X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Fapp%2Futilities%2Fstart-stop-rebuild%2FStartStopRebuildComponent.ts;h=bde04ba3482a71f19e1ca5a2e2c3770b66f2caeb;hb=0a34dfa32165036b380ec6ac493469b34007df0a;hp=18b6058a87d6a28ec0eb1a30328180a05a2b1681;hpb=3d81a28cd6df38cb070c6a6afbbd1528a766f16e;p=osm%2FNG-UI.git diff --git a/src/app/utilities/start-stop-rebuild/StartStopRebuildComponent.ts b/src/app/utilities/start-stop-rebuild/StartStopRebuildComponent.ts index 18b6058..bde04ba 100644 --- a/src/app/utilities/start-stop-rebuild/StartStopRebuildComponent.ts +++ b/src/app/utilities/start-stop-rebuild/StartStopRebuildComponent.ts @@ -18,6 +18,7 @@ /** * @file StartStopRebuild Component */ +import { isNullOrUndefined } from 'util'; import { HttpHeaders } from '@angular/common/http'; import { Component, Injector, Input, OnInit } from '@angular/core'; import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms'; @@ -28,7 +29,6 @@ import { environment } from 'environment'; import { StartStopRebuild } from 'NSInstanceModel'; import { RestService } from 'RestService'; import { SharedService } from 'SharedService'; -import { isNullOrUndefined } from 'util'; import { DF, VNFD } from 'VNFDModel'; import { VDUR, VNFInstanceDetails } from 'VNFInstanceModel'; @@ -68,6 +68,10 @@ export class StartStopRebuildComponent implements OnInit { public nsIdFilteredData: {}[] = []; /** Form valid on submit trigger @public */ public submitted: boolean = false; + /** Contains vduId @public */ + public vduId: {}; + /** Items for countIndex @public */ + public countIndex: {}[]; /** Input contains Modal dialog component Instance @public */ @Input() public instanceType: string; /** Input contains Modal dialog component Instance @public */ @@ -131,12 +135,15 @@ export class StartStopRebuildComponent implements OnInit { vnfInstanceData.push(vnfDataObj); }); const nsId: string = 'NS'; + // eslint-disable-next-line security/detect-object-injection this.nsIdFilteredData = vnfInstanceData.filter((vnfdData: {}[]): boolean => vnfdData[nsId] === this.params.id); this.nsIdFilteredData.forEach((resVNF: {}[]): void => { const memberIndex: string = 'MemberIndex'; const vnfinstanceID: string = 'VNFInstanceId'; const assignMemberIndex: {} = { + // eslint-disable-next-line security/detect-object-injection id: resVNF[memberIndex], + // eslint-disable-next-line security/detect-object-injection vnfinstanceId: resVNF[vnfinstanceID] }; this.memberVnfIndex.push(assignMemberIndex); @@ -152,7 +159,6 @@ export class StartStopRebuildComponent implements OnInit { /** Getting vdu-id & count-index from VNFInstance API */ public getVdu(id: string): void { const vnfInstanceData: {}[] = []; - const vnfrDetails: {}[] = []; this.getFormControl('vduId').setValue(null); this.getFormControl('countIndex').setValue(null); if (!isNullOrUndefined(id)) { @@ -161,7 +167,9 @@ export class StartStopRebuildComponent implements OnInit { this.instanceId = id; this.selectedvnfId = vnfInstanceDetail['vnfd-ref']; const VDU: string = 'vdur'; + // eslint-disable-next-line security/detect-object-injection if (vnfInstanceDetail[VDU] !== undefined) { + // eslint-disable-next-line security/detect-object-injection vnfInstanceDetail[VDU].forEach((vdu: VDUR): void => { const vnfInstanceDataObj: {} = { @@ -172,6 +180,13 @@ export class StartStopRebuildComponent implements OnInit { vnfInstanceData.push(vnfInstanceDataObj); }); this.vdu = vnfInstanceData; + const vduName: string = 'VDU'; + this.vduId = this.vdu.filter((vdu: {}, index: number, self: {}[]): {} => + index === self.findIndex((t: {}): {} => ( + // eslint-disable-next-line security/detect-object-injection + t[vduName] === vdu[vduName] + )) + ); } this.checkDay12Operation(this.selectedvnfId); }, (error: ERRORDATA): void => { @@ -181,6 +196,13 @@ export class StartStopRebuildComponent implements OnInit { } } + /** Getting count-index by filtering id */ + public getCountIndex(id: string): void { + const VDU: string = 'VDU'; + // eslint-disable-next-line security/detect-object-injection + this.countIndex = this.vdu.filter((vnfdData: {}[]): boolean => vnfdData[VDU] === id); + } + /** To check primitve actions from VNFR */ public checkDay12Operation(id: string): void { const apiUrl: string = environment.VNFPACKAGES_URL + '?id=' + id; @@ -264,7 +286,9 @@ export class StartStopRebuildComponent implements OnInit { }; this.restService.postResource(apiURLHeader, startPayload).subscribe((result: {}): void => { this.activeModal.close(modalData); - this.router.navigate(['/instances/ns/history-operations/' + this.params.id]).catch(); + this.router.navigate(['/instances/ns/history-operations/' + this.params.id]).catch((): void => { + // Catch Navigation Error + }); }, (error: ERRORDATA): void => { this.restService.handleError(error, 'post'); this.isLoadingResults = false; @@ -273,6 +297,7 @@ export class StartStopRebuildComponent implements OnInit { /** Used to get the AbstractControl of controlName passed @private */ private getFormControl(controlName: string): AbstractControl { + // eslint-disable-next-line security/detect-object-injection return this.startForm.controls[controlName]; } }