added ansible server functionality
[appc/cdt.git] / src / app / shared / pipes / vm-filtering.pipe.ts
1 /*
2 ============LICENSE_START==========================================
3 ===================================================================
4 Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
5 ===================================================================
6
7 Unless otherwise specified, all software contained herein is licensed
8 under the Apache License, Version 2.0 (the License);
9 you may not use this software except in compliance with the License.
10 You may obtain a copy of the License at
11
12     http://www.apache.org/licenses/LICENSE-2.0
13
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
19
20 ============LICENSE_END============================================ */
21 import { Pipe, PipeTransform } from '@angular/core';
22
23 @Pipe({ name: 'vmFiltering', pure: false })
24 export class VmFilteringPipe implements PipeTransform {
25
26     transform(value: any, action: any, templateId, newVnfc): any {
27         let filterValue
28         if(action == 'ConfigScaleOut'){
29             filterValue= templateId
30         } else if(action == 'Configure' || action == 'ConfigModify'){
31             filterValue= newVnfc
32         }
33         if (action == 'ConfigScaleOut') {
34             let x = value.filter(obj => {
35                 //return value
36                 return obj['template-id'] == filterValue;
37             });
38
39
40             return x;
41         } else if( action == 'Configure' || action == 'ConfigModify'){
42             let x = value.filter(obj => {
43                 //return value
44                 return ( obj['vnfcType-id'] == filterValue || obj['vnfcType-id'] == undefined);
45             });
46
47
48             return x;
49         } else {
50             return value;
51
52         }
53     }
54
55 }