import { Component, ElementRef, Injector, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { Component, ElementRef, Injector, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { NSCREATEPARAMS, NSData, NSDDetails } from 'NSDModel';
import { RestService } from 'RestService';
import { SharedService } from 'SharedService';
import { NSCREATEPARAMS, NSData, NSDDetails } from 'NSDModel';
import { RestService } from 'RestService';
import { SharedService } from 'SharedService';
delete this.instantiateForm.value.ssh_keys;
} else {
this.copySSHKey = JSON.parse(JSON.stringify(this.instantiateForm.value.ssh_keys));
delete this.instantiateForm.value.ssh_keys;
} else {
this.copySSHKey = JSON.parse(JSON.stringify(this.instantiateForm.value.ssh_keys));
this.instantiateForm.get('ssh_keys').setValue([this.copySSHKey]);
}
if (isNullOrUndefined(this.instantiateForm.value.config) || this.instantiateForm.value.config === '') {
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) => {
if (validJSON) {
this.instantiateForm.value.config = JSON.parse(this.instantiateForm.value.config);
Object.keys(this.instantiateForm.value.config).forEach((item: string) => {
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) => {
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) => {
this.activeModal.close(modalData);
this.notifierService.notify('success', this.instantiateForm.value.nsName +
this.translateService.instant('PAGE.NSINSTANCE.CREATEDSUCCESSFULLY'));
this.activeModal.close(modalData);
this.notifierService.notify('success', this.instantiateForm.value.nsName +
this.translateService.instant('PAGE.NSINSTANCE.CREATEDSUCCESSFULLY'));
}, (error: ERRORDATA) => {
this.isLoadingResults = false;
this.restService.handleError(error, 'post');
if (!isNullOrUndefined(this.copySSHKey)) {
}, (error: ERRORDATA) => {
this.isLoadingResults = false;
this.restService.handleError(error, 'post');
if (!isNullOrUndefined(this.copySSHKey)) {
if (files && files.length === 1) {
this.sharedService.getFileString(files, 'pub').then((fileContent: string): void => {
const getSSHJson: string = jsyaml.load(fileContent, { json: true });
if (files && files.length === 1) {
this.sharedService.getFileString(files, 'pub').then((fileContent: string): void => {
const getSSHJson: string = jsyaml.load(fileContent, { json: true });
this.instantiateForm.get('ssh_keys').setValue(getSSHJson);
}).catch((err: string): void => {
if (err === 'typeError') {
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 => {
const fileFormat: string = this.sharedService.fetchFileExtension(files).toLocaleLowerCase();
if (fileFormat === 'yaml' || fileFormat === 'yml') {
this.sharedService.getFileString(files, 'yaml').then((fileContent: string): void => {
this.instantiateForm.get('config').setValue(fileContent);
}).catch((err: string): void => {
if (err === 'typeError') {
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 });
} else if (fileFormat === 'json') {
this.sharedService.getFileString(files, 'json').then((fileContent: string): void => {
const getConfigJson: string = jsyaml.load(fileContent, { json: true });
this.instantiateForm.get('config').setValue(JSON.stringify(getConfigJson));
}).catch((err: string): void => {
if (err === 'typeError') {
this.instantiateForm.get('config').setValue(JSON.stringify(getConfigJson));
}).catch((err: string): void => {
if (err === 'typeError') {