From 6f900cc45d7dd7f97430812b86b5c1d1693c8ae3 Mon Sep 17 00:00:00 2001 From: Ittay Stern Date: Wed, 29 Aug 2018 17:01:32 +0300 Subject: merge from ecomp a88f0072 - Modern UI Issue-ID: VID-378 Change-Id: Ibcb23dd27f550cf32ce2fe0239f0f496ae014ff6 Signed-off-by: Ittay Stern --- .../capitalize/capitalize-and-format.pipe.spec.ts | 20 +++++--- .../pipes/capitalize/capitalize-and-format.pipe.ts | 2 +- .../src/app/shared/pipes/data-filter.pipe.ts | 29 ----------- .../pipes/dataFilter/data-filter.pipe.spec.ts | 52 +++++++++++++++++++ .../shared/pipes/dataFilter/data-filter.pipe.ts | 47 +++++++++++++++++ .../dynamic-input-label.pipe.spec.ts | 36 +++++++------ .../dynamicInputLabel/dynamic-input-label.pipe.ts | 2 +- .../src/app/shared/pipes/highlight-filter.pipe.ts | 10 ---- .../pipes/highlight/highlight-filter.pipe.spec.ts | 29 +++++++++++ .../pipes/highlight/highlight-filter.pipe.ts | 12 +++++ .../pipes/objectToArray/objectToArray.pipe.spec.ts | 35 +++++++++++++ .../pipes/objectToArray/objectToArray.pipe.ts | 8 +++ .../app/shared/pipes/order/orderBy.pipe.spec.ts | 60 ++++++++++++++++++++++ .../src/app/shared/pipes/order/orderBy.pipe.ts | 35 +++++++++++++ .../src/app/shared/pipes/safe/safe.pipe.spec.ts | 60 ++++++++++++++++++++++ .../src/app/shared/pipes/safe/safe.pipe.ts | 22 ++++++++ .../pipes/serviceInfo/serviceInfo.pipe.spec.ts | 21 +++++--- .../shared/pipes/serviceInfo/serviceInfo.pipe.ts | 4 +- 18 files changed, 413 insertions(+), 71 deletions(-) delete mode 100644 vid-webpack-master/src/app/shared/pipes/data-filter.pipe.ts create mode 100644 vid-webpack-master/src/app/shared/pipes/dataFilter/data-filter.pipe.spec.ts create mode 100644 vid-webpack-master/src/app/shared/pipes/dataFilter/data-filter.pipe.ts delete mode 100644 vid-webpack-master/src/app/shared/pipes/highlight-filter.pipe.ts create mode 100644 vid-webpack-master/src/app/shared/pipes/highlight/highlight-filter.pipe.spec.ts create mode 100644 vid-webpack-master/src/app/shared/pipes/highlight/highlight-filter.pipe.ts create mode 100644 vid-webpack-master/src/app/shared/pipes/objectToArray/objectToArray.pipe.spec.ts create mode 100644 vid-webpack-master/src/app/shared/pipes/objectToArray/objectToArray.pipe.ts create mode 100644 vid-webpack-master/src/app/shared/pipes/order/orderBy.pipe.spec.ts create mode 100644 vid-webpack-master/src/app/shared/pipes/order/orderBy.pipe.ts create mode 100644 vid-webpack-master/src/app/shared/pipes/safe/safe.pipe.spec.ts create mode 100644 vid-webpack-master/src/app/shared/pipes/safe/safe.pipe.ts (limited to 'vid-webpack-master/src/app/shared/pipes') diff --git a/vid-webpack-master/src/app/shared/pipes/capitalize/capitalize-and-format.pipe.spec.ts b/vid-webpack-master/src/app/shared/pipes/capitalize/capitalize-and-format.pipe.spec.ts index 84d2ff4b6..f0bcbb0f1 100644 --- a/vid-webpack-master/src/app/shared/pipes/capitalize/capitalize-and-format.pipe.spec.ts +++ b/vid-webpack-master/src/app/shared/pipes/capitalize/capitalize-and-format.pipe.spec.ts @@ -1,25 +1,33 @@ - import {CapitalizeAndFormatPipe} from "./capitalize-and-format.pipe"; +import {TestBed} from "@angular/core/testing"; describe('Capitalize And Format Pipe', () => { let capitalizeAndFormatPipe: CapitalizeAndFormatPipe; - beforeEach(() => { + beforeAll(done => (async () => { + TestBed.configureTestingModule({}); + await TestBed.compileComponents(); capitalizeAndFormatPipe = new CapitalizeAndFormatPipe(); - }); + })().then(done).catch(done.fail)); + - it('Capitalize And Format Pipe should be defined', () => { + test('Capitalize And Format Pipe should be defined', () => { expect(capitalizeAndFormatPipe).toBeDefined(); }); - it('Capitalize And Format Pipe : (UPPERCASE)', ()=> { + test('Capitalize And Format Pipe : (UPPERCASE)', ()=> { let result: string = capitalizeAndFormatPipe.transform('PENDING'); expect(result).toEqual('Pending'); }); - it('Capitalize And Format Pipe (UPPERCASE) and Underscore should replace by -', ()=> { + test('Capitalize And Format Pipe (UPPERCASE) and Underscore should replace by -', ()=> { let result: string = capitalizeAndFormatPipe.transform('IN_PROGRESS'); expect(result).toEqual('In-progress'); }); + test('Capitalize And Format Pipe (COMPLETED_WITH_ERRORS) and All Underscores should replace by -', ()=> { + let result: string = capitalizeAndFormatPipe.transform('COMPLETED_WITH_ERRORS'); + expect('Completed-with-errors').toEqual(result); + }); + }); diff --git a/vid-webpack-master/src/app/shared/pipes/capitalize/capitalize-and-format.pipe.ts b/vid-webpack-master/src/app/shared/pipes/capitalize/capitalize-and-format.pipe.ts index e3ec9ae9a..12b1eb912 100644 --- a/vid-webpack-master/src/app/shared/pipes/capitalize/capitalize-and-format.pipe.ts +++ b/vid-webpack-master/src/app/shared/pipes/capitalize/capitalize-and-format.pipe.ts @@ -4,7 +4,7 @@ import {PipeTransform, Pipe} from '@angular/core'; export class CapitalizeAndFormatPipe implements PipeTransform { transform(text: string): string { if (text) { - text = text.toLowerCase().replace('_', '-'); + text = text.toLowerCase().replace(/_/g, '-'); return text.charAt(0).toUpperCase() + text.slice(1); } return text; diff --git a/vid-webpack-master/src/app/shared/pipes/data-filter.pipe.ts b/vid-webpack-master/src/app/shared/pipes/data-filter.pipe.ts deleted file mode 100644 index 1ff836762..000000000 --- a/vid-webpack-master/src/app/shared/pipes/data-filter.pipe.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Created by cp2122 on 1/4/2018. - */ -import { Pipe, PipeTransform } from '@angular/core'; - -@Pipe({ - name: 'dataFilter' -}) -export class DataFilterPipe implements PipeTransform { - keys = []; - transform(items: any, args: string): any { - if (items != null && items.length > 0) { - let ans = []; - - if (this.keys.length === 0) { - this.keys = Object.keys(items[0]); - } - for (let i of items) { - for (let k of this.keys) { - if (i[k] !== null && i[k].toString().match('^.*' + args + '.*$')) { - ans.push(i); - break; - } - } - } - return ans; - } - } -} diff --git a/vid-webpack-master/src/app/shared/pipes/dataFilter/data-filter.pipe.spec.ts b/vid-webpack-master/src/app/shared/pipes/dataFilter/data-filter.pipe.spec.ts new file mode 100644 index 000000000..378ba259d --- /dev/null +++ b/vid-webpack-master/src/app/shared/pipes/dataFilter/data-filter.pipe.spec.ts @@ -0,0 +1,52 @@ +import {TestBed} from "@angular/core/testing"; +import {DataFilterPipe} from "./data-filter.pipe"; + +describe('Data filter pipe', () => { + + let dataFilterPipe: DataFilterPipe; + + beforeAll(done => (async () => { + TestBed.configureTestingModule({}); + await TestBed.compileComponents(); + + dataFilterPipe = new DataFilterPipe(); + + })().then(done).catch(done.fail)); + const items= [{'id':1, 'name': 'aaa'}, + {'id':12, 'name': 'bbb', 'children':{'first': 155, 'second': 2, 'third': 3}}, + {'id':3, 'name': 'ccc', 'children':{'first': 1, 'second': 2, 'third': 3}}, + {'id':4, 'name': 'aad', 'children':{'first': 1, 'second': 2, 'third': 3}}]; + const keys : string[][] = [["id"],["name"],["children", "first"]]; + + + test('should return items contains substring, keys not provided', () => { + const expected = [{'id':1, 'name': 'aaa'}, {'id':4, 'name': 'aad', 'children':{'first': 1, 'second': 2, 'third': 3}}]; + let res:any[] = dataFilterPipe.transform(items,'aa'); + expect(res).toEqual(expected); + }); + + + test('should return no result, keys not provided', () => { + const expected = []; + let res:any[] = dataFilterPipe.transform(items,'5'); + expect(res).toEqual(expected); + }); + + test('should return no result, deep keys provided', () => { + const expected = []; + let res:any[] = dataFilterPipe.transform(items,'6', keys); + expect(res).toEqual(expected); + }); + + test('should return expected result, deep keys provided', () => { + const expected = [{'id':12, 'name': 'bbb', 'children':{'first': 155, 'second': 2, 'third': 3}}]; + let res:any[] = dataFilterPipe.transform(items,'155', keys); + expect(res).toEqual(expected); + }); + + test('should return expected result, case insensitive', () => { + const expected = [{'id':12, 'name': 'bbb', 'children':{'first': 155, 'second': 2, 'third': 3}}]; + let res:any[] = dataFilterPipe.transform(items,'BBB', keys); + expect(res).toEqual(expected); + }); +}); diff --git a/vid-webpack-master/src/app/shared/pipes/dataFilter/data-filter.pipe.ts b/vid-webpack-master/src/app/shared/pipes/dataFilter/data-filter.pipe.ts new file mode 100644 index 000000000..4b4f1a5bc --- /dev/null +++ b/vid-webpack-master/src/app/shared/pipes/dataFilter/data-filter.pipe.ts @@ -0,0 +1,47 @@ +/** + * Created by cp2122 on 1/4/2018. + */ +import { Pipe, PipeTransform } from '@angular/core'; +import * as _ from 'lodash'; + +@Pipe({ + name: 'dataFilter' +}) +export class DataFilterPipe implements PipeTransform { + + transform(items: any, searchStr: string, keys?: string[][]): any { + if (items != null && items.length > 0 && !_.isNil(searchStr)) { + let ans = []; + + if (_.isNil(keys) || keys.length === 0) { + keys = Object.keys(items[0]).map((key)=> new Array(key) ); + } + for (const item of items) { + for(const key of keys) { + + let val: string = DataFilterPipe.getDeepObjectValueByKeys(item, key); + if (!_.isNil(val) && val.toLowerCase().includes(searchStr.toLowerCase())) { + ans.push(item); + break; + } + } + } + return ans; + } + } + /********************************************************************** + get value from obj data by array of keys. + @keys: all table column and keys + @rowData : row data + ************************************************************************/ + static getDeepObjectValueByKeys(rowData: any , keys: string[]) : string { + let obj = rowData[keys[0]]; + if(_.isNil(obj)) { + return obj; + } + for(let i = 1; i < keys.length ; i++){ + obj = obj[keys[i]]; + } + return obj.toString(); + } +} diff --git a/vid-webpack-master/src/app/shared/pipes/dynamicInputLabel/dynamic-input-label.pipe.spec.ts b/vid-webpack-master/src/app/shared/pipes/dynamicInputLabel/dynamic-input-label.pipe.spec.ts index 22b619290..9938a1c57 100644 --- a/vid-webpack-master/src/app/shared/pipes/dynamicInputLabel/dynamic-input-label.pipe.spec.ts +++ b/vid-webpack-master/src/app/shared/pipes/dynamicInputLabel/dynamic-input-label.pipe.spec.ts @@ -1,43 +1,47 @@ import { DynamicInputLabelPipe } from './dynamic-input-label.pipe'; +import {TestBed} from "@angular/core/testing"; describe('Dynamic input label Pipe', () => { - let dynamicInputLabelPipe: DynamicInputLabelPipe; - beforeEach(() => { + let dynamicInputLabelPipe: DynamicInputLabelPipe; + beforeAll(done => (async () => { + TestBed.configureTestingModule({}); + await TestBed.compileComponents(); dynamicInputLabelPipe = new DynamicInputLabelPipe(); - }); - it('Dynamic input label Pipe should be defined', () => { + })().then(done).catch(done.fail)); + + test('Dynamic input label Pipe should be defined', () => { expect(dynamicInputLabelPipe).toBeDefined(); }); - it('Dynamic input label Pipe : Empty string should return empty string', ()=> { + test('Dynamic input label Pipe : Empty string should return empty string', ()=> { let result: string = dynamicInputLabelPipe.transform(''); - expect(result).toEqual(':*'); + expect(result).toEqual(':'); }); - it('Dynamic input label Pipe: vnf should be VNF (UPPERCASE)', ()=> { + test('Dynamic input label Pipe: vnf should be VNF (UPPERCASE)', ()=> { let result: string = dynamicInputLabelPipe.transform('vnf'); - expect(result).toEqual('VNF:*'); + expect(result).toEqual('VNF:'); }); - it('Dynamic input label Pipe : nf should be NF (UPPERCASE)\'', ()=> { + test('Dynamic input label Pipe : nf should be NF (UPPERCASE)\'', ()=> { let result: string = dynamicInputLabelPipe.transform('nf'); - expect(result).toEqual('NF:*'); + expect(result).toEqual('NF:'); }); - it('Dynamic input label Pipe : Underscore should replace by empty character', ()=> { + test('Dynamic input label Pipe : Underscore should replace by empty character', ()=> { let result: string = dynamicInputLabelPipe.transform('nf_Test'); - expect(result).toEqual('NF test:*'); + expect(result).toEqual('NF test:'); }); - it('Dynamic input label Pipe : Complex string', ()=> { + test('Dynamic input label Pipe : Complex string', ()=> { let result: string = dynamicInputLabelPipe.transform('nf_Test_vnf_nf'); - expect(result).toEqual('NF test VNF NF:*'); + expect(result).toEqual('NF test VNF NF:'); }); - it('Dynamic input label Pipe : First letter should be uppercase', ()=> { + test('Dynamic input label Pipe : First letter should be uppercase', ()=> { let result: string = dynamicInputLabelPipe.transform('nfr'); - expect(result).toEqual('Nfr:*'); + expect(result).toEqual('Nfr:'); }); }); diff --git a/vid-webpack-master/src/app/shared/pipes/dynamicInputLabel/dynamic-input-label.pipe.ts b/vid-webpack-master/src/app/shared/pipes/dynamicInputLabel/dynamic-input-label.pipe.ts index bec87b46d..f0896befb 100644 --- a/vid-webpack-master/src/app/shared/pipes/dynamicInputLabel/dynamic-input-label.pipe.ts +++ b/vid-webpack-master/src/app/shared/pipes/dynamicInputLabel/dynamic-input-label.pipe.ts @@ -7,6 +7,6 @@ export class DynamicInputLabelPipe implements PipeTransform { let uppercase_vnf = split_label.replace(/\bvnf\b/ig, 'VNF'); let uppercase_nf = uppercase_vnf.replace(/\bnf\b/ig, 'NF'); let capitalize_sentence = uppercase_nf.charAt(0).toUpperCase() + uppercase_nf.slice(1); - return capitalize_sentence + ':*'; + return capitalize_sentence + ':'; } } diff --git a/vid-webpack-master/src/app/shared/pipes/highlight-filter.pipe.ts b/vid-webpack-master/src/app/shared/pipes/highlight-filter.pipe.ts deleted file mode 100644 index 93aecbf69..000000000 --- a/vid-webpack-master/src/app/shared/pipes/highlight-filter.pipe.ts +++ /dev/null @@ -1,10 +0,0 @@ -import {PipeTransform, Pipe} from '@angular/core'; - -@Pipe({ name: 'highlight' }) -export class HighlightPipe implements PipeTransform { - transform(text: string, search: string): string { - let pattern = search.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); - let regex = new RegExp(pattern, 'gi'); - return search ? text.replace(regex, (match) => `${match}`) : text; - } -} diff --git a/vid-webpack-master/src/app/shared/pipes/highlight/highlight-filter.pipe.spec.ts b/vid-webpack-master/src/app/shared/pipes/highlight/highlight-filter.pipe.spec.ts new file mode 100644 index 000000000..6c2fc42d7 --- /dev/null +++ b/vid-webpack-master/src/app/shared/pipes/highlight/highlight-filter.pipe.spec.ts @@ -0,0 +1,29 @@ + +import {HighlightPipe} from "./highlight-filter.pipe"; +import {TestBed} from "@angular/core/testing"; + +describe('Highlight Pipe', () => { + let highlightPipe: HighlightPipe; + + beforeAll(done => (async () => { + TestBed.configureTestingModule({}); + await TestBed.compileComponents(); + + highlightPipe = new HighlightPipe(); + + })().then(done).catch(done.fail)); + + test('Highlight Pipe should be defined', () => { + expect(highlightPipe).toBeDefined(); + }); + + test('Highlight Pipe should return "HTML" with highlight class if match exist', () => { + let result : string = highlightPipe.transform('Hello World', 'Wor'); + expect(result).toEqual('Hello World'); + }); + + test('Highlight Pipe should not return "HTML" with highlight class if no match exist', () => { + let result : string = highlightPipe.transform('Hello World', 'ABC'); + expect(result).toEqual('Hello World'); + }); +}); diff --git a/vid-webpack-master/src/app/shared/pipes/highlight/highlight-filter.pipe.ts b/vid-webpack-master/src/app/shared/pipes/highlight/highlight-filter.pipe.ts new file mode 100644 index 000000000..b25458d6d --- /dev/null +++ b/vid-webpack-master/src/app/shared/pipes/highlight/highlight-filter.pipe.ts @@ -0,0 +1,12 @@ +import {PipeTransform, Pipe} from '@angular/core'; +import * as _ from 'lodash'; + +@Pipe({ name: 'highlight' }) +export class HighlightPipe implements PipeTransform { + transform(text: string, search: string): string { + if(_.isNil(text)) return text; + let pattern = search.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); + let regex = new RegExp(pattern, 'gi'); + return search ? text.replace(regex, (match) => `${match}`) : text; + } +} diff --git a/vid-webpack-master/src/app/shared/pipes/objectToArray/objectToArray.pipe.spec.ts b/vid-webpack-master/src/app/shared/pipes/objectToArray/objectToArray.pipe.spec.ts new file mode 100644 index 000000000..093e17341 --- /dev/null +++ b/vid-webpack-master/src/app/shared/pipes/objectToArray/objectToArray.pipe.spec.ts @@ -0,0 +1,35 @@ +import {TestBed} from "@angular/core/testing"; +import {ObjectToArrayPipe} from "./objectToArray.pipe"; + + +describe('Object To Array Pipe', () => { + let pipe: ObjectToArrayPipe; + + beforeAll(done => (async () => { + TestBed.configureTestingModule({ + + }); + await TestBed.compileComponents(); + pipe = new ObjectToArrayPipe(); + + })().then(done).catch(done.fail)); + + + test('should flat object to array', () => { + let object = { + "a" : { + "name" : "A" + }, + "b" : { + "name" : "B" + }, + "c" : { + "name" : "C" + } + }; + let result = pipe.transform(object); + expect(result[0]).toEqual({"name" : "A"}); + expect(result[1]).toEqual({"name" : "B"}); + expect(result[2]).toEqual({"name" : "C"}); + }); +}); diff --git a/vid-webpack-master/src/app/shared/pipes/objectToArray/objectToArray.pipe.ts b/vid-webpack-master/src/app/shared/pipes/objectToArray/objectToArray.pipe.ts new file mode 100644 index 000000000..fa201d981 --- /dev/null +++ b/vid-webpack-master/src/app/shared/pipes/objectToArray/objectToArray.pipe.ts @@ -0,0 +1,8 @@ +import { PipeTransform, Pipe } from '@angular/core'; +import * as _ from 'lodash'; +@Pipe({name: 'objecttoarray'}) +export class ObjectToArrayPipe implements PipeTransform { + transform(obj) : any { + return _.values(obj); + } +} diff --git a/vid-webpack-master/src/app/shared/pipes/order/orderBy.pipe.spec.ts b/vid-webpack-master/src/app/shared/pipes/order/orderBy.pipe.spec.ts new file mode 100644 index 000000000..e6a1d310c --- /dev/null +++ b/vid-webpack-master/src/app/shared/pipes/order/orderBy.pipe.spec.ts @@ -0,0 +1,60 @@ +import {OrderByPipe} from "./orderBy.pipe"; +import {TestBed} from "@angular/core/testing"; + + +describe('Sort Pipe', () => { + let pipe: OrderByPipe; + + beforeAll(done => (async () => { + TestBed.configureTestingModule({ + + }); + await TestBed.compileComponents(); + pipe = new OrderByPipe(); + + })().then(done).catch(done.fail)); + + + test('Sort should order the array with nested objects', () => { + let list = [ + { + id: 1, + name: 'b' + }, + { + id: 3, + name: 'a' + }, + { + id: 2, + name: 'd' + } + ]; + + let result = pipe.transform(list, {property : 'name'}); + expect(result.length).toEqual(3); + expect(result).toEqual([ + { + 'id': 3, + 'name': 'a' + }, + { + 'id': 1, + 'name': 'b' + }, + { + 'id': 2, + 'name': 'd' + }]) + + }); + + test('Sort should order the array', () => { + let list = ['b', 'd', 'a']; + + let result = pipe.transform(list); + expect(result.length).toEqual(3); + expect(result).toEqual(['a', 'b', 'd']); + + }); +}); diff --git a/vid-webpack-master/src/app/shared/pipes/order/orderBy.pipe.ts b/vid-webpack-master/src/app/shared/pipes/order/orderBy.pipe.ts new file mode 100644 index 000000000..a3b82329b --- /dev/null +++ b/vid-webpack-master/src/app/shared/pipes/order/orderBy.pipe.ts @@ -0,0 +1,35 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import * as _ from 'lodash'; +@Pipe({ name: 'orderBy' }) +export class OrderByPipe implements PipeTransform { + + transform(records: any[], args: any = {}): any { + args.direction = !_.isNil(args.direction) ? args.direction : 1; + + if(!_.isNil(records)){ + return records.sort(function(a, b){ + if(args.property){ + if(a[args.property] < b[args.property]){ + return -1 * args.direction; + } + else if( a[args.property] > b[args.property]){ + return 1 * args.direction; + } + else{ + return 0; + } + }else { + if(a < b){ + return -1 * args.direction; + } + else if( a > b){ + return 1 * args.direction; + } + else{ + return 0; + } + } + }); + } + }; +} diff --git a/vid-webpack-master/src/app/shared/pipes/safe/safe.pipe.spec.ts b/vid-webpack-master/src/app/shared/pipes/safe/safe.pipe.spec.ts new file mode 100644 index 000000000..f0471731e --- /dev/null +++ b/vid-webpack-master/src/app/shared/pipes/safe/safe.pipe.spec.ts @@ -0,0 +1,60 @@ +import {SafePipe} from "./safe.pipe"; +import {DomSanitizer} from "@angular/platform-browser"; +import {getTestBed, TestBed} from "@angular/core/testing"; + + +describe('Safe pipe', () => { + + let injector; + let pipe: SafePipe; + let sanitizer: DomSanitizer; + + beforeAll(done => (async () => { + TestBed.configureTestingModule({ + providers: [SafePipe] + }); + await TestBed.compileComponents(); + + injector = getTestBed(); + sanitizer = injector.get(DomSanitizer); + pipe = injector.get(SafePipe); + + })().then(done).catch(done.fail)); + + test('safe pipe should return Safe object', () => { + let options = [ + { + value: 'value', + type: 'html', + func: 'bypassSecurityTrustHtml' + }, + { + value: 'value', + type: 'style', + func: 'bypassSecurityTrustStyle' + }, + { + value: 'value', + type: 'script', + func: 'bypassSecurityTrustScript' + }, + { + value: 'value', + type: 'url', + func: 'bypassSecurityTrustUrl' + }, + { + value: 'value', + type: 'resourceUrl', + func: 'bypassSecurityTrustResourceUrl' + } + ]; + + for (let option of options) { + jest.spyOn(sanitizer, option.func); + pipe.transform(option.value, option.type); + expect(sanitizer[option.func]).toHaveBeenCalledWith(option.value); + } + }); + +}); diff --git a/vid-webpack-master/src/app/shared/pipes/safe/safe.pipe.ts b/vid-webpack-master/src/app/shared/pipes/safe/safe.pipe.ts new file mode 100644 index 000000000..cff5b61a9 --- /dev/null +++ b/vid-webpack-master/src/app/shared/pipes/safe/safe.pipe.ts @@ -0,0 +1,22 @@ +// @ts-ignore +import {DomSanitizer, SafeHtml, SafeResourceUrl, SafeScript, SafeStyle, SafeUrl} from "@angular/platform-browser"; +import {Pipe, PipeTransform} from "@angular/core"; + + +@Pipe({ + name: 'safe' +}) +export class SafePipe implements PipeTransform { + + constructor(protected sanitizer: DomSanitizer) {} + + public transform(value: any, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl { + switch (type) { + case 'html': return this.sanitizer.bypassSecurityTrustHtml(value); + case 'style': return this.sanitizer.bypassSecurityTrustStyle(value); + case 'script': return this.sanitizer.bypassSecurityTrustScript(value); + case 'url': return this.sanitizer.bypassSecurityTrustUrl(value); + case 'resourceUrl': return this.sanitizer.bypassSecurityTrustResourceUrl(value); + } + } +} diff --git a/vid-webpack-master/src/app/shared/pipes/serviceInfo/serviceInfo.pipe.spec.ts b/vid-webpack-master/src/app/shared/pipes/serviceInfo/serviceInfo.pipe.spec.ts index 984e3378c..670f2f224 100644 --- a/vid-webpack-master/src/app/shared/pipes/serviceInfo/serviceInfo.pipe.spec.ts +++ b/vid-webpack-master/src/app/shared/pipes/serviceInfo/serviceInfo.pipe.spec.ts @@ -1,14 +1,23 @@ import {ServiceInfoPipe} from "./serviceInfo.pipe"; +import {TestBed} from "@angular/core/testing"; describe('Service info Pipe', () => { let pipe: ServiceInfoPipe; - beforeEach(() => { + + beforeAll(done => (async () => { + TestBed.configureTestingModule({ + + }); + await TestBed.compileComponents(); pipe = new ServiceInfoPipe(); - }); - it('Service info Pipe should return model name', () => { + + })().then(done).catch(done.fail)); + + + test('Service info Pipe should return model name', () => { let store = { getState : function() { return { @@ -24,7 +33,7 @@ describe('Service info Pipe', () => { - it('Service info Pipe should return null if field name not exist', () => { + test('Service info Pipe should return null if field name not exist', () => { let store = { getState : function() { return { @@ -38,7 +47,7 @@ describe('Service info Pipe', () => { expect(result).toBeNull(); }); - it('Service info Pipe should return null if model not exist', () => { + test('Service info Pipe should return null if model not exist', () => { let store = { getState : function() { return { @@ -53,6 +62,6 @@ describe('Service info Pipe', () => { }); function generateserviceHierarchy(){ - return JSON.parse('{"6e59c5de-f052-46fa-aa7e-2fca9d674c44":{"service":{"uuid":"6e59c5de-f052-46fa-aa7e-2fca9d674c44","invariantUuid":"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0","name":"ComplexService","version":"1.0","toscaModelURL":null,"category":"Mobility","serviceType":"","serviceRole":"","description":"ComplexService","serviceEcompNaming":"true","instantiationType":"Macro","inputs":{}},"vnfs":{"VF_vMee 0":{"uuid":"d6557200-ecf2-4641-8094-5393ae3aae60","invariantUuid":"4160458e-f648-4b30-a176-43881ffffe9e","description":"VSP_vMee","name":"VF_vMee","version":"2.0","customizationUuid":"91415b44-753d-494c-926a-456a9172bbb9","inputs":{},"commands":{},"properties":{"gpb2_Internal2_mac":"00:80:37:0E:02:22","sctp-b-ipv6-egress_src_start_port":"0","sctp-a-ipv6-egress_rule_application":"any","Internal2_allow_transit":"true","sctp-b-IPv6_ethertype":"IPv6","sctp-a-egress_rule_application":"any","sctp-b-ingress_action":"pass","sctp-b-ingress_rule_protocol":"icmp","ncb2_Internal1_mac":"00:80:37:0E:0F:12","sctp-b-ipv6-ingress-src_start_port":"0.0","ncb1_Internal2_mac":"00:80:37:0E:09:12","fsb_volume_size_0":"320.0","sctp-b-egress_src_addresses":"local","sctp-a-ipv6-ingress_ethertype":"IPv4","sctp-a-ipv6-ingress-dst_start_port":"0","sctp-b-ipv6-ingress_rule_application":"any","domain_name":"default-domain","sctp-a-ingress_rule_protocol":"icmp","sctp-b-egress-src_start_port":"0.0","sctp-a-egress_src_addresses":"local","sctp-b-display_name":"epc-sctp-b-ipv4v6-sec-group","sctp-a-egress-src_start_port":"0.0","sctp-a-ingress_ethertype":"IPv4","sctp-b-ipv6-ingress-dst_end_port":"65535","sctp-b-dst_subnet_prefix_v6":"::","nf_naming":"{ecomp_generated_naming=true}","sctp-a-ipv6-ingress_src_subnet_prefix":"0.0.0.0","sctp-b-egress-dst_start_port":"0.0","ncb_flavor_name":"nv.c20r64d1","gpb1_Internal1_mac":"00:80:37:0E:01:22","sctp-b-egress_dst_subnet_prefix_len":"0.0","Internal2_net_cidr":"169.255.0.0","sctp-a-ingress-dst_start_port":"0.0","sctp-a-egress-dst_start_port":"0.0","fsb1_Internal2_mac":"00:80:37:0E:0B:12","sctp-a-egress_ethertype":"IPv4","vlc_st_service_mode":"in-network-nat","sctp-a-ipv6-egress_ethertype":"IPv4","sctp-a-egress-src_end_port":"65535.0","sctp-b-ipv6-egress_rule_application":"any","sctp-b-egress_action":"pass","sctp-a-ingress-src_subnet_prefix_len":"0.0","sctp-b-ipv6-ingress-src_end_port":"65535.0","sctp-b-name":"epc-sctp-b-ipv4v6-sec-group","fsb2_Internal1_mac":"00:80:37:0E:0D:12","sctp-a-ipv6-ingress-src_start_port":"0.0","sctp-b-ipv6-egress_ethertype":"IPv4","Internal1_net_cidr":"169.253.0.0","sctp-a-egress_dst_subnet_prefix":"0.0.0.0","fsb_flavor_name":"nv.c20r64d1","sctp_rule_protocol":"132","sctp-b-ipv6-ingress_src_subnet_prefix_len":"0","sctp-a-ipv6-ingress_rule_application":"any","ecomp_generated_naming":"true","sctp-a-IPv6_ethertype":"IPv6","vlc2_Internal1_mac":"00:80:37:0E:02:12","vlc_st_virtualization_type":"virtual-machine","sctp-b-ingress-dst_start_port":"0.0","sctp-b-ingress-dst_end_port":"65535.0","sctp-a-ipv6-ingress-src_end_port":"65535.0","sctp-a-display_name":"epc-sctp-a-ipv4v6-sec-group","sctp-b-ingress_rule_application":"any","int2_sec_group_name":"int2-sec-group","vlc_flavor_name":"nd.c16r64d1","sctp-b-ipv6-egress_src_addresses":"local","vlc_st_interface_type_int1":"other1","sctp-b-egress-src_end_port":"65535.0","sctp-a-ipv6-egress-dst_start_port":"0","vlc_st_interface_type_int2":"other2","sctp-a-ipv6-egress_rule_protocol":"any","Internal2_shared":"false","sctp-a-ipv6-egress_dst_subnet_prefix_len":"0","Internal2_rpf":"disable","vlc1_Internal1_mac":"00:80:37:0E:01:12","sctp-b-ipv6-egress_src_end_port":"65535","sctp-a-ipv6-egress_src_addresses":"local","sctp-a-ingress-dst_end_port":"65535.0","sctp-a-ipv6-egress_src_end_port":"65535","Internal1_forwarding_mode":"l2","Internal2_dhcp":"false","sctp-a-dst_subnet_prefix_v6":"::","pxe_image_name":"MME_PXE-Boot_16ACP04_GA.qcow2","vlc_st_interface_type_gtp":"other0","ncb1_Internal1_mac":"00:80:37:0E:09:12","sctp-b-src_subnet_prefix_v6":"::","sctp-a-egress_dst_subnet_prefix_len":"0.0","int1_sec_group_name":"int1-sec-group","Internal1_dhcp":"false","sctp-a-ipv6-egress_dst_end_port":"65535","Internal2_forwarding_mode":"l2","fsb2_Internal2_mac":"00:80:37:0E:0D:12","sctp-b-egress_dst_subnet_prefix":"0.0.0.0","Internal1_net_cidr_len":"17","gpb2_Internal1_mac":"00:80:37:0E:02:22","sctp-b-ingress-src_subnet_prefix_len":"0.0","sctp-a-ingress_dst_addresses":"local","sctp-a-egress_action":"pass","fsb_volume_type_0":"SF-Default-SSD","ncb2_Internal2_mac":"00:80:37:0E:0F:12","vlc_st_interface_type_sctp_a":"left","vlc_st_interface_type_sctp_b":"right","sctp-a-src_subnet_prefix_v6":"::","vlc_st_version":"2","sctp-b-egress_ethertype":"IPv4","sctp-a-ingress_rule_application":"any","gpb1_Internal2_mac":"00:80:37:0E:01:22","instance_ip_family_v6":"v6","sctp-a-ipv6-egress_src_start_port":"0","sctp-b-ingress-src_start_port":"0.0","sctp-b-ingress_dst_addresses":"local","fsb1_Internal1_mac":"00:80:37:0E:0B:12","vlc_st_interface_type_oam":"management","multi_stage_design":"false","oam_sec_group_name":"oam-sec-group","Internal2_net_gateway":"169.255.0.3","sctp-a-ipv6-ingress-dst_end_port":"65535","sctp-b-ipv6-egress-dst_start_port":"0","Internal1_net_gateway":"169.253.0.3","sctp-b-ipv6-egress_rule_protocol":"any","gtp_sec_group_name":"gtp-sec-group","sctp-a-ipv6-egress_dst_subnet_prefix":"0.0.0.0","sctp-b-ipv6-egress_dst_subnet_prefix_len":"0","sctp-a-ipv6-ingress_dst_addresses":"local","sctp-a-egress_rule_protocol":"icmp","sctp-b-ipv6-egress_action":"pass","sctp-a-ipv6-egress_action":"pass","Internal1_shared":"false","sctp-b-ipv6-ingress_rule_protocol":"any","Internal2_net_cidr_len":"17","sctp-a-name":"epc-sctp-a-ipv4v6-sec-group","sctp-a-ingress-src_end_port":"65535.0","sctp-b-ipv6-ingress_src_subnet_prefix":"0.0.0.0","sctp-a-egress-dst_end_port":"65535.0","sctp-a-ingress_action":"pass","sctp-b-egress_rule_protocol":"icmp","sctp-b-ipv6-ingress_action":"pass","vlc_st_service_type":"firewall","sctp-b-ipv6-egress_dst_end_port":"65535","sctp-b-ipv6-ingress-dst_start_port":"0","vlc2_Internal2_mac":"00:80:37:0E:02:12","vlc_st_availability_zone":"true","fsb_volume_image_name_1":"MME_FSB2_16ACP04_GA.qcow2","sctp-b-ingress-src_subnet_prefix":"0.0.0.0","sctp-a-ipv6-ingress_src_subnet_prefix_len":"0","Internal1_allow_transit":"true","gpb_flavor_name":"nv.c20r64d1","availability_zone_max_count":"1","fsb_volume_image_name_0":"MME_FSB1_16ACP04_GA.qcow2","sctp-b-ipv6-ingress_dst_addresses":"local","sctp-b-ipv6-egress_dst_subnet_prefix":"0.0.0.0","sctp-b-ipv6-ingress_ethertype":"IPv4","vlc1_Internal2_mac":"00:80:37:0E:01:12","sctp-a-ingress-src_subnet_prefix":"0.0.0.0","sctp-a-ipv6-ingress_action":"pass","Internal1_rpf":"disable","sctp-b-ingress_ethertype":"IPv4","sctp-b-egress_rule_application":"any","sctp-b-ingress-src_end_port":"65535.0","sctp-a-ipv6-ingress_rule_protocol":"any","sctp-a-ingress-src_start_port":"0.0","sctp-b-egress-dst_end_port":"65535.0"},"type":"VF","modelCustomizationName":"VF_vMee 0","vfModules":{"vf_vmee0..VfVmee..vmme_vlc..module-1":{"uuid":"522159d5-d6e0-4c2a-aa44-5a542a12a830","invariantUuid":"98a7c88b-b577-476a-90e4-e25a5871e02b","customizationUuid":"55b1be94-671a-403e-a26c-667e9c47d091","description":null,"name":"VfVmee..vmme_vlc..module-1","version":"2","modelCustomizationName":"VfVmee..vmme_vlc..module-1","properties":{"minCountInstances":0,"maxCountInstances":null,"initialCount":0,"vfModuleLabel":"vmme_vlc"},"inputs":{},"volumeGroupAllowed":false},"vf_vmee0..VfVmee..vmme_gpb..module-2":{"uuid":"41708296-e443-4c71-953f-d9a010f059e1","invariantUuid":"1cca90b8-3490-495e-87da-3f3e4c57d5b9","customizationUuid":"6add59e0-7fe1-4bc4-af48-f8812422ae7c","description":null,"name":"VfVmee..vmme_gpb..module-2","version":"2","modelCustomizationName":"VfVmee..vmme_gpb..module-2","properties":{"minCountInstances":0,"maxCountInstances":null,"initialCount":0,"vfModuleLabel":"vmme_gpb"},"inputs":{},"volumeGroupAllowed":false},"vf_vmee0..VfVmee..base_vmme..module-0":{"uuid":"a27f5cfc-7f12-4f99-af08-0af9c3885c87","invariantUuid":"a6f9e51a-2b35-416a-ae15-15e58d61f36d","customizationUuid":"f8c040f1-7e51-4a11-aca8-acf256cfd861","description":null,"name":"VfVmee..base_vmme..module-0","version":"2","modelCustomizationName":"VfVmee..base_vmme..module-0","properties":{"minCountInstances":1,"maxCountInstances":1,"initialCount":1,"vfModuleLabel":"base_vmme"},"inputs":{},"volumeGroupAllowed":true}},"volumeGroups":{"vf_vmee0..VfVmee..base_vmme..module-0":{"uuid":"a27f5cfc-7f12-4f99-af08-0af9c3885c87","invariantUuid":"a6f9e51a-2b35-416a-ae15-15e58d61f36d","customizationUuid":"f8c040f1-7e51-4a11-aca8-acf256cfd861","description":null,"name":"VfVmee..base_vmme..module-0","version":"2","modelCustomizationName":"VfVmee..base_vmme..module-0","properties":{"minCountInstances":1,"maxCountInstances":1,"initialCount":1,"vfModuleLabel":"base_vmme"},"inputs":{}}},"vfcInstanceGroups":{}}},"networks":{"ExtVL 0":{"uuid":"ddc3f20c-08b5-40fd-af72-c6d14636b986","invariantUuid":"379f816b-a7aa-422f-be30-17114ff50b7c","description":"ECOMP generic virtual link (network) base type for all other service-level and global networks","name":"ExtVL","version":"37.0","customizationUuid":"94fdd893-4a36-4d70-b16a-ec29c54c184f","inputs":{},"commands":{},"properties":{"network_assignments":"{is_external_network=false, ipv4_subnet_default_assignment={min_subnets_count=1}, ecomp_generated_network_assignment=false, ipv6_subnet_default_assignment={min_subnets_count=1}}","exVL_naming":"{ecomp_generated_naming=true}","network_flows":"{is_network_policy=false, is_bound_to_vpn=false}","network_homing":"{ecomp_selected_instance_node_target=false}"},"type":"VL","modelCustomizationName":"ExtVL 0"}},"collectionResource":{},"configurations":{"Port Mirroring Configuration By Policy 0":{"uuid":"b4398538-e89d-4f13-b33d-ca323434ba50","invariantUuid":"6ef0ca40-f366-4897-951f-abd65d25f6f7","description":"A port mirroring configuration by policy object","name":"Port Mirroring Configuration By Policy","version":"27.0","customizationUuid":"3c3b7b8d-8669-4b3b-8664-61970041fad2","inputs":{},"commands":{},"properties":{},"type":"Configuration","modelCustomizationName":"Port Mirroring Configuration By Policy 0","sourceNodes":[],"collectorNodes":null,"configurationByPolicy":false}},"serviceProxies":{},"vfModules":{"vf_vmee0..VfVmee..vmme_vlc..module-1":{"uuid":"522159d5-d6e0-4c2a-aa44-5a542a12a830","invariantUuid":"98a7c88b-b577-476a-90e4-e25a5871e02b","customizationUuid":"55b1be94-671a-403e-a26c-667e9c47d091","description":null,"name":"VfVmee..vmme_vlc..module-1","version":"2","modelCustomizationName":"VfVmee..vmme_vlc..module-1","properties":{"minCountInstances":0,"maxCountInstances":null,"initialCount":0,"vfModuleLabel":"vmme_vlc"},"inputs":{},"volumeGroupAllowed":false},"vf_vmee0..VfVmee..vmme_gpb..module-2":{"uuid":"41708296-e443-4c71-953f-d9a010f059e1","invariantUuid":"1cca90b8-3490-495e-87da-3f3e4c57d5b9","customizationUuid":"6add59e0-7fe1-4bc4-af48-f8812422ae7c","description":null,"name":"VfVmee..vmme_gpb..module-2","version":"2","modelCustomizationName":"VfVmee..vmme_gpb..module-2","properties":{"minCountInstances":0,"maxCountInstances":null,"initialCount":0,"vfModuleLabel":"vmme_gpb"},"inputs":{},"volumeGroupAllowed":false},"vf_vmee0..VfVmee..base_vmme..module-0":{"uuid":"a27f5cfc-7f12-4f99-af08-0af9c3885c87","invariantUuid":"a6f9e51a-2b35-416a-ae15-15e58d61f36d","customizationUuid":"f8c040f1-7e51-4a11-aca8-acf256cfd861","description":null,"name":"VfVmee..base_vmme..module-0","version":"2","modelCustomizationName":"VfVmee..base_vmme..module-0","properties":{"minCountInstances":1,"maxCountInstances":1,"initialCount":1,"vfModuleLabel":"base_vmme"},"inputs":{},"volumeGroupAllowed":true}},"volumeGroups":{"vf_vmee0..VfVmee..base_vmme..module-0":{"uuid":"a27f5cfc-7f12-4f99-af08-0af9c3885c87","invariantUuid":"a6f9e51a-2b35-416a-ae15-15e58d61f36d","customizationUuid":"f8c040f1-7e51-4a11-aca8-acf256cfd861","description":null,"name":"VfVmee..base_vmme..module-0","version":"2","modelCustomizationName":"VfVmee..base_vmme..module-0","properties":{"minCountInstances":1,"maxCountInstances":1,"initialCount":1,"vfModuleLabel":"base_vmme"},"inputs":{}}},"pnfs":{}}}'); + return JSON.parse('{"6e59c5de-f052-46fa-aa7e-2fca9d674c44":{"service":{"uuid":"6e59c5de-f052-46fa-aa7e-2fca9d674c44","invariantUuid":"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0","name":"ComplexService","version":"1.0","toscaModelURL":null,"category":"Emanuel","serviceType":"","serviceRole":"","description":"ComplexService","serviceEcompNaming":"true","instantiationType":"Macro","inputs":{}},"vnfs":{"VF_vMee 0":{"uuid":"d6557200-ecf2-4641-8094-5393ae3aae60","invariantUuid":"4160458e-f648-4b30-a176-43881ffffe9e","description":"VSP_vMee","name":"VF_vMee","version":"2.0","customizationUuid":"91415b44-753d-494c-926a-456a9172bbb9","inputs":{},"commands":{},"properties":{"gpb2_Internal2_mac":"00:11:22:EF:AC:DF","sctp-b-ipv6-egress_src_start_port":"0","sctp-a-ipv6-egress_rule_application":"any","Internal2_allow_transit":"true","sctp-b-IPv6_ethertype":"IPv6","sctp-a-egress_rule_application":"any","sctp-b-ingress_action":"pass","sctp-b-ingress_rule_protocol":"icmp","ncb2_Internal1_mac":"00:11:22:EF:AC:DF","sctp-b-ipv6-ingress-src_start_port":"0.0","ncb1_Internal2_mac":"00:11:22:EF:AC:DF","fsb_volume_size_0":"320.0","sctp-b-egress_src_addresses":"local","sctp-a-ipv6-ingress_ethertype":"IPv4","sctp-a-ipv6-ingress-dst_start_port":"0","sctp-b-ipv6-ingress_rule_application":"any","domain_name":"default-domain","sctp-a-ingress_rule_protocol":"icmp","sctp-b-egress-src_start_port":"0.0","sctp-a-egress_src_addresses":"local","sctp-b-display_name":"epc-sctp-b-ipv4v6-sec-group","sctp-a-egress-src_start_port":"0.0","sctp-a-ingress_ethertype":"IPv4","sctp-b-ipv6-ingress-dst_end_port":"65535","sctp-b-dst_subnet_prefix_v6":"::","nf_naming":"{ecomp_generated_naming=true}","sctp-a-ipv6-ingress_src_subnet_prefix":"0.0.0.0","sctp-b-egress-dst_start_port":"0.0","ncb_flavor_name":"nv.c20r64d1","gpb1_Internal1_mac":"00:11:22:EF:AC:DF","sctp-b-egress_dst_subnet_prefix_len":"0.0","Internal2_net_cidr":"10.0.0.10","sctp-a-ingress-dst_start_port":"0.0","sctp-a-egress-dst_start_port":"0.0","fsb1_Internal2_mac":"00:11:22:EF:AC:DF","sctp-a-egress_ethertype":"IPv4","vlc_st_service_mode":"in-network-nat","sctp-a-ipv6-egress_ethertype":"IPv4","sctp-a-egress-src_end_port":"65535.0","sctp-b-ipv6-egress_rule_application":"any","sctp-b-egress_action":"pass","sctp-a-ingress-src_subnet_prefix_len":"0.0","sctp-b-ipv6-ingress-src_end_port":"65535.0","sctp-b-name":"epc-sctp-b-ipv4v6-sec-group","fsb2_Internal1_mac":"00:11:22:EF:AC:DF","sctp-a-ipv6-ingress-src_start_port":"0.0","sctp-b-ipv6-egress_ethertype":"IPv4","Internal1_net_cidr":"10.0.0.10","sctp-a-egress_dst_subnet_prefix":"0.0.0.0","fsb_flavor_name":"nv.c20r64d1","sctp_rule_protocol":"132","sctp-b-ipv6-ingress_src_subnet_prefix_len":"0","sctp-a-ipv6-ingress_rule_application":"any","ecomp_generated_naming":"true","sctp-a-IPv6_ethertype":"IPv6","vlc2_Internal1_mac":"00:11:22:EF:AC:DF","vlc_st_virtualization_type":"virtual-machine","sctp-b-ingress-dst_start_port":"0.0","sctp-b-ingress-dst_end_port":"65535.0","sctp-a-ipv6-ingress-src_end_port":"65535.0","sctp-a-display_name":"epc-sctp-a-ipv4v6-sec-group","sctp-b-ingress_rule_application":"any","int2_sec_group_name":"int2-sec-group","vlc_flavor_name":"nd.c16r64d1","sctp-b-ipv6-egress_src_addresses":"local","vlc_st_interface_type_int1":"other1","sctp-b-egress-src_end_port":"65535.0","sctp-a-ipv6-egress-dst_start_port":"0","vlc_st_interface_type_int2":"other2","sctp-a-ipv6-egress_rule_protocol":"any","Internal2_shared":"false","sctp-a-ipv6-egress_dst_subnet_prefix_len":"0","Internal2_rpf":"disable","vlc1_Internal1_mac":"00:11:22:EF:AC:DF","sctp-b-ipv6-egress_src_end_port":"65535","sctp-a-ipv6-egress_src_addresses":"local","sctp-a-ingress-dst_end_port":"65535.0","sctp-a-ipv6-egress_src_end_port":"65535","Internal1_forwarding_mode":"l2","Internal2_dhcp":"false","sctp-a-dst_subnet_prefix_v6":"::","pxe_image_name":"MME_PXE-Boot_16ACP04_GA.qcow2","vlc_st_interface_type_gtp":"other0","ncb1_Internal1_mac":"00:11:22:EF:AC:DF","sctp-b-src_subnet_prefix_v6":"::","sctp-a-egress_dst_subnet_prefix_len":"0.0","int1_sec_group_name":"int1-sec-group","Internal1_dhcp":"false","sctp-a-ipv6-egress_dst_end_port":"65535","Internal2_forwarding_mode":"l2","fsb2_Internal2_mac":"00:11:22:EF:AC:DF","sctp-b-egress_dst_subnet_prefix":"0.0.0.0","Internal1_net_cidr_len":"17","gpb2_Internal1_mac":"00:11:22:EF:AC:DF","sctp-b-ingress-src_subnet_prefix_len":"0.0","sctp-a-ingress_dst_addresses":"local","sctp-a-egress_action":"pass","fsb_volume_type_0":"SF-Default-SSD","ncb2_Internal2_mac":"00:11:22:EF:AC:DF","vlc_st_interface_type_sctp_a":"left","vlc_st_interface_type_sctp_b":"right","sctp-a-src_subnet_prefix_v6":"::","vlc_st_version":"2","sctp-b-egress_ethertype":"IPv4","sctp-a-ingress_rule_application":"any","gpb1_Internal2_mac":"00:11:22:EF:AC:DF","instance_ip_family_v6":"v6","sctp-a-ipv6-egress_src_start_port":"0","sctp-b-ingress-src_start_port":"0.0","sctp-b-ingress_dst_addresses":"local","fsb1_Internal1_mac":"00:11:22:EF:AC:DF","vlc_st_interface_type_oam":"management","multi_stage_design":"false","oam_sec_group_name":"oam-sec-group","Internal2_net_gateway":"10.0.0.10","sctp-a-ipv6-ingress-dst_end_port":"65535","sctp-b-ipv6-egress-dst_start_port":"0","Internal1_net_gateway":"10.0.0.10","sctp-b-ipv6-egress_rule_protocol":"any","gtp_sec_group_name":"gtp-sec-group","sctp-a-ipv6-egress_dst_subnet_prefix":"0.0.0.0","sctp-b-ipv6-egress_dst_subnet_prefix_len":"0","sctp-a-ipv6-ingress_dst_addresses":"local","sctp-a-egress_rule_protocol":"icmp","sctp-b-ipv6-egress_action":"pass","sctp-a-ipv6-egress_action":"pass","Internal1_shared":"false","sctp-b-ipv6-ingress_rule_protocol":"any","Internal2_net_cidr_len":"17","sctp-a-name":"epc-sctp-a-ipv4v6-sec-group","sctp-a-ingress-src_end_port":"65535.0","sctp-b-ipv6-ingress_src_subnet_prefix":"0.0.0.0","sctp-a-egress-dst_end_port":"65535.0","sctp-a-ingress_action":"pass","sctp-b-egress_rule_protocol":"icmp","sctp-b-ipv6-ingress_action":"pass","vlc_st_service_type":"firewall","sctp-b-ipv6-egress_dst_end_port":"65535","sctp-b-ipv6-ingress-dst_start_port":"0","vlc2_Internal2_mac":"00:11:22:EF:AC:DF","vlc_st_availability_zone":"true","fsb_volume_image_name_1":"MME_FSB2_16ACP04_GA.qcow2","sctp-b-ingress-src_subnet_prefix":"0.0.0.0","sctp-a-ipv6-ingress_src_subnet_prefix_len":"0","Internal1_allow_transit":"true","gpb_flavor_name":"nv.c20r64d1","availability_zone_max_count":"1","fsb_volume_image_name_0":"MME_FSB1_16ACP04_GA.qcow2","sctp-b-ipv6-ingress_dst_addresses":"local","sctp-b-ipv6-egress_dst_subnet_prefix":"0.0.0.0","sctp-b-ipv6-ingress_ethertype":"IPv4","vlc1_Internal2_mac":"00:11:22:EF:AC:DF","sctp-a-ingress-src_subnet_prefix":"0.0.0.0","sctp-a-ipv6-ingress_action":"pass","Internal1_rpf":"disable","sctp-b-ingress_ethertype":"IPv4","sctp-b-egress_rule_application":"any","sctp-b-ingress-src_end_port":"65535.0","sctp-a-ipv6-ingress_rule_protocol":"any","sctp-a-ingress-src_start_port":"0.0","sctp-b-egress-dst_end_port":"65535.0"},"type":"VF","modelCustomizationName":"VF_vMee 0","vfModules":{"vf_vmee0..VfVmee..vmme_vlc..module-1":{"uuid":"522159d5-d6e0-4c2a-aa44-5a542a12a830","invariantUuid":"98a7c88b-b577-476a-90e4-e25a5871e02b","customizationUuid":"55b1be94-671a-403e-a26c-667e9c47d091","description":null,"name":"VfVmee..vmme_vlc..module-1","version":"2","modelCustomizationName":"VfVmee..vmme_vlc..module-1","properties":{"minCountInstances":0,"maxCountInstances":null,"initialCount":0,"vfModuleLabel":"vmme_vlc"},"inputs":{},"volumeGroupAllowed":false},"vf_vmee0..VfVmee..vmme_gpb..module-2":{"uuid":"41708296-e443-4c71-953f-d9a010f059e1","invariantUuid":"1cca90b8-3490-495e-87da-3f3e4c57d5b9","customizationUuid":"6add59e0-7fe1-4bc4-af48-f8812422ae7c","description":null,"name":"VfVmee..vmme_gpb..module-2","version":"2","modelCustomizationName":"VfVmee..vmme_gpb..module-2","properties":{"minCountInstances":0,"maxCountInstances":null,"initialCount":0,"vfModuleLabel":"vmme_gpb"},"inputs":{},"volumeGroupAllowed":false},"vf_vmee0..VfVmee..base_vmme..module-0":{"uuid":"a27f5cfc-7f12-4f99-af08-0af9c3885c87","invariantUuid":"a6f9e51a-2b35-416a-ae15-15e58d61f36d","customizationUuid":"f8c040f1-7e51-4a11-aca8-acf256cfd861","description":null,"name":"VfVmee..base_vmme..module-0","version":"2","modelCustomizationName":"VfVmee..base_vmme..module-0","properties":{"minCountInstances":1,"maxCountInstances":1,"initialCount":1,"vfModuleLabel":"base_vmme"},"inputs":{},"volumeGroupAllowed":true}},"volumeGroups":{"vf_vmee0..VfVmee..base_vmme..module-0":{"uuid":"a27f5cfc-7f12-4f99-af08-0af9c3885c87","invariantUuid":"a6f9e51a-2b35-416a-ae15-15e58d61f36d","customizationUuid":"f8c040f1-7e51-4a11-aca8-acf256cfd861","description":null,"name":"VfVmee..base_vmme..module-0","version":"2","modelCustomizationName":"VfVmee..base_vmme..module-0","properties":{"minCountInstances":1,"maxCountInstances":1,"initialCount":1,"vfModuleLabel":"base_vmme"},"inputs":{}}},"vfcInstanceGroups":{}}},"networks":{"ExtVL 0":{"uuid":"ddc3f20c-08b5-40fd-af72-c6d14636b986","invariantUuid":"379f816b-a7aa-422f-be30-17114ff50b7c","description":"ECOMP generic virtual link (network) base type for all other service-level and global networks","name":"ExtVL","version":"37.0","customizationUuid":"94fdd893-4a36-4d70-b16a-ec29c54c184f","inputs":{},"commands":{},"properties":{"network_assignments":"{is_external_network=false, ipv4_subnet_default_assignment={min_subnets_count=1}, ecomp_generated_network_assignment=false, ipv6_subnet_default_assignment={min_subnets_count=1}}","exVL_naming":"{ecomp_generated_naming=true}","network_flows":"{is_network_policy=false, is_bound_to_vpn=false}","network_homing":"{ecomp_selected_instance_node_target=false}"},"type":"VL","modelCustomizationName":"ExtVL 0"}},"collectionResource":{},"configurations":{"Port Mirroring Configuration By Policy 0":{"uuid":"b4398538-e89d-4f13-b33d-ca323434ba50","invariantUuid":"6ef0ca40-f366-4897-951f-abd65d25f6f7","description":"A port mirroring configuration by policy object","name":"Port Mirroring Configuration By Policy","version":"27.0","customizationUuid":"3c3b7b8d-8669-4b3b-8664-61970041fad2","inputs":{},"commands":{},"properties":{},"type":"Configuration","modelCustomizationName":"Port Mirroring Configuration By Policy 0","sourceNodes":[],"collectorNodes":null,"configurationByPolicy":false}},"serviceProxies":{},"vfModules":{"vf_vmee0..VfVmee..vmme_vlc..module-1":{"uuid":"522159d5-d6e0-4c2a-aa44-5a542a12a830","invariantUuid":"98a7c88b-b577-476a-90e4-e25a5871e02b","customizationUuid":"55b1be94-671a-403e-a26c-667e9c47d091","description":null,"name":"VfVmee..vmme_vlc..module-1","version":"2","modelCustomizationName":"VfVmee..vmme_vlc..module-1","properties":{"minCountInstances":0,"maxCountInstances":null,"initialCount":0,"vfModuleLabel":"vmme_vlc"},"inputs":{},"volumeGroupAllowed":false},"vf_vmee0..VfVmee..vmme_gpb..module-2":{"uuid":"41708296-e443-4c71-953f-d9a010f059e1","invariantUuid":"1cca90b8-3490-495e-87da-3f3e4c57d5b9","customizationUuid":"6add59e0-7fe1-4bc4-af48-f8812422ae7c","description":null,"name":"VfVmee..vmme_gpb..module-2","version":"2","modelCustomizationName":"VfVmee..vmme_gpb..module-2","properties":{"minCountInstances":0,"maxCountInstances":null,"initialCount":0,"vfModuleLabel":"vmme_gpb"},"inputs":{},"volumeGroupAllowed":false},"vf_vmee0..VfVmee..base_vmme..module-0":{"uuid":"a27f5cfc-7f12-4f99-af08-0af9c3885c87","invariantUuid":"a6f9e51a-2b35-416a-ae15-15e58d61f36d","customizationUuid":"f8c040f1-7e51-4a11-aca8-acf256cfd861","description":null,"name":"VfVmee..base_vmme..module-0","version":"2","modelCustomizationName":"VfVmee..base_vmme..module-0","properties":{"minCountInstances":1,"maxCountInstances":1,"initialCount":1,"vfModuleLabel":"base_vmme"},"inputs":{},"volumeGroupAllowed":true}},"volumeGroups":{"vf_vmee0..VfVmee..base_vmme..module-0":{"uuid":"a27f5cfc-7f12-4f99-af08-0af9c3885c87","invariantUuid":"a6f9e51a-2b35-416a-ae15-15e58d61f36d","customizationUuid":"f8c040f1-7e51-4a11-aca8-acf256cfd861","description":null,"name":"VfVmee..base_vmme..module-0","version":"2","modelCustomizationName":"VfVmee..base_vmme..module-0","properties":{"minCountInstances":1,"maxCountInstances":1,"initialCount":1,"vfModuleLabel":"base_vmme"},"inputs":{}}},"pnfs":{}}}'); } }); diff --git a/vid-webpack-master/src/app/shared/pipes/serviceInfo/serviceInfo.pipe.ts b/vid-webpack-master/src/app/shared/pipes/serviceInfo/serviceInfo.pipe.ts index 8cb2e1dcd..2876362e2 100644 --- a/vid-webpack-master/src/app/shared/pipes/serviceInfo/serviceInfo.pipe.ts +++ b/vid-webpack-master/src/app/shared/pipes/serviceInfo/serviceInfo.pipe.ts @@ -1,11 +1,11 @@ import {PipeTransform, Pipe} from '@angular/core'; -import {isNullOrUndefined} from "util"; +import * as _ from 'lodash'; @Pipe({ name: 'serviceInfo'}) export class ServiceInfoPipe implements PipeTransform { transform(service: string, store : any , modelId : string, fieldName : string): string { const serviceHierarchy = store.getState().service.serviceHierarchy; - if(!isNullOrUndefined(serviceHierarchy) && !isNullOrUndefined(serviceHierarchy[modelId])){ + if(!_.isNil(serviceHierarchy) && !_.isNil(serviceHierarchy[modelId])){ return serviceHierarchy[modelId].service[fieldName] || null; } return null; -- cgit 1.2.3-korg