From 53dd4b1458d97d5348206bfae453df2a3a42659f Mon Sep 17 00:00:00 2001 From: STEINNI Date: Wed, 7 Jan 2026 10:28:23 +0000 Subject: [PATCH] graflow: EIC + text replacement --- app/assets/html/bzGraflow/nodesEIC.html | 59 ++++++++++++++++++ app/assets/html/bzGraflow/nodesTest2.html | 14 +++-- app/assets/html/test.html | 71 ++++++++++++++++------ app/assets/json/bzGraflow/testFlowEic.json | 35 +++++++++++ app/thirdparty/buildoz/bzGraflow.js | 21 +++++-- 5 files changed, 171 insertions(+), 29 deletions(-) create mode 100644 app/assets/html/bzGraflow/nodesEIC.html create mode 100644 app/assets/json/bzGraflow/testFlowEic.json diff --git a/app/assets/html/bzGraflow/nodesEIC.html b/app/assets/html/bzGraflow/nodesEIC.html new file mode 100644 index 0000000..dc77f0f --- /dev/null +++ b/app/assets/html/bzGraflow/nodesEIC.html @@ -0,0 +1,59 @@ + + + + diff --git a/app/assets/html/bzGraflow/nodesTest2.html b/app/assets/html/bzGraflow/nodesTest2.html index 2ec357f..6e6d09e 100644 --- a/app/assets/html/bzGraflow/nodesTest2.html +++ b/app/assets/html/bzGraflow/nodesTest2.html @@ -14,7 +14,8 @@ .bzgf-node .text { position: absolute; top: 50%; - transform: translateY(-50%); + left: 50%; + transform: translateX(-50%) translateY(-50%); width: 100%; height: 2em; color: white; @@ -42,6 +43,8 @@ height: 30px; border-radius: 50%; } + .bzgf-node[data-nodetype="start"] .text, + .bzgf-node[data-nodetype="end"] .text{ width: 80%; } .bzgf-node[data-nodetype="condition"]{ border: none; @@ -66,9 +69,10 @@ height: 70px; padding: 0; } + .bzgf-node[data-nodetype="process"] .text{ width: 80%; } .bzgf-node[data-nodetype="process"] .dbline{ border: 1px solid white; - width: 80%; + width: 75%; height: 100%; position: absolute; top: -1px; @@ -94,11 +98,8 @@ } .bzgf-node[data-nodetype="database"] .text{ background: black; - width: 99%; - height: 98%; + width: 87%; z-index: 1; - position: absolute; - inset: 0; } .bzgf-node[data-nodetype="database"] .bottom{ z-index: 0; @@ -120,6 +121,7 @@ padding: 0; border: none; } + .bzgf-node[data-nodetype="preparation"] .text{ width: 85%; } .bzgf-node[data-nodetype="preparation"] .outerframe{ width: 100%; height: 100%; diff --git a/app/assets/html/test.html b/app/assets/html/test.html index 61fc94d..09d50d2 100644 --- a/app/assets/html/test.html +++ b/app/assets/html/test.html @@ -4,24 +4,38 @@ graflow - - + - - - - - - - + +
+ + +
+
+ +
+ + +
+
+ +
+ + +
+
diff --git a/app/assets/json/bzGraflow/testFlowEic.json b/app/assets/json/bzGraflow/testFlowEic.json new file mode 100644 index 0000000..ac86071 --- /dev/null +++ b/app/assets/json/bzGraflow/testFlowEic.json @@ -0,0 +1,35 @@ +{ + "nodesFile": "/app/assets/html/bzGraflow/nodesEIC.html", + "flow": { + "nodes":[ + { "nodeType": "eicBasic", + "id": "aze", + "coords": { "x": 50, "y": 120}, + "data": { + "title": "Build attendees list", + "subtitle": "Build an attendees list to email" + } + }, + { "nodeType": "eicBasic", + "id": "aze2", + "coords": { "x": 300, "y": 120}, + "data": { + "title": "Select message", + "subtitle": "Select an email template" + } + }, + { "nodeType": "eicBasic", + "id": "aze3", + "coords": { "x": 550, "y": 120}, + "data": { + "title": "Data mapping", + "subtitle": "Associate content variables with attendees data" + } + } + ], + "links": [ + { "from": ["aze", "out1"], "to": ["aze2", "in1"] }, + { "from": ["aze2", "out1"], "to": ["aze3", "in1"] } + ] + } +} \ No newline at end of file diff --git a/app/thirdparty/buildoz/bzGraflow.js b/app/thirdparty/buildoz/bzGraflow.js index cb7e024..67b7310 100644 --- a/app/thirdparty/buildoz/bzGraflow.js +++ b/app/thirdparty/buildoz/bzGraflow.js @@ -30,6 +30,12 @@ class BZgraflow extends Buildoz{ this.loadFlow(flowUrl) // Let it load async } + error(msg, err){ + this.innerHTML = `
${msg}
` + if(err) console.error(msg, err) + else console.error(msg) + } + async loadFlow(url){ const res = await fetch(url+'?'+crypto.randomUUID()) const buf = await res.text() @@ -37,11 +43,12 @@ class BZgraflow extends Buildoz{ try{ flowObj = JSON.parse(buf) } catch(err){ - console.error('Could not parse flow JSON!?', err) + this.error('Could not parse flow JSON!?', err) + return } if(!flowObj.nodesFile){ - console.error('No nodesFile in JSON!?') + this.error('No nodesFile in JSON!?') return } await this.loadNodes(flowObj.nodesFile) @@ -81,9 +88,15 @@ class BZgraflow extends Buildoz{ } } - addNode(type, id, x, y){ + addNode(type, id, x, y, data){ + if(!(type in this.nodesRegistry)){ console.warn(`Unknown node type (${type})`); return(null)} const nodeDef = this.nodesRegistry[type] this.stagedNodes[id] = nodeDef.cloneNode(true) + if(data){ + for(const token in data){ + this.stagedNodes[id].innerHTML = this.stagedNodes[id].innerHTML.replace(new RegExp(`\{${token}\}`, 'g'), data[token]) + } + } const portEls = this.stagedNodes[id].querySelectorAll('.port') this.stagedNodes[id].style.left = `${x}px` this.stagedNodes[id].style.top = `${y}px` @@ -113,7 +126,7 @@ class BZgraflow extends Buildoz{ let x = 0 let y = 0 for(const node of this.flow.nodes){ - const nodeEl = this.addNode(node.nodeType, node.id , node.coords.x, node.coords.y) + const nodeEl = this.addNode(node.nodeType, node.id , node.coords.x, node.coords.y, node.data) } for(const link of this.flow.links){ this.addWire(link)