support set parameter for workflow
[sdc/sdc-workflow-designer.git] / sdc-workflow-designer-ui / src / app / components / canvas / canvas.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 { BroadcastService } from '../../services/broadcast.service';
16 import { JsPlumbService } from '../../services/jsplumb.service';
17 import { ActivatedRoute } from "@angular/router";
18 import { DataAccessService } from "../../services/data-access/data-access.service";
19 import { WorkflowService } from "../../services/workflow.service";
20 import { Workflow } from "../../model/workflow/workflow";
21
22 /**
23  * main canvas, it contains two parts: canvas and node property component
24  * bpmn task nodes can be dropped into this canvas, and then the workflow can be edit
25  */
26 @Component({
27     selector: 'b4t-canvas',
28     styleUrls: ['./canvas.component.css'],
29     templateUrl: 'canvas.component.html',
30 })
31 export class CanvasComponent implements AfterViewInit {
32
33     constructor(private broadcastService: BroadcastService,
34         private dataAccessService: DataAccessService,
35         private jsPlumbService: JsPlumbService,
36         private route: ActivatedRoute,
37         private workflowService: WorkflowService) {
38     }
39
40     ngOnInit(): void {
41         this.route.queryParams.subscribe(params => {
42             if (params.id) {
43                 this.dataAccessService.catalogService.loadWorkflow(params.id).subscribe(workflow => {
44                     this.workflowService.workflow = workflow;
45                 });
46             }
47         });
48     }
49
50     public ngAfterViewInit() {
51         this.jsPlumbService.buttonDroppable();
52     }
53
54     public canvasClick() {
55         this.broadcastService.broadcast(this.broadcastService.showProperty, false);
56     }
57
58
59     public getWorkflow(): Workflow {
60         return this.workflowService.workflow;
61     }
62 }