UNPKG

pipeline-builder-demo

Version:
49 lines (38 loc) 1.16 kB
import { Injectable } from '@angular/core'; import * as Pipeline from 'pipeline-builder'; @Injectable() export class PipelineDataService { private callCountMap: Map<string, number>; private diagram: Pipeline.IVisualizer; private _workflow: Pipeline.IWorkflow; constructor() { this.callCountMap = new Map<string, number>(); } getDiagram(): Pipeline.IVisualizer { if(!this.diagram){ this.diagram = new Pipeline.Visualizer(document.getElementById('paper')); } return this.diagram; } get workflow(): Pipeline.IWorkflow { return this._workflow; } set workflow(flow: Pipeline.IWorkflow) { this._workflow = flow; } getCallSuffix(desired: string) { desired = desired.toLowerCase(); if (!this.callCountMap.has(desired)) { this.callCountMap.set(desired, 1); return ''; } else { let val = this.callCountMap.get(desired); this.callCountMap.set(desired, val + 1); return `_${val}`; } } existCallSuffix(desired: string) { desired = desired.toLowerCase(); return this.callCountMap.has(desired); } }