2 * Copyright (c) 2017 ZTE Corporation.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * and the Apache License 2.0 which both accompany this distribution,
6 * and are available at http://www.eclipse.org/legal/epl-v10.html
7 * and http://www.apache.org/licenses/LICENSE-2.0
10 * ZTE - initial API and implementation and/or initial documentation
13 import {Component, OnInit} from "@angular/core";
14 import {TranslateService} from "@ngx-translate/core";
15 import {PlanTreeviewItem} from "../../model/plan-treeview-item";
16 import {ValueSource} from "../../model/value-source.enum";
17 import {NodeType} from "../../model/workflow/node-type.enum";
18 import {WorkflowNode} from "../../model/workflow/workflow-node";
19 import {BroadcastService} from "../../services/broadcast.service";
20 import {JsPlumbService} from "../../services/jsplumb.service";
21 import {ModelService} from "../../services/model.service";
22 import {NoticeService} from "../../services/notice.service";
25 * property component presents information of a workflow node.
26 * the presented information can be edit in this component.
27 * it may load information dynamically. the content may be different for different node type.
30 selector: 'wfm-properties',
31 styleUrls: ['./properties.component.css'],
32 templateUrl: 'properties.component.html',
34 export class PropertiesComponent implements OnInit {
35 public node: WorkflowNode;
36 public planTreeviewItems: PlanTreeviewItem[];
37 public nodeType = NodeType;
38 // public nodeTypes: string[] = WorkflowNodeType;
40 public titleEditing = false;
41 public valueSource = [ValueSource.string];
43 constructor(private broadcastService: BroadcastService,
44 private modelService: ModelService,
45 private translate: TranslateService,
46 private noticeService: NoticeService,
47 private jsPlumbService: JsPlumbService) {
52 this.broadcastService.showProperty$.subscribe(element => {
53 if (element && this.modelService.isNode(element)) {
54 this.node = element as WorkflowNode;
55 // temporarily, if config info not exists then close the property panel
56 // TODOS: 1) save config info in case config info no exists on a different environment.
57 // 2) display property panel even if config info not exists for it may be adjust.
59 this.planTreeviewItems = this.modelService.getPlanParameters(this.node.id);
63 this.translate.get('WORKFLOW.MSG.SWAGGER_NOT_EXISTS').subscribe((res: string) => {
64 this.noticeService.error(res);
75 const parentId = this.jsPlumbService.getParentNodeId(this.node.id);
76 this.jsPlumbService.remove(this.node);
77 this.modelService.deleteNode(parentId, this.node.id);