X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Fapp%2Fpackages%2Finstantiate-ns%2FInstantiateNsComponent.ts;h=9ba89da4dda3b652595c16817015230ed677f7f3;hb=c84f1123f8ba69f9e2211b2d816bb415e595efaa;hp=74569f1a02898ee10aa1983a338671b78f98138f;hpb=c1642477dde718a0ba902a0d6dc39a1fdcfe2bcf;p=osm%2FNG-UI.git diff --git a/src/app/packages/instantiate-ns/InstantiateNsComponent.ts b/src/app/packages/instantiate-ns/InstantiateNsComponent.ts index 74569f1..9ba89da 100644 --- a/src/app/packages/instantiate-ns/InstantiateNsComponent.ts +++ b/src/app/packages/instantiate-ns/InstantiateNsComponent.ts @@ -30,8 +30,7 @@ import { environment } from 'environment'; import * as jsyaml from 'js-yaml'; import { NSCREATEPARAMS, NSData, NSDDetails } from 'NSDModel'; import { RestService } from 'RestService'; -import { SharedService } from 'SharedService'; -import { isNullOrUndefined } from 'util'; +import { SharedService, isNullOrUndefined } from 'SharedService'; import { VimAccountDetails } from 'VimAccountModel'; /** @@ -75,6 +74,9 @@ export class InstantiateNsComponent implements OnInit { /** Give the message for the loading @public */ public message: string = 'PLEASEWAIT'; + /** Contains Selected VIM Details @public */ + public selectedVIMDetails: VimAccountDetails = null; + /** Element ref for fileInputConfig @public */ @ViewChild('fileInputConfig', { static: true }) public fileInputConfig: ElementRef; @@ -183,7 +185,6 @@ export class InstantiateNsComponent implements OnInit { delete this.instantiateForm.value.ssh_keys; } else { this.copySSHKey = JSON.parse(JSON.stringify(this.instantiateForm.value.ssh_keys)); - // tslint:disable-next-line: no-backbone-get-set-outside-model this.instantiateForm.get('ssh_keys').setValue([this.copySSHKey]); } if (isNullOrUndefined(this.instantiateForm.value.config) || this.instantiateForm.value.config === '') { @@ -193,12 +194,14 @@ export class InstantiateNsComponent implements OnInit { if (validJSON) { this.instantiateForm.value.config = JSON.parse(this.instantiateForm.value.config); Object.keys(this.instantiateForm.value.config).forEach((item: string) => { + // eslint-disable-next-line security/detect-object-injection this.instantiateForm.value[item] = this.instantiateForm.value.config[item]; }); delete this.instantiateForm.value.config; } else { const getConfigJson: string = jsyaml.load(this.instantiateForm.value.config, { json: true }); Object.keys(getConfigJson).forEach((item: string) => { + // eslint-disable-next-line security/detect-object-injection this.instantiateForm.value[item] = getConfigJson[item]; }); delete this.instantiateForm.value.config; @@ -212,12 +215,13 @@ export class InstantiateNsComponent implements OnInit { this.activeModal.close(modalData); this.notifierService.notify('success', this.instantiateForm.value.nsName + this.translateService.instant('PAGE.NSINSTANCE.CREATEDSUCCESSFULLY')); - this.router.navigate(['/instances/ns']).catch(); + this.router.navigate(['/instances/ns']).catch((): void => { + // Catch Navigation Error + }); }, (error: ERRORDATA) => { this.isLoadingResults = false; this.restService.handleError(error, 'post'); if (!isNullOrUndefined(this.copySSHKey)) { - // tslint:disable-next-line: no-backbone-get-set-outside-model this.instantiateForm.get('ssh_keys').setValue(this.copySSHKey); } }); @@ -228,7 +232,6 @@ export class InstantiateNsComponent implements OnInit { if (files && files.length === 1) { this.sharedService.getFileString(files, 'pub').then((fileContent: string): void => { const getSSHJson: string = jsyaml.load(fileContent, { json: true }); - // tslint:disable-next-line: no-backbone-get-set-outside-model this.instantiateForm.get('ssh_keys').setValue(getSSHJson); }).catch((err: string): void => { if (err === 'typeError') { @@ -252,7 +255,6 @@ export class InstantiateNsComponent implements OnInit { const fileFormat: string = this.sharedService.fetchFileExtension(files).toLocaleLowerCase(); if (fileFormat === 'yaml' || fileFormat === 'yml') { this.sharedService.getFileString(files, 'yaml').then((fileContent: string): void => { - // tslint:disable-next-line: no-backbone-get-set-outside-model this.instantiateForm.get('config').setValue(fileContent); }).catch((err: string): void => { if (err === 'typeError') { @@ -266,7 +268,6 @@ export class InstantiateNsComponent implements OnInit { } else if (fileFormat === 'json') { this.sharedService.getFileString(files, 'json').then((fileContent: string): void => { const getConfigJson: string = jsyaml.load(fileContent, { json: true }); - // tslint:disable-next-line: no-backbone-get-set-outside-model this.instantiateForm.get('config').setValue(JSON.stringify(getConfigJson)); }).catch((err: string): void => { if (err === 'typeError') { @@ -284,4 +285,11 @@ export class InstantiateNsComponent implements OnInit { this.fileInputConfigLabel.nativeElement.innerText = files[0].name; this.fileInputConfig.nativeElement.value = null; } + + /** Get Selected VIM details @public */ + public getSelectedVIMDetails(vimDetails: VimAccountDetails): void { + if (!isNullOrUndefined(vimDetails.resources)) { + this.selectedVIMDetails = vimDetails; + } + } }