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';
/**
/** 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;
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 === '') {
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;
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);
}
});
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') {
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') {
} 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') {
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;
+ }
+ }
}