From 21feb2032d383548d1a85007313020e17ce0cffa Mon Sep 17 00:00:00 2001 From: qfl <790872612@qq.com> Date: Fri, 31 May 2024 15:20:58 +0800 Subject: [PATCH] fixed flow-graph build error (#67) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 乔风鳞 --- flow-graph/.env.docker | 2 + flow-graph/.env.prod | 3 +- flow-graph/Dockerfile | 6 +- flow-graph/package.json | 1 + flow-graph/src/common/flowService.ts | 6 +- flow-graph/src/components/NodesBar/index.vue | 1 + .../components/modals/NodeDefinitionModal.vue | 17 +++- flow-graph/src/models/X6FlowGraph.ts | 6 +- flow-graph/src/models/task/baseTask.ts | 2 +- flow-graph/vite.config.ts | 4 +- .../service/facade/DAGDescriptorFacade.java | 81 ------------------- .../rill/flow/controller/BgController.java | 26 ------ 12 files changed, 33 insertions(+), 122 deletions(-) create mode 100644 flow-graph/.env.docker diff --git a/flow-graph/.env.docker b/flow-graph/.env.docker new file mode 100644 index 000000000..c1f2901d9 --- /dev/null +++ b/flow-graph/.env.docker @@ -0,0 +1,2 @@ +VITE_SERVER_PORT=80 +VITE_BASE_URL=__micro_flow_graph_base_url diff --git a/flow-graph/.env.prod b/flow-graph/.env.prod index 9579fa52e..90bddc01a 100644 --- a/flow-graph/.env.prod +++ b/flow-graph/.env.prod @@ -1 +1,2 @@ -VITE_SERVER_PORT=80 \ No newline at end of file +VITE_SERVER_PORT=80 +VITE_BASE_URL=/flow-graph/ \ No newline at end of file diff --git a/flow-graph/Dockerfile b/flow-graph/Dockerfile index acfc35594..91d011f79 100644 --- a/flow-graph/Dockerfile +++ b/flow-graph/Dockerfile @@ -6,10 +6,12 @@ COPY . ./ RUN npm cache clean --force RUN npm config set strict-ssl false -RUN npm install pnpm@9.0.2 -g && pnpm install && pnpm build:prod +RUN npm install pnpm@9.0.2 -g && pnpm install && pnpm build:docker FROM nginx:1.23.3-alpine as production-stage COPY --from=build-stage /data/flow-graph/dist /usr/share/nginx/html/dist COPY --from=build-stage /data/flow-graph/deploy/nginx.conf /etc/nginx/nginx.conf.template -CMD /bin/sh -c "envsubst '80' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf && nginx -g 'daemon off;'" +CMD sed -i "s|/__micro_flow_graph_base_url|$FLOW_MICRO_GRAPH_BASE|g" /usr/share/nginx/html/dist/index.html && \ + sed -i "s|/__micro_flow_graph_base_url|$FLOW_MICRO_GRAPH_BASE|g" /usr/share/nginx/html/dist/assets/index*.js && \ + /bin/sh -c "envsubst '80' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf && nginx -g 'daemon off;'" diff --git a/flow-graph/package.json b/flow-graph/package.json index f50e39a10..b8143e97f 100644 --- a/flow-graph/package.json +++ b/flow-graph/package.json @@ -8,6 +8,7 @@ "build": "vite build", "build:dev": "vite build --mode development", "build:prod": "vite build --mode prod", + "build:docker": "vite build --mode docker", "preview": "vite preview" }, "dependencies": { diff --git a/flow-graph/src/common/flowService.ts b/flow-graph/src/common/flowService.ts index fe212bfa5..561073543 100644 --- a/flow-graph/src/common/flowService.ts +++ b/flow-graph/src/common/flowService.ts @@ -20,7 +20,6 @@ import yaml from 'js-yaml'; import { useI18nStoreWithOut } from "../store/modules/i18nStore"; import { InputSchemaHandlerFactory } from "./inputSchemaStyleHandler"; import { InputSchemaTypeEnum } from "../models/enums/InputSchemaTypeEnum"; - // 保存节点分组信息 export function saveNodeGroups(queryTemplateNodesUrls: string[]) { const flowGraphStore = useFlowStoreWithOut(); @@ -30,7 +29,9 @@ export function saveNodeGroups(queryTemplateNodesUrls: string[]) { } queryTemplateNodesUrls.forEach((url) => { queryTemplateNodes(url).then((res) => { + const urlSearchParams = new URLSearchParams(url) res.forEach((node) => { + node.id = urlSearchParams.get('source') ? urlSearchParams.get('source') + node.id : node.id; nodePrototypeRegistry.add(node); }); }); @@ -391,7 +392,8 @@ export function convertObjectToMappingParametersMap(nodeSchema: string, obj: any for (const key in obj) { let bizType = nodeTemplateSchema?.properties?.[key]?.bizType !== undefined ? nodeTemplateSchema?.properties?.[key]?.bizType : InputSchemaTypeEnum.NORMAL; if (Array.isArray(obj[key]) || typeof obj[key] === 'string') { - let arrayToMapResult = InputSchemaHandlerFactory.getHandler(bizType).saveSchemaValueHandle(key, obj[key]) + const newKey = currentKey ? `${currentKey}.${key}` : key; + let arrayToMapResult = InputSchemaHandlerFactory.getHandler(bizType).saveSchemaValueHandle(newKey, obj[key]) result = new Map([...result, ...arrayToMapResult]) continue; } diff --git a/flow-graph/src/components/NodesBar/index.vue b/flow-graph/src/components/NodesBar/index.vue index 9493f6ce0..7164a4777 100644 --- a/flow-graph/src/components/NodesBar/index.vue +++ b/flow-graph/src/components/NodesBar/index.vue @@ -45,6 +45,7 @@ if (flowGraphStore.getNodePrototypeRegistry().isEmpty()) { return; } + nodePrototypeMap.value = new Map(); nodePrototypeRegistry.value.getNodePrototypes().forEach((nodePrototype) => { const nodeCategoryNumber = nodePrototype.node_category; const nodeCategory = getNodeCategoryByNumber(nodeCategoryNumber); diff --git a/flow-graph/src/components/modals/NodeDefinitionModal.vue b/flow-graph/src/components/modals/NodeDefinitionModal.vue index 5452c7444..47c701b00 100644 --- a/flow-graph/src/components/modals/NodeDefinitionModal.vue +++ b/flow-graph/src/components/modals/NodeDefinitionModal.vue @@ -206,8 +206,7 @@ if (nodeSchema === undefined) { continue; } - - let result = InputSchemaHandlerFactory.getHandler(nodeSchema[inputTargetParam]?.bizType).showSchemaValueHandle(inputTargetParam, nodeSchema, inputMappingMap, flowGraph) + let result = InputSchemaHandlerFactory.getHandler(getBizTypeByJsonPath(inputTargetParam, nodeSchema)).showSchemaValueHandle(inputTargetParam, nodeSchema, inputMappingMap, flowGraph) if (result === null) { continue; } @@ -217,6 +216,15 @@ oldJsonSchemaFormData = getJsonByJsonPaths(jsonSchemaFormDataList); } + function getBizTypeByJsonPath(path: string, schema: JSON) { + let bizType + path.split('.').forEach(item => { + schema = schema[item]?.properties ? schema[item].properties : schema[item]; + bizType = schema?.bizType; + }) + return bizType; + } + // 监听点击事件后弹modal function isOpenModel(opt: OptEnum) { return opt === OptEnum.CREATE || opt === OptEnum.EDIT; @@ -246,7 +254,6 @@ // 2.2 获取 fieldsSchemaData 数据,填充表单 fieldsSchemaData.value = getFieldsSchemaData(node, nodePrototype); - open.value = true; }); @@ -269,6 +276,8 @@ function getFieldsSchemaData(node: RillNode, nodePrototype: NodePrototype): object { let fields = {}; + let nodeTaskFields = JSON.parse(JSON.stringify(node.task)); + if ( getNodeCategoryByNumber(nodePrototype.node_category) == NodeCategory.TEMPLATE_NODE && nodePrototype.template !== undefined @@ -280,7 +289,7 @@ return fields; } for (const field of Object.keys(node.task)) { - fields[field] = node.task[field]; + fields[field] = nodeTaskFields[field]; } return fields; } diff --git a/flow-graph/src/models/X6FlowGraph.ts b/flow-graph/src/models/X6FlowGraph.ts index 2047705c0..7e322969a 100644 --- a/flow-graph/src/models/X6FlowGraph.ts +++ b/flow-graph/src/models/X6FlowGraph.ts @@ -79,7 +79,7 @@ export class X6FlowGraph implements FlowGraph { if (getNodeCategoryByNumber(nodePrototype.node_category) === NodeCategory.TEMPLATE_NODE) { const taskYaml = nodePrototype.template.task_yaml; const fields = yaml.load(taskYaml); - taskName = fields?.name; + taskName = fields?.name === undefined ? fields?.category : fields?.name; } else { taskName = nodePrototype.meta_data.category; } @@ -255,7 +255,7 @@ export class X6FlowGraph implements FlowGraph { } const nodeCategory = getNodeCategoryByNumber(nodePrototype.node_category); if (nodeCategory === NodeCategory.TEMPLATE_NODE) { - node.task.taskTemplateId = Number(node.nodePrototypeId); + node.task.taskTemplateId = node.nodePrototypeId; } } @@ -462,7 +462,7 @@ export class X6FlowGraph implements FlowGraph { continue; } for (const inputMapping of inputMappings) { - const source = inputMapping.source; + const source = String(inputMapping.source); if (source === undefined || !source.startsWith('$.context.' + oldTaskName + '.')) { continue; } diff --git a/flow-graph/src/models/task/baseTask.ts b/flow-graph/src/models/task/baseTask.ts index a3845090c..eaa7473d7 100644 --- a/flow-graph/src/models/task/baseTask.ts +++ b/flow-graph/src/models/task/baseTask.ts @@ -5,7 +5,7 @@ export class BaseTask { name: string; title: string; category: string; - taskTemplateId: number; + taskTemplateId: string; next: string; inputMappings: Mapping[]; outputMappings: Mapping[]; diff --git a/flow-graph/vite.config.ts b/flow-graph/vite.config.ts index 486c05ed0..4cad7dfa0 100644 --- a/flow-graph/vite.config.ts +++ b/flow-graph/vite.config.ts @@ -5,12 +5,12 @@ import { fileURLToPath, URL } from 'node:url'; export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), ''); - console.log("micro app: ", mode, env.VITE_BASE_URL, "http://localhost:7001/flow-graph/") + console.log("micro app: ", mode, env.VITE_BASE_URL) return { define: { __APP_ENV__: JSON.stringify(env.APP_ENV), }, - base: mode === 'development' ? env.VITE_BASE_URL : "/flow-graph/", + base: env.VITE_BASE_URL, plugins: [ vue(), qiankun('flow-graph', { diff --git a/rill-flow-service/src/main/java/com/weibo/rill/flow/service/facade/DAGDescriptorFacade.java b/rill-flow-service/src/main/java/com/weibo/rill/flow/service/facade/DAGDescriptorFacade.java index 28132edab..315e79304 100644 --- a/rill-flow-service/src/main/java/com/weibo/rill/flow/service/facade/DAGDescriptorFacade.java +++ b/rill-flow-service/src/main/java/com/weibo/rill/flow/service/facade/DAGDescriptorFacade.java @@ -366,85 +366,4 @@ private JsonNode transToJSON(String descriptor) { throw new RuntimeException(); } } - - public List> getDagOpGroups() { - List> groups = new ArrayList<>(); - Node function = Node.builder() - .id(1) - .name("") - .category(NodeType.FUNCTION.getType()) - .status("") - .resourceName("") - .pattern("task_sync") - .inputMappings("") - .outputMappings("") - .tolerance("") - .build(); - - Node rillFlow = Node.builder() - .id(2) - .name("") - .category(NodeType.RILL_FLOW.getType()) - .status("") - .resourceName("rillflow://default:common:test:prod:test") - .pattern("task_scheduler") - .inputMappings("") - .outputMappings("") - .tolerance("") - .build(); - JSONObject group3 = new JSONObject(); - group3.put("groupId", 1); - group3.put("groupName", "流程节点"); - group3.put("operatorList", Arrays.asList(function, rillFlow)); - groups.add(group3); - - Node forNode = Node.builder() - .id(4) - .name("") - .category(NodeType.FOREACH.getType()) - .status("") - .resourceName("") - .pattern("task_scheduler") - .inputMappings("") - .outputMappings("") - .tolerance("") - .build(); - - Node returnNode = Node.builder() - .id(5) - .name("") - .category(NodeType.RETURN.getType()) - .pattern("task_scheduler") - .conditions("") - .build(); - - JSONObject group4 = new JSONObject(); - group4.put("groupId", 2); - group4.put("groupName", "逻辑节点"); - group4.put("operatorList", Arrays.asList(forNode, returnNode)); - groups.add(group4); - - //plugins - List protocolPlugins = protocolPluginService.getProtocolPlugins(); - List pluginNodeList = Lists.newArrayList(); - for (int i = 0; i < protocolPlugins.size(); i++) { - Node pluginNode = Node.builder() - .id(3 + i) - .name(protocolPlugins.get(i).getString("name")) - .icon(protocolPlugins.get(i).getString("icon")) - .schema(protocolPlugins.get(i).getString("schema")) - .category(NodeType.HTTP_HTTPS.getType()) - .pattern("task_scheduler") - .conditions("") - .build(); - pluginNodeList.add(pluginNode); - } - JSONObject pluginsGroup = new JSONObject(); - pluginsGroup.put("groupId", 3); - pluginsGroup.put("groupName", "插件节点"); - pluginsGroup.put("operatorList", pluginNodeList); - groups.add(pluginsGroup); - - return groups; - } } diff --git a/rill-flow-web/src/main/java/com/weibo/rill/flow/controller/BgController.java b/rill-flow-web/src/main/java/com/weibo/rill/flow/controller/BgController.java index 8548bab23..53f43c298 100644 --- a/rill-flow-web/src/main/java/com/weibo/rill/flow/controller/BgController.java +++ b/rill-flow-web/src/main/java/com/weibo/rill/flow/controller/BgController.java @@ -51,7 +51,6 @@ @Api(tags = {"管理后台接口"}) @RequestMapping("/flow/bg") public class BgController { - private static final String EXECUTION_ID = "execution_id"; private static final String BUSINESS_IDS = "business_ids"; @Value("${rill_flow_trace_query_host:}") @@ -176,31 +175,6 @@ private void appendTraceInfo(Map result) { } } - /** - * 节点类型列表 - * - * @return - */ - @GetMapping(value = "/edit/dag_op_groups.json") - public Map getDagOpGroups() { - List> groups = dagDescriptorFacade.getDagOpGroups(); - return Map.of("data", groups, "message", "", "success", true); - } - - /** - * 临时调试使用,后续上线需要删掉 - * - * @param flowUser - * @param executionId - * @param brief - * @return - */ - @RequestMapping(value = "get.json", method = RequestMethod.GET) - public Map get(User flowUser, - @RequestParam(value = EXECUTION_ID) String executionId, - @RequestParam(value = "brief", defaultValue = "false") boolean brief) { - return ImmutableMap.of("ret", dagRuntimeFacade.getBasicDAGInfo(executionId, brief)); - } @PostMapping(value = "/user/login.json") public Map convert(@RequestBody UserLoginRequest request) {