20609: Change subprocess progress bar to combine relevant process statuses
[arvados.git] / src / lib / cwl-svg / graph / step-node.ts
1 import {StepModel} from "cwlts/models";
2 import {Edge} from "./edge";
3 import {GraphNode} from "./graph-node";
4 import {TemplateParser} from "./template-parser";
5
6 export class StepNode {
7
8     private svg: SVGSVGElement;
9     private stepEl: SVGElement;
10     private model: StepModel;
11
12     constructor(element: SVGElement, stepModel: StepModel) {
13
14         this.stepEl = element;
15         this.svg    = element.ownerSVGElement!;
16         this.model  = stepModel;
17
18     }
19
20     update() {
21         const tpl = GraphNode.makeTemplate(this.model);
22         const el  = TemplateParser.parse(tpl)!;
23
24         this.stepEl.innerHTML = el.innerHTML;
25
26         // Reposition all edges
27         const incomingEdges = this.svg.querySelectorAll(`.edge[data-destination-node="${this.model.connectionId}"]`);
28         const outgoingEdges = this.svg.querySelectorAll(`.edge[data-source-node="${this.model.connectionId}"`);
29
30         for (const edge of [...Array.from(incomingEdges), ...Array.from(outgoingEdges)]) {
31             Edge.spawnBetweenConnectionIDs(
32                 this.svg.querySelector(".workflow") as SVGGElement,
33                 edge.getAttribute("data-source-connection")!,
34                 edge.getAttribute("data-destination-connection")!
35             );
36         }
37
38         console.log("Should redraw input port", incomingEdges);
39
40     }
41 }