-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpanel.htm
More file actions
793 lines (658 loc) · 24.1 KB
/
Copy pathpanel.htm
File metadata and controls
793 lines (658 loc) · 24.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Flow Workspace</title>
<link href="/iotstyle.css" rel="stylesheet" type="text/css">
<script type="module" src="micro.js"></script>
<script src="microsvg.js"></script>
<script src="/sfc/loader.js"></script>
<style>
#panel {
--con-color: #080808;
fill: none;
background-color: silver;
background-image: linear-gradient(to top, rgba(0, 0, 0, .2) 1px, transparent 1px),
linear-gradient(to left, rgba(0, 0, 0, .2) 1px, transparent 1px);
background-size: 12px 12px;
}
#panel #templates {
display: none;
}
#edges>path {
stroke: var(--con-color);
stroke-width: 3;
stroke-linecap: round;
marker-end: url(#arrow);
}
.node {
font-size: 11px;
font-family: sans-serif;
fill: black;
fill-opacity: 1;
stroke: none;
font-style: normal;
font-weight: normal;
cursor: move;
}
.node rect {
fill: #d4dced;
stroke-width: 0;
}
/* connector pins */
.node circle {
fill: var(--con-color);
stroke-width: 2;
stroke: #d4dced;
r: 6;
&[draggable] {
cursor: crosshair;
}
.node .config {
cursor: pointer;
}
.dragCircle {
fill: none;
stroke: none;
}
#Grid {
fill: #e0e0e0;
stroke: none
}
}
</style>
</head>
<body class="sitelayout fillscreen" style="--layout-gap:0">
<u-toast></u-toast>
<header>
<h1>Flow Workspace</h1>
</header>
<nav class="navbar">
<a class="button" href="/">Home</a>
<a class="button" href="/board.htm">Board</a>
<a class="button" href="/microide.htm">IDE</a>
<a class="button" href="/log.htm">Log</a>
<span class="gap"></span>
<button id="addButton">+</button>
<button id="unlock">unlock</button>
<button id="auto">auto</button>
<button id="sysButton">sys</button>
</nav>
<main style="user-select: none;overflow:scroll">
<svg id="panel">
<defs>
<marker id="arrow" markerWidth="6" markerHeight="6" refX="14" refY="8" orient="auto" viewBox="0 0 16 16">
<path d="M0,0 L0,16 L16,8 z" style="fill:var(--con-color)" />
</marker>
</defs>
<rect height="100%" width="100%"></rect>
<g id="templates">
<g draggable="true" class="node">
<title></title>
<rect width="64" height="64" rx="8"></rect>
<use class="icon" x="16" y="8" width="32" height="32" color="#203050" href="" />
<use class="config" x="48" y="4" width="12" height="12" color="#203050" cursor="pointer"
href="/icons.svg#config" />
<text class="id" x="32" y="56" text-anchor="middle">subtitle</text>
<circle pin="in" cx="3" cy="32"></circle>
<circle pin="out" draggable="true" cx="61" cy="32"></circle>
</g>
</g>
<g id="nodes"></g>
<g id="edges"></g>
</svg>
</main>
<script type="module">
import { hub, micro, fetchJSON, fetchText, getHashParams, toBool } from '/micro.js';
window.hub = hub;
window.getHashParams = getHashParams;
window.toBool = toBool;
var params = getHashParams({ sys: false });
var allComponentsLoaded = window.loadComponent(['u-toast', 'u-form-json', 'u-form-dialog']);
// calc the current event/mouse/touch position
function getSVGPos(panel, evt) {
var newScale = panel.currentScale;
var translation = panel.currentTranslate;
var panelPos = panel.getBoundingClientRect();
var ret = {
x: Math.round((evt.clientX - translation.x) / newScale - panelPos.left),
y: Math.round((evt.clientY - translation.y) / newScale - panelPos.top)
};
return (ret);
} // getSVGPos()
// mode a svg group to a specific position using transform:translate
function moveSVGGroup(g, x, y) {
g.setAttribute('transform', 'translate(' + x + ',' + y + ')');
} // moveSVGGroup
// find the center position of the named pin in a svg node group.
function _pinPos(g, pin) {
var panelPos = panelObj.getBoundingClientRect();
var obj = g.querySelector('[pin="' + pin + '"]');
if (!obj) {
obj = g;
}
var b2 = obj.getBoundingClientRect();
var pos = {
x: Math.round(b2.left + b2.width / 2 - panelPos.left),
y: Math.round(b2.top + b2.height / 2 - panelPos.top)
};
return (pos);
} // _pinPos()
// =====
// GRID dimension and size
const PANEL_GRIDSIZE = 72; // px
const NODE_SIZE = 64; // px
const PANEL_WIDTH = 16;
const PANEL_HEIGHT = 12;
const XPref = 64; // x-prefering curve for Edges
const ITERATE = 500; // number of iterations for the force-directed layout algorithm
const DELTA = 0.0004; // minimum movement of a node to be counted as a move in the force-directed layout algorithm. Used to stop the algorithm when no significant movement is observed.
// svg container objects
const panelObj = document.getElementById('panel');
const nodesGroup = document.getElementById('nodes');
const edgesGroup = document.getElementById('edges');
// Drag & Drop support variables.
var DragNode; // node element where dragging started.
var DragObj = null; // SVGObject that will be dragged
var DragMode = null;
var DragOffset = null;
// https://cs.brown.edu/people/rtamassi/gdhandbook/chapters/force-directed.pdf
class LAYOUT {
XY = "uXY"; // key in localstorage for placements
/*
HomeDing config data model ->
create nodes = {id, icon, conf, x, y, fx, fy }
create edges = {src, tar, obj}
*/
nodes = {};
edges = [];
// add a new node
addNode(id, t, s) {
var n = this.nodes[id] ?? (this.nodes[id] = {});
n.id = id;
n.icon = uElements.defs[t]?.icon || t;
n.conf = s;
n.x = 0;
n.y = 0;
n.fx = 0;
n.fy = 0;
}
// add a new edge
addEdge(srcPath, tarPath) {
this.edges.push({
src: srcPath,
tar: tarPath
});
}
/** analyse edges (connections)
* to identify void actions and unconnected nodes.
* - for every edge, count outgoing and incoming edges of the connected nodes.
* - remove edges with non-existing source or target node.
* */
analyseChains() {
// reset in/out counters to 0
for (const n of Object.values(this.nodes)) {
n._out = n._in = 0;
}
// remove edge going into the nirvana
this.edges = this.edges.filter(l => {
const fits = (this.nodes[l.src] && this.nodes[l.tar]);
if (!fits) {
console.log("undeliverable action:", l.src, l.tar);
}
return (fits);
});
this.edges.forEach(l => {
this.nodes[l.src]._out++;
this.nodes[l.tar]._in++;
});
}
/**
* Place disconnected nodes in a fixed row at the top.
*
* For every node without incoming or outgoing edges, this method
* assigns a distinct x coordinate, fixes y at 0, and marks the node
* as fixed so the force-directed layout does not move it.
*/
placeSingleNodes() {
let px = 1;
for (const n of Object.values(this.nodes)) {
if (n._out == 0 && n._in == 0) {
n.x = px++;
n.y = 0;
n._fixed = true;
}
}
} // placeSingleNodes()
/** Load possibly existingnode placements from localStorage and assign them to the nodes.
*
* This method reads the node placements from localStorage using the key defined in this.XY.
* It then iterates over all nodes and checks if they are not already fixed and if there is a corresponding placement in the loaded data.
* If both conditions are met, it assigns the loaded x and y coordinates to the node and marks it as fixed to prevent further movement by the layout algorithm.
* */
loadPlacements() {
// read position from localstorage
const locs = JSON.parse(window.localStorage.getItem(this.XY) || "{}");
let px = 1;
for (const [id, n] of Object.entries(this.nodes)) {
if ((!n._fixed) && (locs[id])) {
n.x = locs[id].x;
n.y = locs[id].y;
n._fixed = true;
}
}
} // loadPlacements()
/* initial placement of all nodes
- force-directed graph layout
- nodes repel each other
- edges attract their nodes
- single nodes are placed in a row at the top.
*/
placeNodes() {
var py = 1;
this.analyseChains();
this.placeSingleNodes();
this.loadPlacements();
// heuristic initial placement from left to right
for (const n of Object.values(this.nodes)) {
if (!n._fixed) {
// nodes with edges vertically;
if (n._in === 0) {
n.x = 3;
} else if (n._out === 0) {
n.x = 8;
} else {
n.x = 6 + n._in - n._out;
}
n.x = Math.max(n.x, 0);
n.y = py++;
}
} // for
} // placeNodes()
// reset the force calculation of all nodes.
// If unlock is true, also reset the fixed state of all nodes with edges
// and clear the localStorage persisted positioning.
calcReset(unlock = false) {
for (const n of Object.values(this.nodes)) {
n.fx = 0;
n.fy = 0;
if ((unlock) && (n._out > 0 || n._in > 0)) {
n._fixed = false;
}
} // for
if (unlock) {
window.localStorage.removeItem(this.XY);
}
}
// perform one iteration of the force-directed layout algorithm.
// For each pair of nodes, it calculates the repelling force
// and updates the force accumulators (fx and fx) of the nodes accordingly.
// Then, for each edge, it calculates the attracting force between the connected nodes and updates their force accumulators.
// Finally, it moves each node based on the accumulated forces, unless the node is marked as fixed.
// The method returns the total number of nodes that were moved during this iteration.
moveNodes() {
let cntMoves = 0;
this.calcReset();
const prev = [];
for (const node1 of Object.values(this.nodes).filter(node => node.y > 0)) {
// only use nodes with edges.
for (const node2 of prev) {
calcRepel(node1, node2);
}
prev.push(node1);
}
for (const edge of this.edges) {
calcSpring(this.nodes[edge.src], this.nodes[edge.tar]);
}
for (const node of Object.values(this.nodes)) {
cntMoves += moveForce(node);
}
return (cntMoves);
} // moveNodes()
// create / update all svg objects for nodes to current position of nodes
drawAllNodes() {
for (const nodeId in this.nodes) {
const t = nodeId.split('/')[0];
const e = this.nodes[nodeId];
const ed = uElements.defs[t];
const sData = JSON.stringify(e.conf ?? {}, null, 2);
let obj = e.obj;
if (!obj) {
obj = e.obj = document.querySelector('#templates .node').cloneNode(true);
nodesGroup.appendChild(obj);
obj.id = nodeId;
if (ed) {
if ((!ed.events) || (ed.events.length == 0)) {
const pin = obj.querySelector('[pin="out"]');
if (pin) pin.style.display = "none";
}
}
obj.querySelector('.config').addEventListener('click', function(evt) {
let t = evt.target;
while (t && !t.classList.contains('node')) t = t.parentElement;
const d = t.getAttribute('data');
const id = t.getAttribute('id').split('/');
const dlg = document.querySelector('dialog#configElement');
dlg.showModal({ ...JSON.parse(d), type: id[0], id: id[1] });
});
}
if (e.icon)
obj.querySelector('.icon').setAttribute("href", "/icons.svg#" + e.icon);
obj.querySelector('title').textContent = sData;
obj.setAttribute("data", sData);
obj.querySelector('.id').firstChild.textContent = nodeId;
moveSVGGroup(obj, e.x * PANEL_GRIDSIZE + 4, e.y * PANEL_GRIDSIZE + 4);
}
const uPos = {};
Object.values(this.nodes).forEach(n => {
if (n._fixed)
uPos[n.id] = { x: n.x, y: n.y };
});
window.localStorage.setItem(this.XY, JSON.stringify(uPos));
} // drawAllNodes()
// create / update all svg objects edges to current position of nodes
drawAllEdges() {
let aPos, ePos;
for (let n = 0; n < this.edges.length; n++) {
const f = this.edges[n];
const sObj = this.nodes[f.src];
const tObj = this.nodes[f.tar];
if (sObj && tObj) {
const obj = f.obj;
aPos = _pinPos(sObj.obj, 'out');
ePos = _pinPos(tObj.obj, 'in');
f.obj = this.drawEdge(obj, aPos, ePos);
}
}
} // drawAllEdges()
// create / update a svg object for an edge from aPos to ePos. If obj is given, reuse it, otherwise create a new one.
drawEdge(obj, aPos, ePos) {
if (!obj) {
obj = edgesGroup.ownerDocument.createElementNS("http://www.w3.org/2000/svg", 'path');
edgesGroup.appendChild(obj);
// obj.addEventListener('click', function(evt) {
// // how to delete an edge ?
// });
}
obj.setAttribute("d", `M ${aPos.x + 6},${aPos.y} C ${aPos.x + XPref},${aPos.y} ${ePos.x - XPref},${ePos.y} ${ePos.x - 18},${ePos.y} L ${ePos.x - 6},${ePos.y}`);
return obj;
} // drawEdge()
/// perform multiple iterations of the force-directed layout algorithm
// until no significant movement of nodes is observed
// or the maximum number of iterations is reached.
// After the iterations, it updates the positions of all nodes and edges on the SVG panel.
shiftNodes() {
for (let n = 0; n < ITERATE; n++) {
if (!this.moveNodes()) {
console.log("shiftNodes:", n);
break;
}
};
this.drawAllNodes();
this.drawAllEdges();
} // shiftNodes()
}
const layout = new LAYOUT();
/// helper function to constrain a value between a min and max value.
function constrain(val, min, max) {
if (val < min) {
val = min;
} else if (val > max) {
val = max;
}
return (val);
} // constrain()
// ===== attach event listeners to buttons and panel
/// add click handler on the unlock button to reset the force calculation and unlock all nodes for manual placement.
document.getElementById('unlock').addEventListener("click", evt => {
layout.calcReset(true);
});
/// add click handler on the auto button to start the force-directed layout algorithm.
document.getElementById('auto').addEventListener("click", evt => {
layout.shiftNodes();
});
/// add click handler on the add button to open the new element dialog.
document.getElementById('addButton').addEventListener("click", async evt => {
// load dialogs on demand.
await loadPlugins();
document.querySelector('dialog#newElement').showModal()
.then(data => {
const dConfig = document.querySelector('dialog#configElement');
dConfig.showModal(data);
});
});
window.onerror = function(msg, url, lineNo, columnNo, error) {
var message = [
'Error: ' + msg,
'Script: ' + url,
'Line: ' + lineNo,
'Column: ' + columnNo,
'Error object: ' + JSON.stringify(error)
].join(' - ');
console.error(message);
};
var params = getHashParams({ sys: false });
window.addEventListener("hashchange", function() {
window.location.reload();
});
document.getElementById('sysButton').addEventListener('click', function(evt) {
params.sys = !toBool(params.sys);
window.location.hash = 'sys=' + params.sys;
});
async function loadPlugins() {
var ret;
if (!document.querySelector('dialog#action')) {
// lazy load dialogs.
ret = fetchText("./board-new.htm")
.then(txt => {
document.body.appendChild(document.createRange().createContextualFragment(txt));
});
}
return (ret);
} // loadPlugins()
// Element definitions and config+state of running elements
const uElements = {
defs: {},
impl: [],
env: {},
config: {},
state: {}
};
window.uElements = uElements;
// adjust size of the panelObj.
panelObj.style.width = PANEL_GRIDSIZE * PANEL_WIDTH + "px";
panelObj.style.height = PANEL_GRIDSIZE * PANEL_HEIGHT + "px";
// create all nodes and edges from the HomeDing config files
function createNodes(conf) {
for (let [eType, elem] of Object.entries(conf)) {
eType = eType.toLowerCase();
for (let [eID, eConf] of Object.entries(elem)) {
eID = eID.toLowerCase();
if (toBool(params.sys) || (!uElements.defs[eType]) || (!toBool(uElements.defs[eType].sys))) {
// show this one.
const id = `${eType}/${eID}`;
// create node
layout.addNode(id, eType, eConf);
// create edges
for (let [key, actions] of Object.entries(eConf)) {
if (key.substring(0, 2) == 'on') {
actions.split(',').forEach(function(a) {
layout.addEdge(id, a.split('?')[0]);
});
}
}
}
}
}
} // createNodes()
// calc force given by 2 nodes repel each other
function calcRepel(node1, node2) {
const dx = node2.x - node1.x;
const dy = node2.y - node1.y;
const d2 = dx * dx + dy * dy;
const f1 = 0.1;
const fx = f1 * dx / d2;
const fy = f1 * dy / d2;
node1.fx -= fx;
node1.fy -= fy;
node2.fx += fx;
node2.fy += fy;
} // calcRepel()
// calc force given by 2 connected nodes attacting each other
function calcSpring(node1, node2) {
if (node1 && node2) {
const dx = node2.x - node1.x;
const dy = node2.y - node1.y;
const d2 = dx * dx + dy * dy;
const d = Math.sqrt(d2);
const f1 = 2 * Math.log(d / 2);
let fx = f1 * dx / d;
let fy = f1 * dy / d;
// bended springs cause a force as well
fx -= 0.3;
fy = 2 * fy;
node1.fx += fx;
node1.fy += fy;
node2.fx -= fx;
node2.fy -= fy;
}
} // calcSpring
// calc the movement of a node given its accumulated forces.
// return 1 when the node was moved, otherwise 0.
// The movement is constrained to the panel size and a factor is applied to slow down the movement.
function moveForce(node) {
let ret = 0;
if (!node._fixed) {
const nx = constrain(node.x + node.fx * 0.1, 0, PANEL_WIDTH - 1);
const ny = constrain(node.y + node.fy * 0.1, 1, PANEL_HEIGHT - 1);
if (Math.abs(nx - node.x) > DELTA || Math.abs(ny - node.y) > DELTA) {
node.x = nx;
node.y = ny;
ret = 1;
}
}
return (ret);
}
// create / update all svg objects edges to current position of nodes
// create / update all svg objects edges to current position of nodes
window.addEventListener('load', async function() {
// get configuration data
var p2 = fetchJSON('/elements.json').then(json => uElements.defs = json);
var p3 = fetchJSON('/env.json').then(json => uElements.env = json);
var p4 = fetchJSON('/config.json').then(json => uElements.config = json);
var p5 = fetchJSON('/api/elements').then(json => uElements.impl = json);
// start when all data is available
Promise.all([p2, p3, p4, p5]).then(function() {
hub.write('env', JSON.stringify(uElements.env));
hub.write('config', JSON.stringify(uElements.config));
createNodes(uElements.env);
createNodes(uElements.config);
layout.placeNodes();
layout.shiftNodes();
loadPlugins();
});
});
// === drag & drop
var _conPos;
var _conObj;
panelObj.addEventListener("mousedown", function(evt) {
if (!DragObj) {
var o = evt.target;
// check for a draggable object.
while (o && o.attributes && (!o.attributes["draggable"]))
o = o.parentNode;
if (o && o.attributes && (o.attributes["draggable"]))
DragObj = o;
}
let obj = DragObj;
while (obj && !obj.classList.contains('node')) obj = obj.parentElement;
DragNode = Object.values(layout.nodes).find(n => (n.obj === obj));
if (DragObj) {
if (DragObj.getAttribute('pin') === 'out') {
DragMode = 'c';
// create draggable circle
DragOffset = _pinPos(DragObj.parentNode, 'out');
DragObj = createSVGNode(panelObj, 'circle', {
class: 'dragCircle',
cx: DragOffset.x,
cy: DragOffset.y,
r: 6
});
_conPos = { x: DragOffset.x, y: DragOffset.y };
_conObj = layout.drawEdge(undefined, _conPos, _conPos);
} else {
DragMode = 'n';
// calculate Drag Offset = mouse position - drag object position
DragOffset = getSVGPos(panelObj, evt);
var cc = DragObj.getCTM();
DragOffset.x -= cc.e;
DragOffset.y -= cc.f;
}
}
}); // mouseDown
panelObj.addEventListener("mousemove", function(evt) {
if (DragObj) {
var DragPos = getSVGPos(panelObj, evt);
moveSVGGroup(DragObj, DragPos.x - DragOffset.x, DragPos.y - DragOffset.y);
if (DragMode === 'n') {
layout.drawAllEdges();
} else {
DragPos.x += 6;
layout.drawEdge(_conObj, _conPos, DragPos);
}
} // if
}); // mousemove
panelObj.addEventListener("mouseup", function(evt) {
if (DragObj) {
var DragPos = getSVGPos(panelObj, evt);
if (DragMode === 'c') {
// connector drop
DragObj.remove();
_conObj.remove();
// find target node
const x = DragPos.x / PANEL_GRIDSIZE;
const y = DragPos.y / PANEL_GRIDSIZE;
const node = Object.values(layout.nodes).find(n =>
(n.x <= x) && (n.x + 1 > x) && (n.y <= y) && (n.y + 1 > y)
);
// Start the action connect dialog
if ((node) && (node !== DragNode)) {
const dlg = document.querySelector('dialog#action');
const d = {
srcId: DragNode.id,
event: '',
target: node.id,
action: '',
value: '$v'
};
// debugger;
dlg.showModal(d).then(data => {
console.debug('panel', 'action dialog result', data);
// DragNode and target node do exist.
const { fName, config } = findConfig(DragNode.id);
config[data.event] = `${data.target}?${data.action}=${data.value}`;
debugger;
changeConfig(DragNode.id, config);
});
}
} else if (DragMode === 'n') {
// node drop
const node = Object.values(layout.nodes).find(n => (n.obj === DragObj));
node.x = Math.floor(6 * (DragPos.x - DragOffset.x) / PANEL_GRIDSIZE) / 6;
node.y = Math.floor(6 * (DragPos.y - DragOffset.y) / PANEL_GRIDSIZE) / 6;
node._fixed = true;
}
layout.drawAllNodes();
layout.drawAllEdges();
} // if
DragObj = null;
}); // mouseup
if (window !== window.top) {
// disable header and navbar in portal mode.
document.querySelector('.u-header').style.display = 'none';
document.querySelector('.u-navbar').style.display = 'none';
} // if
</script>
</body>
</html>