2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 import * as _ from "lodash";
22 import {Component, ComponentRef} from '@angular/core';
23 import {ForwardingPath} from "app/models/forwarding-path";
24 import {ServiceServiceNg2} from "app/ng2/services/component-services/service.service";
25 import {ModalService} from "app/ng2/services/modal.service";
26 import {ModalComponent} from "app/ng2/components/ui/modal/modal.component";
29 selector: 'service-paths-list',
30 templateUrl: './service-paths-list.component.html',
31 styleUrls:['service-paths-list.component.less'],
32 providers: [ServiceServiceNg2, ModalService]
34 export default class ServicePathsListComponent {
35 modalInstance: ComponentRef<ModalComponent>;
36 headers: Array<string> = [];
37 paths: Array<ForwardingPath> = [];
39 onAddServicePath: Function;
40 onEditServicePath: Function;
43 constructor(private serviceService:ServiceServiceNg2) {
44 this.headers = ['Flow Name','Actions'];
48 _.forEach(this.input.service.forwardingPaths, (path: ForwardingPath)=> {
49 this.paths[this.paths.length] = path;
51 this.paths.sort((a:ForwardingPath, b:ForwardingPath)=> {
52 return a.name.localeCompare(b.name);
54 this.onAddServicePath = this.input.onCreateServicePath;
55 this.onEditServicePath = this.input.onEditServicePath;
56 this.isViewOnly = this.input.isViewOnly;
59 deletePath = (id:string):void => {
60 this.serviceService.deleteServicePath(this.input.service, id).subscribe((res:any) => {
61 delete this.input.service.forwardingPaths[id];
62 this.paths = this.paths.filter(function(path){
63 return path.uniqueId !== id;