From f093dcdbc4012a64c11a293052afbc74d84c8c5a Mon Sep 17 00:00:00 2001 From: Lvbo163 Date: Thu, 11 Jan 2018 19:13:03 +0800 Subject: add backend service add data access interfaces for template data Issue-ID: SDC-905 Change-Id: Ie632b00dbc6ede01b0ee8a3c7abdbbc1f476f1e4 Signed-off-by: Lvbo163 --- .../error-event/error-event.component.html | 15 +++ .../property/error-event/error-event.component.ts | 25 ++++ .../intermediate-catch-event.component.html | 14 ++- .../node-template/node-template.component.html | 49 ++++++++ .../node-template/node-template.component.ts | 132 +++++++++++++++++++++ .../components/property/properties.component.css | 2 +- .../components/property/properties.component.html | 5 +- .../components/property/properties.component.ts | 8 +- .../property/rest-task/rest-task.component.html | 6 +- .../property/rest-task/rest-task.component.ts | 9 +- .../script-task/script-task.component.html | 8 +- .../property/script-task/script-task.component.ts | 2 + .../start-event-parameters.component.html | 25 ---- .../start-event-parameters.component.ts | 35 ------ 14 files changed, 259 insertions(+), 76 deletions(-) create mode 100644 sdc-workflow-designer-ui/src/app/components/property/error-event/error-event.component.html create mode 100644 sdc-workflow-designer-ui/src/app/components/property/error-event/error-event.component.ts create mode 100644 sdc-workflow-designer-ui/src/app/components/property/node-template/node-template.component.html create mode 100644 sdc-workflow-designer-ui/src/app/components/property/node-template/node-template.component.ts delete mode 100644 sdc-workflow-designer-ui/src/app/components/property/start-event-parameters/start-event-parameters.component.html delete mode 100644 sdc-workflow-designer-ui/src/app/components/property/start-event-parameters/start-event-parameters.component.ts (limited to 'sdc-workflow-designer-ui/src/app/components/property') diff --git a/sdc-workflow-designer-ui/src/app/components/property/error-event/error-event.component.html b/sdc-workflow-designer-ui/src/app/components/property/error-event/error-event.component.html new file mode 100644 index 00000000..45abdd0f --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/property/error-event/error-event.component.html @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/sdc-workflow-designer-ui/src/app/components/property/error-event/error-event.component.ts b/sdc-workflow-designer-ui/src/app/components/property/error-event/error-event.component.ts new file mode 100644 index 00000000..f8a63a15 --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/property/error-event/error-event.component.ts @@ -0,0 +1,25 @@ +/******************************************************************************* + * 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 { Component, Input } from '@angular/core'; + +import { ValueSource } from '../../../model/value-source.enum'; +import { Parameter } from '../../../model/workflow/parameter'; +import { ErrorEvent } from '../../../model/workflow/error-event'; + +@Component({ + selector: 'b4t-error-event', + templateUrl: 'error-event.component.html', +}) +export class ErrorEventComponent { + @Input() public node: ErrorEvent; + public sources: ValueSource[] = [ValueSource.String]; +} diff --git a/sdc-workflow-designer-ui/src/app/components/property/intermediate-catch-event/intermediate-catch-event.component.html b/sdc-workflow-designer-ui/src/app/components/property/intermediate-catch-event/intermediate-catch-event.component.html index f615d9f2..3395a6ee 100644 --- a/sdc-workflow-designer-ui/src/app/components/property/intermediate-catch-event/intermediate-catch-event.component.html +++ b/sdc-workflow-designer-ui/src/app/components/property/intermediate-catch-event/intermediate-catch-event.component.html @@ -13,7 +13,7 @@ -->
- +
Duration Date @@ -22,7 +22,7 @@
- +
@@ -30,16 +30,20 @@
- +
- + +
- +
+
diff --git a/sdc-workflow-designer-ui/src/app/components/property/node-template/node-template.component.html b/sdc-workflow-designer-ui/src/app/components/property/node-template/node-template.component.html new file mode 100644 index 00000000..5768c0b5 --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/property/node-template/node-template.component.html @@ -0,0 +1,49 @@ + + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
+ + +
+ + diff --git a/sdc-workflow-designer-ui/src/app/components/property/node-template/node-template.component.ts b/sdc-workflow-designer-ui/src/app/components/property/node-template/node-template.component.ts new file mode 100644 index 00000000..5d7339d0 --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/property/node-template/node-template.component.ts @@ -0,0 +1,132 @@ +/** + * 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 { Subscription } from '../../../../../node_modules/rxjs/Subscription.d'; + +import { PlanTreeviewItem } from '../../../model/plan-treeview-item'; +import { NodeTemplate } from '../../../model/topology/node-template'; +import { ValueSource } from '../../../model/value-source.enum'; +import { Parameter } from '../../../model/workflow/parameter'; +import { ToscaNodeTask } from '../../../model/workflow/tosca-node-task'; +import { BroadcastService } from '../../../services/broadcast.service'; +import { DataService } from '../../../services/data/data.service'; + +/** + * node template component provides operations about tosca modules which saved in winery. + * This component will be used in the property component while the corresponding workflow node is calling the node template's operation + */ +@Component({ + selector: 'b4t-node-template', + templateUrl: 'node-template.component.html', +}) +export class NodeTemplateComponent implements AfterViewInit { + @Input() public node: ToscaNodeTask; + @Input() public planItems: PlanTreeviewItem[]; + + public inputSources: ValueSource[] = [ValueSource.String, ValueSource.Variable, ValueSource.Topology, ValueSource.Plan]; + public outputSources: ValueSource[] = [ValueSource.Topology, ValueSource.Plan]; + public nodeInterfaces: string[] = []; + public nodeOperations: any[] = []; + public nodeTemplates: NodeTemplate[] = []; + + constructor(private dataService: DataService) { + } + + public ngAfterViewInit() { + this.dataService.loadNodeTemplates() + .subscribe(nodeTemplates => this.nodeTemplates = nodeTemplates); + + this.loadInterfaces(); + this.loadOperations(); + } + + public nodeTemplateChanged() { + this.setTemplateNamespace(); + + this.nodeInterfaceChanged(''); + + this.loadInterfaces(); + } + + public nodeInterfaceChanged(newInterface: string) { + this.node.nodeInterface = newInterface; + + this.nodeOperationChanged(''); + + this.loadOperations(); + } + + public nodeOperationChanged(operation: string) { + this.node.operation = operation; + + this.node.input = []; + this.node.output = []; + + this.loadParameters(); + } + + private setTemplateNamespace() { + const nodeTemplate = this.nodeTemplates.find( + tmpNodeTemplate => tmpNodeTemplate.id === this.node.template.id); + + if (nodeTemplate) { + this.node.template.namespace = nodeTemplate.namespace; + this.node.template.type = nodeTemplate.type; + } + } + + private loadInterfaces() { + if (this.node.template.id) { + this.dataService.loadNodeTemplateInterfaces(this.node.template) + .subscribe(interfaces => { + this.nodeInterfaces = interfaces; + }); + } else { + this.nodeInterfaces = []; + } + } + + private loadOperations() { + if (this.node.nodeInterface) { + this.nodeOperations = []; + this.dataService.loadNodeTemplateOperations( + this.node.template, + this.node.nodeInterface) + .subscribe(operations => this.nodeOperations = operations); + } else { + this.nodeOperations = []; + } + } + + private loadParameters() { + if (this.node.operation) { + this.dataService.loadNodeTemplateOperationParameter( + this.node.template, + this.node.nodeInterface, + this.node.operation) + .subscribe(params => { + this.node.input = []; + this.node.output = []; + + params.input.forEach(param => { + const p = new Parameter(param, '', ValueSource[ValueSource.String]); + this.node.input.push(p); + }); + + params.output.forEach(param => { + const p = new Parameter(param, '', ValueSource[ValueSource.Definition]); + this.node.output.push(p); + }); + }); + } + } +} diff --git a/sdc-workflow-designer-ui/src/app/components/property/properties.component.css b/sdc-workflow-designer-ui/src/app/components/property/properties.component.css index 4487e0b3..6c8c67d3 100644 --- a/sdc-workflow-designer-ui/src/app/components/property/properties.component.css +++ b/sdc-workflow-designer-ui/src/app/components/property/properties.component.css @@ -10,7 +10,7 @@ * ZTE - initial API and implementation and/or initial documentation */ - .wm-properties-wrapper { +.wm-properties-wrapper { background-color: white; position: fixed; width: 500px; 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 99f14b56..8aa912d7 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 @@ -12,7 +12,7 @@ */ --> -
+
@@ -34,6 +34,9 @@
+ + + diff --git a/sdc-workflow-designer-ui/src/app/components/property/properties.component.ts b/sdc-workflow-designer-ui/src/app/components/property/properties.component.ts index c49b4661..56db6583 100644 --- a/sdc-workflow-designer-ui/src/app/components/property/properties.component.ts +++ b/sdc-workflow-designer-ui/src/app/components/property/properties.component.ts @@ -12,6 +12,7 @@ import { Component, OnInit } from '@angular/core'; import { TreeNode } from 'primeng/primeng'; +import { TranslateService } from '@ngx-translate/core'; import { PlanTreeviewItem } from '../../model/plan-treeview-item'; import { ValueSource } from '../../model/value-source.enum'; @@ -21,6 +22,7 @@ import { WorkflowNode } from '../../model/workflow/workflow-node'; import { BroadcastService } from '../../services/broadcast.service'; import { JsPlumbService } from '../../services/jsplumb.service'; import { ModelService } from '../../services/model.service'; +import { NoticeService } from '../../services/notice.service'; /** * property component presents information of a workflow node. @@ -43,6 +45,8 @@ export class PropertiesComponent implements OnInit { constructor(private broadcastService: BroadcastService, private modelService: ModelService, + private translate: TranslateService, + private noticeService: NoticeService, private jsPlumbService: JsPlumbService) { } @@ -59,7 +63,9 @@ export class PropertiesComponent implements OnInit { this.show = true; } catch (error) { this.show = false; - console.log(error); + this.translate.get('WORKFLOW.MSG.SWAGGER_NOT_EXISTS').subscribe((res: string) => { + this.noticeService.error(res); + }); } } else { this.show = false; diff --git a/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task.component.html b/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task.component.html index 99b8a0f4..089d242d 100644 --- a/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task.component.html +++ b/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task.component.html @@ -13,7 +13,7 @@ -->
- +
@@ -31,7 +31,7 @@
- +
+
- +
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 index 9e55ed49..1dd3b7a6 100644 --- 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 @@ -19,4 +19,6 @@ import { ScriptTask } from "../../../model/workflow/script-task"; }) export class ScriptTaskComponent { @Input() public node: ScriptTask; + + public scriptOperations = ['JavaScript']; } diff --git a/sdc-workflow-designer-ui/src/app/components/property/start-event-parameters/start-event-parameters.component.html b/sdc-workflow-designer-ui/src/app/components/property/start-event-parameters/start-event-parameters.component.html deleted file mode 100644 index d6aaafd8..00000000 --- a/sdc-workflow-designer-ui/src/app/components/property/start-event-parameters/start-event-parameters.component.html +++ /dev/null @@ -1,25 +0,0 @@ - - -
-
-
- -
-
- - \ No newline at end of file diff --git a/sdc-workflow-designer-ui/src/app/components/property/start-event-parameters/start-event-parameters.component.ts b/sdc-workflow-designer-ui/src/app/components/property/start-event-parameters/start-event-parameters.component.ts deleted file mode 100644 index 65838792..00000000 --- a/sdc-workflow-designer-ui/src/app/components/property/start-event-parameters/start-event-parameters.component.ts +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * 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 { Component, Input, ViewChild } from '@angular/core'; -import { Subscription } from 'rxjs/Subscription'; - -import { ValueSource } from '../../../model/value-source.enum'; -import { Parameter } from '../../../model/workflow/parameter'; -import { StartEvent } from '../../../model/workflow/start-event'; -import { BroadcastService } from '../../../services/broadcast.service'; - -@Component({ - selector: 'b4t-start-event-parameters', - templateUrl: 'start-event-parameters.component.html', -}) -export class StartEventParametersComponent { - @Input() public node: StartEvent; - public sources: ValueSource[] = [ValueSource.String]; - - public create(): void { - this.node.parameters.push(new Parameter('', '', ValueSource[ValueSource.String])); - } - - public delete(index: number): void { - this.node.parameters.splice(index, 1); - } -} -- cgit 1.2.3-korg