|
@@ -73,10 +73,11 @@ const getJsonData = () => {
|
|
|
}
|
|
|
JSON.parse(JSON.stringify(data.cells)).forEach((cell: any) => {
|
|
|
if (cell.shape === 'workflow-node') {
|
|
|
+ console.log(cell)
|
|
|
const node: any = {
|
|
|
id: cell.id,
|
|
|
- x: cell.position.x,
|
|
|
- y: cell.position.y,
|
|
|
+ type: cell.data.workflowData.type,
|
|
|
+ position: cell.position,
|
|
|
data: cell.data.workflowData,
|
|
|
}
|
|
|
delete node.data.edgeSource
|
|
@@ -88,7 +89,7 @@ const getJsonData = () => {
|
|
|
source: cell.source.cell,
|
|
|
}
|
|
|
if (!cell.source.port.includes('end')) {
|
|
|
- edge.port = cell.source.port
|
|
|
+ edge.sourceHandle = cell.source.port
|
|
|
}
|
|
|
res.graph.edges.push(edge)
|
|
|
}
|
|
@@ -108,14 +109,19 @@ const initData = () => {
|
|
|
WorkflowStore.$patch(
|
|
|
(s: any) => (s.envVars.vars = data.environmentVariables || []),
|
|
|
)
|
|
|
- // if (data.graph.viewport) {
|
|
|
- // state.workflowData = data.graph
|
|
|
- // } else {
|
|
|
- state.workflowData = {
|
|
|
- nodes: [],
|
|
|
- edges: [],
|
|
|
+ if (data.graph.viewport) {
|
|
|
+ const graph = {
|
|
|
+ viewport: data.graph.viewport,
|
|
|
+ nodes: formatNodes(data.graph.nodes),
|
|
|
+ edges: formatEdges(data.graph.edges),
|
|
|
+ }
|
|
|
+ state.workflowData = graph
|
|
|
+ } else {
|
|
|
+ state.workflowData = {
|
|
|
+ nodes: [],
|
|
|
+ edges: [],
|
|
|
+ }
|
|
|
}
|
|
|
- // }
|
|
|
})
|
|
|
.catch(() => {})
|
|
|
.finally(() => {})
|
|
@@ -123,6 +129,27 @@ const initData = () => {
|
|
|
// WorkflowStore.$patch((s: any) => (s.envVars.vars = d.envVars || []))
|
|
|
// state.workflowData = d.graph
|
|
|
}
|
|
|
+const formatNodes = (arr) => {
|
|
|
+ return arr.map((node: any) => {
|
|
|
+ const obj = {
|
|
|
+ id: node.id,
|
|
|
+ x: node.position.x,
|
|
|
+ y: node.position.y,
|
|
|
+ data: node.data,
|
|
|
+ }
|
|
|
+ return obj
|
|
|
+ })
|
|
|
+}
|
|
|
+const formatEdges = (arr) => {
|
|
|
+ return arr.map((edge: any) => {
|
|
|
+ const obj = {
|
|
|
+ source: edge.source,
|
|
|
+ target: edge.target,
|
|
|
+ port: edge.sourceHandle || null,
|
|
|
+ }
|
|
|
+ return obj
|
|
|
+ })
|
|
|
+}
|
|
|
onMounted(() => {
|
|
|
initData()
|
|
|
})
|