support set parameter for workflow
[sdc/sdc-workflow-designer.git] / sdc-workflow-designer-ui / src / app / components / property / properties.component.ts
1 /**
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
8  *
9  * Contributors:
10  *     ZTE - initial API and implementation and/or initial documentation
11  */
12
13 import { AfterViewInit, Component } from '@angular/core';
14
15 import { WorkflowNode } from '../../model/workflow/workflow-node';
16 import { BroadcastService } from '../../services/broadcast.service';
17 import { JsPlumbService } from '../../services/jsplumb.service';
18 import { WorkflowService } from '../../services/workflow.service';
19
20 /**
21  * property component presents information of a workflow node.
22  * the presented information can be edit in this component.
23  * it may load information dynamically. the content may be different for different node type.
24  */
25 @Component({
26     selector: 'b4t-properties',
27     styleUrls: ['./properties.component.css'],
28     templateUrl: 'properties.component.html',
29 })
30 export class PropertiesComponent implements AfterViewInit {
31     public node: WorkflowNode;
32     public show = false;
33     public titleEditing = false;
34
35     constructor(private broadcastService: BroadcastService,
36                 private jsPlumnService: JsPlumbService,
37                 private workflowService: WorkflowService) {
38
39     }
40
41     public ngAfterViewInit() {
42         this.broadcastService.showProperty$.subscribe(show => this.show = show);
43         this.broadcastService.nodeProperty$.subscribe(node => this.node = node);
44     }
45
46     public nodeNameChanged() {
47         this.titleEditing = !this.titleEditing;
48         this.jsPlumnService.jsplumbInstance.repaintEverything();
49     }
50
51     public deleteNode() {
52         this.show = false;
53
54         this.jsPlumnService.remove(this.node.id);
55         this.workflowService.deleteNode(this.node.id);
56     }
57 }