summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sdc-workflow-designer-ui/src/app/app.module.ts4
-rw-r--r--sdc-workflow-designer-ui/src/app/components/canvas/canvas.component.html2
-rw-r--r--sdc-workflow-designer-ui/src/app/components/node/node.component.css9
-rw-r--r--sdc-workflow-designer-ui/src/app/components/node/node.component.ts3
-rw-r--r--sdc-workflow-designer-ui/src/app/components/property/properties.component.html1
-rw-r--r--sdc-workflow-designer-ui/src/app/components/property/script-task/script-task.component.html28
-rw-r--r--sdc-workflow-designer-ui/src/app/components/property/script-task/script-task.component.ts22
-rw-r--r--sdc-workflow-designer-ui/src/app/components/toolbar/toolbar.component.css8
-rw-r--r--sdc-workflow-designer-ui/src/app/directive/drag-select/drag-select.directive.ts134
-rw-r--r--sdc-workflow-designer-ui/src/app/model/workflow/node-type.enum.ts1
-rw-r--r--sdc-workflow-designer-ui/src/app/model/workflow/script-task.ts24
-rw-r--r--sdc-workflow-designer-ui/src/app/services/data-access/in-memory-data.service.ts3
-rw-r--r--sdc-workflow-designer-ui/src/app/services/jsplumb.service.ts49
-rw-r--r--sdc-workflow-designer-ui/src/app/services/workflow-process.service.ts4
-rw-r--r--sdc-workflow-designer-ui/src/app/services/workflow.service.ts1
-rw-r--r--sdc-workflow-designer-ui/src/styles.css6
16 files changed, 282 insertions, 17 deletions
diff --git a/sdc-workflow-designer-ui/src/app/app.module.ts b/sdc-workflow-designer-ui/src/app/app.module.ts
index e2d36a3a..b2bcb742 100644
--- a/sdc-workflow-designer-ui/src/app/app.module.ts
+++ b/sdc-workflow-designer-ui/src/app/app.module.ts
@@ -45,11 +45,14 @@ import { SwaggerTreeConverterService } from "./services/swagger-tree-converter.s
import { WorkflowProcessService } from "./services/workflow-process.service";
import { IntermediateCatchEventComponent } from "./components/property/intermediate-catch-event/intermediate-catch-event.component";
import { SequenceFlowComponent } from "./components/sequence-flow/sequence-flow.component";
+import { ScriptTaskComponent } from "./components/property/script-task/script-task.component";
+import { DragSelectDirective } from "./directive/drag-select/drag-select.directive";
@NgModule({
declarations: [
AppComponent,
CanvasComponent,
+ DragSelectDirective,
EditablePropertyComponent,
IntermediateCatchEventComponent,
MenuComponent,
@@ -62,6 +65,7 @@ import { SequenceFlowComponent } from "./components/sequence-flow/sequence-flow.
PropertiesComponent,
RestTaskComponent,
RestTaskParametersComponent,
+ ScriptTaskComponent,
SequenceFlowComponent,
StartEventParametersComponent,
ToolbarComponent,
diff --git a/sdc-workflow-designer-ui/src/app/components/canvas/canvas.component.html b/sdc-workflow-designer-ui/src/app/components/canvas/canvas.component.html
index 97fe3a67..daf26bc1 100644
--- a/sdc-workflow-designer-ui/src/app/components/canvas/canvas.component.html
+++ b/sdc-workflow-designer-ui/src/app/components/canvas/canvas.component.html
@@ -11,6 +11,6 @@
* ZTE - initial API and implementation and/or initial documentation
*/
-->
-<div id="canvas" class="canvas" (click)="canvasClick()">
+<div id="canvas" class="canvas" (click)="canvasClick()" b4tDragSelect>
<b4t-node *ngFor="let node of getWorkflow()?.nodes; let last = last;" [node]="node" [last]="last"></b4t-node>
</div>
diff --git a/sdc-workflow-designer-ui/src/app/components/node/node.component.css b/sdc-workflow-designer-ui/src/app/components/node/node.component.css
index 1498fcea..093892e4 100644
--- a/sdc-workflow-designer-ui/src/app/components/node/node.component.css
+++ b/sdc-workflow-designer-ui/src/app/components/node/node.component.css
@@ -256,6 +256,15 @@
background-image: url("data:image/svg+xml;utf8,<?xml version='1.0' encoding='UTF-8' standalone='no'?><svg xmlns='http://www.w3.org/2000/svg' xmlns:oryx='http://www.b3mn.org/oryx' viewBox='1 1 30 30' width='28' height='28' style='fill:transparent' version='1.0'> <defs></defs> <oryx:magnets> <oryx:magnet oryx:cx='16' oryx:cy='16' oryx:default='yes' /> </oryx:magnets> <oryx:docker oryx:cx='16' oryx:cy='16' /> <g pointer-events='fill'> <defs> <radialGradient id='background' cx='10%' cy='10%' r='100%' fx='10%' fy='10%'> <stop offset='0%' stop-color='#ffffff' stop-opacity='1'/> <stop id='fill_el' offset='100%' stop-color='#ffffff' stop-opacity='1'/> </radialGradient> </defs> <circle id='bg_frame' cx='16' cy='16' r='15' stroke='black' stroke-width='1' style='stroke-dasharray: 5.5, 3' /> <circle id='frame2_non_interrupting' cx='16' cy='16' r='12' stroke='black' fill='none' stroke-width='1' style='stroke-dasharray: 4.5, 3' /><circle id='frame' cx='16' cy='16' r='15' stroke='black' fill='none' stroke-width='1'/><circle id='frame2' cx='16' cy='16' r='12' stroke='black' fill='none' stroke-width='1'/><circle id='circle' cx='16' cy='16' r='10' stroke='black' fill='none' stroke-width='1'/> <path id='path1' d='M 16 6 L 16 9 M 21 7 L 19.5 10 M 25 11 L 22 12.5 M 26 16 L 23 16 M 25 21 L 22 19.5 M 21 25 L 19.5 22 M 16 26 L 16 23 M 11 25 L 12.5 22 M 7 21 L 10 19.5 M 6 16 L 9 16 M 7 11 L 10 12.5 M 11 7 L 12.5 10 M 18 9 L 16 16 L 20 16' fill='none' stroke='black' /> <text font-size='11' id='text_name' x='16' y='33' oryx:align='top center' stroke='black'></text></g></svg>");
}
+
+.scriptTask {
+ border-radius: 8px;
+ border: 2px solid rgb(0, 0, 0);
+ height: 60px;
+ width: 80px;
+ background-image: url("data:image/svg+xml;utf8,<?xml version='1.0' encoding='UTF-8' standalone='no'?> <svg xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg' xmlns:oryx='http://www.b3mn.org/oryx' version='1.0' width='100%' height='100%'> <g id='scriptTask' transform='scale(1, 1) translate(8,8)'> <path oryx:anchors='top left' id='paper' style='opacity:1;fill:none;stroke:#000000' d='M6.402,0.5h14.5c0,0-5.833,2.833-5.833,5.583s4.417,6,4.417,9.167 s-4.167,5.083-4.167,5.083H0.235c0,0,5-2.667,5-5s-4.583-6.75-4.583-9.25S6.402,0.5,6.402,0.5z'/> <path oryx:anchors='top left' id='line1' style='opacity:1;fill:none;stroke:#000000;stroke-width:1.5' d='M 3.5 4.5 L 13.5 4.5' /> <path oryx:anchors='top left' id='line2' style='opacity:1;fill:none;stroke:#000000;stroke-width:1.5' d='M 3.8 8.5 L 13.8 8.5' /> <path oryx:anchors='top left' id='line3' style='opacity:1;fill:none;stroke:#000000;stroke-width:1.5' d='M 6.3 12.5 L 16.3 12.5' /> <path oryx:anchors='top left' id='line4' style='opacity:1;fill:none;stroke:#000000;stroke-width:1.5' d='M 6.5 16.5 L 16.5 16.5' /> </g> </svg> ");
+}
+
.restTask {
border-radius: 8px;
border: 2px solid rgb(0, 0, 0);
diff --git a/sdc-workflow-designer-ui/src/app/components/node/node.component.ts b/sdc-workflow-designer-ui/src/app/components/node/node.component.ts
index 7a48e5dc..5fe189db 100644
--- a/sdc-workflow-designer-ui/src/app/components/node/node.component.ts
+++ b/sdc-workflow-designer-ui/src/app/components/node/node.component.ts
@@ -41,7 +41,8 @@ export class NodeComponent implements AfterViewInit, OnDestroy {
ngAfterViewInit(): void {
if(this.last) {
- this.jsPlumbService.initNode('.node');
+ this.jsPlumbService.initNode();
+ this.jsPlumbService.connectNodes();
}
this.currentTypeSubscription = this.broadcastService.currentType$.subscribe(type => {
diff --git a/sdc-workflow-designer-ui/src/app/components/property/properties.component.html b/sdc-workflow-designer-ui/src/app/components/property/properties.component.html
index 86a67823..2870a4b1 100644
--- a/sdc-workflow-designer-ui/src/app/components/property/properties.component.html
+++ b/sdc-workflow-designer-ui/src/app/components/property/properties.component.html
@@ -42,4 +42,5 @@
<b4t-start-event-parameters *ngIf="'startEvent' == node.type" [node]="node"></b4t-start-event-parameters>
<b4t-rest-task *ngIf="node.type == 'restTask'" [node]="node" [planItems]="planItems"></b4t-rest-task>
<b4t-intermediate-catch-event *ngIf="'intermediateCatchEvent' == node.type" [node]="node"></b4t-intermediate-catch-event>
+ <b4t-script-task *ngIf="node.type == 'scriptTask'" [node]="node"></b4t-script-task>
</div>
diff --git a/sdc-workflow-designer-ui/src/app/components/property/script-task/script-task.component.html b/sdc-workflow-designer-ui/src/app/components/property/script-task/script-task.component.html
new file mode 100644
index 00000000..6d2bf1ac
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/components/property/script-task/script-task.component.html
@@ -0,0 +1,28 @@
+<!--
+/*******************************************************************************
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+-->
+
+<div class="form-group row">
+ <label class="col-md-3 form-control-label text-md-right">Script Format</label>
+ <div class="col-md-9">
+ <input class="form-control" type="text" [(ngModel)]="node.scriptFormate">
+ </div>
+</div>
+
+<div class="form-group row">
+ <label class="col-md-3 form-control-label text-md-right">Script</label>
+ <div class="col-md-9">
+ <textarea class="form-control" type="text" rows="20" [(ngModel)]="node.script"></textarea>
+ </div>
+</div>
+
diff --git a/sdc-workflow-designer-ui/src/app/components/property/script-task/script-task.component.ts b/sdc-workflow-designer-ui/src/app/components/property/script-task/script-task.component.ts
new file mode 100644
index 00000000..9e55ed49
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/components/property/script-task/script-task.component.ts
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+import { AfterViewInit, Component, Input } from '@angular/core';
+
+import { ScriptTask } from "../../../model/workflow/script-task";
+
+@Component({
+ selector: 'b4t-script-task',
+ templateUrl: 'script-task.component.html',
+})
+export class ScriptTaskComponent {
+ @Input() public node: ScriptTask;
+}
diff --git a/sdc-workflow-designer-ui/src/app/components/toolbar/toolbar.component.css b/sdc-workflow-designer-ui/src/app/components/toolbar/toolbar.component.css
index 942ac586..3edffd66 100644
--- a/sdc-workflow-designer-ui/src/app/components/toolbar/toolbar.component.css
+++ b/sdc-workflow-designer-ui/src/app/components/toolbar/toolbar.component.css
@@ -93,6 +93,14 @@ button span{
background-image: url("data:image/svg+xml;utf8,<?xml version='1.0' encoding='UTF-8' standalone='no'?><svg xmlns='http://www.w3.org/2000/svg' xmlns:oryx='http://www.b3mn.org/oryx' viewBox='1 1 30 30' width='28' height='28' style='fill:transparent' version='1.0'> <defs></defs> <oryx:magnets> <oryx:magnet oryx:cx='16' oryx:cy='16' oryx:default='yes' /> </oryx:magnets> <oryx:docker oryx:cx='16' oryx:cy='16' /> <g pointer-events='fill'> <defs> <radialGradient id='background' cx='10%' cy='10%' r='100%' fx='10%' fy='10%'> <stop offset='0%' stop-color='#ffffff' stop-opacity='1'/> <stop id='fill_el' offset='100%' stop-color='#ffffff' stop-opacity='1'/> </radialGradient> </defs> <circle id='bg_frame' cx='16' cy='16' r='15' stroke='black' stroke-width='1' style='stroke-dasharray: 5.5, 3' /> <circle id='frame2_non_interrupting' cx='16' cy='16' r='12' stroke='black' fill='none' stroke-width='1' style='stroke-dasharray: 4.5, 3' /><circle id='frame' cx='16' cy='16' r='15' stroke='black' fill='none' stroke-width='1'/><circle id='frame2' cx='16' cy='16' r='12' stroke='black' fill='none' stroke-width='1'/><circle id='circle' cx='16' cy='16' r='10' stroke='black' fill='none' stroke-width='1'/> <path id='path1' d='M 16 6 L 16 9 M 21 7 L 19.5 10 M 25 11 L 22 12.5 M 26 16 L 23 16 M 25 21 L 22 19.5 M 21 25 L 19.5 22 M 16 26 L 16 23 M 11 25 L 12.5 22 M 7 21 L 10 19.5 M 6 16 L 9 16 M 7 11 L 10 12.5 M 11 7 L 12.5 10 M 18 9 L 16 16 L 20 16' fill='none' stroke='black' /> <text font-size='11' id='text_name' x='16' y='33' oryx:align='top center' stroke='black'></text></g></svg>");
}
+
+.scriptTask {
+ background-size: cover;
+ height: 30px;
+ width: 30px;
+ background-image: url("data:image/svg+xml;utf8,<?xml version='1.0' encoding='UTF-8' standalone='no'?> <svg xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg' xmlns:oryx='http://www.b3mn.org/oryx' version='1.0' width='100%' height='100%'> <g id='scriptTask' transform='scale(1, 1) translate(8,8)'> <path oryx:anchors='top left' id='paper' style='opacity:1;fill:none;stroke:#000000' d='M6.402,0.5h14.5c0,0-5.833,2.833-5.833,5.583s4.417,6,4.417,9.167 s-4.167,5.083-4.167,5.083H0.235c0,0,5-2.667,5-5s-4.583-6.75-4.583-9.25S6.402,0.5,6.402,0.5z'/> <path oryx:anchors='top left' id='line1' style='opacity:1;fill:none;stroke:#000000;stroke-width:1.5' d='M 3.5 4.5 L 13.5 4.5' /> <path oryx:anchors='top left' id='line2' style='opacity:1;fill:none;stroke:#000000;stroke-width:1.5' d='M 3.8 8.5 L 13.8 8.5' /> <path oryx:anchors='top left' id='line3' style='opacity:1;fill:none;stroke:#000000;stroke-width:1.5' d='M 6.3 12.5 L 16.3 12.5' /> <path oryx:anchors='top left' id='line4' style='opacity:1;fill:none;stroke:#000000;stroke-width:1.5' d='M 6.5 16.5 L 16.5 16.5' /> </g> </svg> ");
+}
+
.toscaTask {
border-radius: 8px;
border: 2px solid rgb(0, 0, 0);
diff --git a/sdc-workflow-designer-ui/src/app/directive/drag-select/drag-select.directive.ts b/sdc-workflow-designer-ui/src/app/directive/drag-select/drag-select.directive.ts
new file mode 100644
index 00000000..395cf040
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/directive/drag-select/drag-select.directive.ts
@@ -0,0 +1,134 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+
+import { AfterViewInit, Directive, ElementRef } from '@angular/core';
+import { JsPlumbService } from "../../services/jsplumb.service";
+
+@Directive({
+ selector: '[b4tDragSelect]'
+})
+export class DragSelectDirective implements AfterViewInit {
+ private selectBox: any;
+ public selecting = false;
+
+ public relatvieX: number;
+ public relatvieY: number;
+
+ public startX: number;
+ public startY: number;
+ public endX: number;
+ public endY: number;
+
+ public left: number = 0;
+ public top: number = 0;
+ public width: number = 0;
+ public height: number = 0;
+
+ constructor(private el: ElementRef, private jsPlumbService: JsPlumbService) { }
+
+ public ngAfterViewInit(): void {
+ this.selectBox = document.createElement('div');
+ const selectArea = this.el.nativeElement.appendChild(this.selectBox);
+ this.el.nativeElement.addEventListener("mousedown", (event: MouseEvent) => this.mouseDown(event));
+ this.el.nativeElement.addEventListener("mousemove", (event: MouseEvent) => this.mouseMove(event));
+ this.el.nativeElement.addEventListener("mouseup", (event: MouseEvent) => this.mouseUp(event));
+ }
+
+ public mouseDown(event: MouseEvent) {
+ this.relatvieX = event.clientX - event.offsetX;
+ this.relatvieY = event.clientY - event.offsetY;
+
+ this.width = 0;
+ this.height = 0;
+ this.startX = event.clientX;
+ this.startY = event.clientY;
+ this.endX = this.startX;
+ this.endY = this.startY;
+ this.selecting = true;
+ this.updateSelectArea();
+ }
+
+ public mouseMove(event: MouseEvent) {
+ this.endX = event.clientX;
+ this.endY = event.clientY;
+
+ this.updateSelectArea();
+ }
+
+ public mouseUp(event: MouseEvent) {
+ this.selecting = false;
+ this.updateSelectArea();
+ }
+
+ private updateSelectArea() {
+ if (this.selecting) {
+ this.selectBox.className = 'selecting';
+ } else {
+ this.selectBox.className = '';
+ return;
+ }
+
+ this.getAllSelectedNodes();
+
+ const leftTmp = this.startX >= this.endX ? this.endX : this.startX;
+ const topTmp = this.startY >= this.endY ? this.endY : this.startY;
+
+ this.left = leftTmp - this.relatvieX;
+ this.top = topTmp - this.relatvieY;
+
+ this.width = Math.abs(this.startX - this.endX);
+ this.height = Math.abs(this.endY - this.startY);
+
+ this.selectBox.style.top = this.top + 'px';
+ this.selectBox.style.left = this.left + 'px';
+ this.selectBox.style.width = this.width + 'px';
+ this.selectBox.style.height = this.height + 'px';
+ }
+
+ public getAllSelectedNodes() {
+ if(!this.selecting) {
+ return;
+ }
+ const selectedNodes = [];
+
+ const nodes = this.el.nativeElement.querySelectorAll('div.node');
+ nodes.forEach(node => {
+ if(this.checkNodeSelected(node)) {
+ selectedNodes.push(node);
+ }
+ });
+
+ this.jsPlumbService.jsplumbInstance.clearDragSelection();
+ this.jsPlumbService.jsplumbInstance.addToDragSelection(selectedNodes);
+
+ }
+
+ private checkNodeSelected(node: any): boolean {
+ const nodeLeft = node.offsetLeft;
+ const nodeTop = node.offsetTop;
+ const nodeRigth = nodeLeft + node.clientWidth;
+ const nodeBottom = nodeTop + node.clientHeight;
+
+ const selectedRight = this.left + this.width;
+ const selectedBottom = this.top + this.height;
+
+ return this.between(nodeLeft, this.left, selectedRight)
+ && this.between(nodeRigth, this.left, selectedRight)
+ && this.between(nodeTop, this.top, selectedBottom)
+ && this.between(nodeBottom, this.top, selectedBottom);
+ }
+
+ private between(value, min, max): boolean {
+ return min <= value && value <= max;
+ }
+
+}
diff --git a/sdc-workflow-designer-ui/src/app/model/workflow/node-type.enum.ts b/sdc-workflow-designer-ui/src/app/model/workflow/node-type.enum.ts
index c8d2fe2b..2481cdbb 100644
--- a/sdc-workflow-designer-ui/src/app/model/workflow/node-type.enum.ts
+++ b/sdc-workflow-designer-ui/src/app/model/workflow/node-type.enum.ts
@@ -17,4 +17,5 @@ export enum NodeType {
intermediateCatchEvent,
exclusiveGateway,
parallelGateway,
+ scriptTask,
}
diff --git a/sdc-workflow-designer-ui/src/app/model/workflow/script-task.ts b/sdc-workflow-designer-ui/src/app/model/workflow/script-task.ts
new file mode 100644
index 00000000..3772226c
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/model/workflow/script-task.ts
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+import { Position } from './position';
+import { WorkflowNode } from './workflow-node';
+import { SequenceFlow } from "./sequence-flow";
+
+export class ScriptTask extends WorkflowNode {
+ public scriptFormat: string;
+ public script: string;
+
+ public constructor(public id: string, public name: string, public type: string, public position: Position, public sequenceFlows: SequenceFlow[]) {
+ super(id, name, type, position, sequenceFlows);
+ }
+
+}
diff --git a/sdc-workflow-designer-ui/src/app/services/data-access/in-memory-data.service.ts b/sdc-workflow-designer-ui/src/app/services/data-access/in-memory-data.service.ts
index 0ad5face..efc1e0b5 100644
--- a/sdc-workflow-designer-ui/src/app/services/data-access/in-memory-data.service.ts
+++ b/sdc-workflow-designer-ui/src/app/services/data-access/in-memory-data.service.ts
@@ -40,7 +40,8 @@ export class InMemoryDataService implements InMemoryDbService {
configs: {
microservices: []
}
- }
+ },
+ {"id":"fjh","name":"fjh","nodes":[{"id":"node0","name":"startEvent","type":"startEvent","position":{"top":43,"left":80.5,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node0","targetRef":"node2"}],"parameters":[]},{"id":"node1","name":"endEvent","type":"endEvent","position":{"top":273,"left":488,"width":200,"height":100},"sequenceFlows":[]},{"id":"node2","name":"exclusiveGateway","type":"exclusiveGateway","position":{"top":6,"left":178,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node2","targetRef":"node3","condition":"未完成"},{"sourceRef":"node2","targetRef":"node4","condition":"创建完成"}]},{"id":"node3","name":"createVL","type":"restTask","position":{"top":13.5,"left":283.5,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node3","targetRef":"node11"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node4","name":"restTask","type":"restTask","position":{"top":110,"left":152,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node4","targetRef":"node5"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node5","name":"exclusiveGateway","type":"exclusiveGateway","position":{"top":27.5,"left":401.5,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node5","targetRef":"node6","condition":"未完成"},{"sourceRef":"node5","targetRef":"node12","condition":"创建完成"}]},{"id":"node6","name":"createVNF","type":"restTask","position":{"top":91,"left":389,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node6","targetRef":"node7"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node7","name":"intermediateCatchEvent","type":"intermediateCatchEvent","position":{"top":190.5,"left":398,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node7","targetRef":"node8"}],"timerEventDefinition":{"type":"timeDuration"}},{"id":"node8","name":"query_vnf nslcm","type":"restTask","position":{"top":240,"left":390,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node8","targetRef":"node9"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node9","name":"exclusiveGateway","type":"exclusiveGateway","position":{"top":316.5,"left":405.5,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node9","targetRef":"node7","condition":"未完成"},{"sourceRef":"node9","targetRef":"node10","condition":"已完成"}]},{"id":"node10","name":"scriptTask","type":"scriptTask","position":{"top":405.5,"left":404.5,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node10","targetRef":"node5"}]},{"id":"node11","name":"scriptTask","type":"scriptTask","position":{"top":181.5,"left":110.5,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node11","targetRef":"node2"}]},{"id":"node12","name":"restTask","type":"restTask","position":{"top":147.5,"left":364.5,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node12","targetRef":"node13"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node13","name":"exclusiveGateway","type":"exclusiveGateway","position":{"top":214.5,"left":397.5,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node13","targetRef":"node14","condition":"未结束"},{"sourceRef":"node13","targetRef":"node18","condition":"已结束"}]},{"id":"node14","name":"createSfc","type":"restTask","position":{"top":202,"left":290.5,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node14","targetRef":"node15"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node15","name":"intermediateCatchEvent","type":"intermediateCatchEvent","position":{"top":128,"left":145.5,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node15","targetRef":"node16"}],"timerEventDefinition":{"type":"timeDuration"}},{"id":"node16","name":"restTask","type":"restTask","position":{"top":330.5,"left":221,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node16","targetRef":"node17"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node17","name":"exclusiveGateway","type":"exclusiveGateway","position":{"top":402,"left":351.5,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node17","targetRef":"node15","condition":"未结束"},{"sourceRef":"node17","targetRef":"node19","condition":"已结束"}]},{"id":"node18","name":"restTask","type":"restTask","position":{"top":217.5,"left":194,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node18","targetRef":"node20"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node19","name":"scriptTask","type":"scriptTask","position":{"top":466,"left":389,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node19","targetRef":"node13"}]},{"id":"node20","name":"Assign_all_status","type":"scriptTask","position":{"top":306.5,"left":590.5,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node20","targetRef":"node21"}]},{"id":"node21","name":"post_do","type":"restTask","position":{"top":390,"left":612.5,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node21","targetRef":"node22"}],"produces":[],"consumes":[],"parameters":[],"responses":[]},{"id":"node22","name":"jobstatus","type":"restTask","position":{"top":426,"left":682.5,"width":200,"height":100},"sequenceFlows":[{"sourceRef":"node22","targetRef":"node1"}],"produces":[],"consumes":[],"parameters":[],"responses":[]}],"configs":{"microservices":[]}},
];
return { workflows, swagger};
}
diff --git a/sdc-workflow-designer-ui/src/app/services/jsplumb.service.ts b/sdc-workflow-designer-ui/src/app/services/jsplumb.service.ts
index 06cb2b0f..6aa5028a 100644
--- a/sdc-workflow-designer-ui/src/app/services/jsplumb.service.ts
+++ b/sdc-workflow-designer-ui/src/app/services/jsplumb.service.ts
@@ -15,6 +15,7 @@ import * as jsp from 'jsplumb';
import { WorkflowProcessService } from "./workflow-process.service";
import { BroadcastService } from "./broadcast.service";
import { Subscription } from 'rxjs/Subscription';
+import { WorkflowNode } from "../model/workflow/workflow-node";
/**
* JsPlumbService
@@ -118,25 +119,45 @@ export class JsPlumbService {
});
}
- public initNode(selectorString: string) {
- const selector = this.jsplumbInstance.getSelector(selectorString);
+ public initNode() {
+ this.processService.getProcess().forEach(node => {
+ this.jsplumbInstance.draggable(node.id, {
+ stop: event => {
+ node.position.left = event.pos[0];
+ node.position.top = event.pos[1];
+ },
+ });
- this.jsplumbInstance.draggable(selector, {
- });
+ this.jsplumbInstance.makeTarget(node.id, {
+ detachable: false,
+ isTarget: true,
+ maxConnections: -1,
+ });
- this.jsplumbInstance.makeTarget(selector, {
- detachable: false,
- isTarget: true,
- maxConnections: -1,
+ this.jsplumbInstance.makeSource(node.id, {
+ filter: '.anchor, .anchor *',
+ detachable: false,
+ isSource: true,
+ maxConnections: -1,
+ });
});
+ }
- this.jsplumbInstance.makeSource(selector, {
- filter: '.anchor, .anchor *',
- detachable: false,
- isSource: true,
- maxConnections: -1,
- });
+ public connectNodes() {
+ const nodes: WorkflowNode[] = this.processService.getProcess();
+ nodes.forEach(node => this.connect4OneNode(node));
+ }
+ public connect4OneNode(node: WorkflowNode) {
+ node.sequenceFlows.forEach(sequenceFlow => {
+ const connection = this.jsplumbInstance.connect({
+ source: sequenceFlow.sourceRef,
+ target: sequenceFlow.targetRef,
+ });
+ if (sequenceFlow.condition) {
+ connection.setLabel(sequenceFlow.condition);
+ }
+ });
}
public setLabel(sourceId: string, targetId: string, label: string) {
diff --git a/sdc-workflow-designer-ui/src/app/services/workflow-process.service.ts b/sdc-workflow-designer-ui/src/app/services/workflow-process.service.ts
index 7f56c4af..04417726 100644
--- a/sdc-workflow-designer-ui/src/app/services/workflow-process.service.ts
+++ b/sdc-workflow-designer-ui/src/app/services/workflow-process.service.ts
@@ -23,6 +23,7 @@ import { WorkflowConfigService } from "./workflow-config.service";
import { Swagger, SwaggerModelSimple, SwaggerReferenceObject } from "../model/swagger";
import { WorkflowService } from "./workflow.service";
import { IntermediateCatchEvent } from "../model/workflow/intermediate-catch-event";
+import { ScriptTask } from "../model/workflow/script-task";
/**
* WorkflowService
@@ -51,6 +52,9 @@ export class WorkflowProcessService {
case NodeType[NodeType.intermediateCatchEvent]:
node = new IntermediateCatchEvent(this.createId(), name, type, new Position(top, left), []);
break;
+ case NodeType[NodeType.scriptTask]:
+ node = new ScriptTask(this.createId(), name, type, new Position(top, left), []);
+ break;
default:
node = new WorkflowNode(this.createId(), name, type, new Position(top, left), []);
break;
diff --git a/sdc-workflow-designer-ui/src/app/services/workflow.service.ts b/sdc-workflow-designer-ui/src/app/services/workflow.service.ts
index 7d751923..c1eed4af 100644
--- a/sdc-workflow-designer-ui/src/app/services/workflow.service.ts
+++ b/sdc-workflow-designer-ui/src/app/services/workflow.service.ts
@@ -30,6 +30,7 @@ export class WorkflowService {
public save(): Observable<boolean> {
console.log(this.workflow);
+ console.log(JSON.stringify(this.workflow));
return this.dataAccessService.catalogService.saveWorkflow(this.workflow);
}
}
diff --git a/sdc-workflow-designer-ui/src/styles.css b/sdc-workflow-designer-ui/src/styles.css
index 6b32fc30..0a624d5e 100644
--- a/sdc-workflow-designer-ui/src/styles.css
+++ b/sdc-workflow-designer-ui/src/styles.css
@@ -57,3 +57,9 @@ textarea.form-control {
margin: 0 !important;
font-size: 12px !important;
}
+
+.selecting {
+ border: 1px solid royalblue;
+ background-color: yellowgreen;
+ position: absolute;
+}