Skip to content

Commit

Permalink
fixed flow-graph build error (#67)
Browse files Browse the repository at this point in the history
Co-authored-by: 乔风鳞 <[email protected]>
  • Loading branch information
qiaofenlin and 乔风鳞 authored May 31, 2024
1 parent dec90a4 commit 21feb20
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 122 deletions.
2 changes: 2 additions & 0 deletions flow-graph/.env.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_SERVER_PORT=80
VITE_BASE_URL=__micro_flow_graph_base_url
3 changes: 2 additions & 1 deletion flow-graph/.env.prod
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
VITE_SERVER_PORT=80
VITE_SERVER_PORT=80
VITE_BASE_URL=/flow-graph/
6 changes: 4 additions & 2 deletions flow-graph/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ COPY . ./
RUN npm cache clean --force
RUN npm config set strict-ssl false

RUN npm install [email protected] -g && pnpm install && pnpm build:prod
RUN npm install [email protected] -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;'"
1 change: 1 addition & 0 deletions flow-graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 4 additions & 2 deletions flow-graph/src/common/flowService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
});
});
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions flow-graph/src/components/NodesBar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
if (flowGraphStore.getNodePrototypeRegistry().isEmpty()) {
return;
}
nodePrototypeMap.value = new Map<NodeCategory, NodeVO[]>();
nodePrototypeRegistry.value.getNodePrototypes().forEach((nodePrototype) => {
const nodeCategoryNumber = nodePrototype.node_category;
const nodeCategory = getNodeCategoryByNumber(nodeCategoryNumber);
Expand Down
17 changes: 13 additions & 4 deletions flow-graph/src/components/modals/NodeDefinitionModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -246,7 +254,6 @@
// 2.2 获取 fieldsSchemaData 数据,填充表单
fieldsSchemaData.value = getFieldsSchemaData(node, nodePrototype);
open.value = true;
});
Expand All @@ -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
Expand All @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions flow-graph/src/models/X6FlowGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion flow-graph/src/models/task/baseTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class BaseTask {
name: string;
title: string;
category: string;
taskTemplateId: number;
taskTemplateId: string;
next: string;
inputMappings: Mapping[];
outputMappings: Mapping[];
Expand Down
4 changes: 2 additions & 2 deletions flow-graph/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,85 +366,4 @@ private JsonNode transToJSON(String descriptor) {
throw new RuntimeException();
}
}

public List<Map<String, Object>> getDagOpGroups() {
List<Map<String, Object>> 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<JSONObject> protocolPlugins = protocolPluginService.getProtocolPlugins();
List<Node> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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:}")
Expand Down Expand Up @@ -176,31 +175,6 @@ private void appendTraceInfo(Map<String, Object> result) {
}
}

/**
* 节点类型列表
*
* @return
*/
@GetMapping(value = "/edit/dag_op_groups.json")
public Map<String, Object> getDagOpGroups() {
List<Map<String, Object>> 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<String, Object> 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<String, Object> convert(@RequestBody UserLoginRequest request) {
Expand Down

0 comments on commit 21feb20

Please sign in to comment.