43120e85edd2ca255216e0c5912072b5c3f82363
[sdc/sdc-workflow-designer.git] /
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 { Component, EventEmitter, Input, Output } from '@angular/core';
14 import { ModalDirective } from 'ngx-bootstrap/modal';
15
16 import { Swagger } from '../../../../model/swagger';
17 import { RestConfig } from '../../../../model/rest-config';
18 import { RestService } from '../../../../services/rest.service';
19
20 /**
21  * toolbar component contains some basic operations(save) and all of the supported workflow nodes.
22  * The supported nodes can be dragged to container component. which will add a new node to the workflow.
23  */
24 @Component({
25     selector: 'b4t-rest-config-list',
26     templateUrl: 'rest-config-list.component.html',
27 })
28 export class RestConfigListComponent {
29     @Output() configSelected = new EventEmitter<RestConfig>();
30
31     constructor(public restService: RestService) {
32     }
33
34     public onConfigSelected(restConfig: RestConfig) {
35         this.configSelected.emit(restConfig);
36     }
37
38     public addRestConfig() {
39
40         const restConfig = this.restService.newRestConfig();
41         this.restService.addRestConfig(restConfig);
42
43         this.onConfigSelected(restConfig);
44     }
45
46     public deleteRestConfig(index: number) {
47         // this.restService.getRestConfigs().splice(index, 1);
48
49         // let restConfig;
50         // if (this.restService.getRestConfigs().length > 0) {
51         //     if (this.restService.getRestConfigs()[index]) {
52         //         restConfig = this.restService.getRestConfigs()[index];
53         //     } else {
54         //         restConfig = this.restService.getRestConfigs()[index - 1];
55         //     }
56         // }
57         // this.onConfigSelected(restConfig);
58     }
59 }