+
+ /** Check data is empty or not to load config @public */
+ public checkData(): void {
+ if (this.data !== '' && this.data.length > this.configLength) {
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
+ const modalRef: NgbModalRef = this.modalService.open(WarningComponent, { backdrop: 'static' });
+ modalRef.componentInstance.heading = this.translateService.instant('PAGE.VIMDETAILS.VIMHEADER');
+ modalRef.componentInstance.confirmationMessage = this.translateService.instant('PAGE.VIMDETAILS.VIMCONTENT');
+ modalRef.componentInstance.submitMessage = this.translateService.instant('PAGE.VIMDETAILS.VIMSUBMIT');
+ modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => {
+ if (result.message === CONFIGCONSTANT.done) {
+ this.loadSampleConfig();
+ }
+ }).catch((): void => {
+ // Catch Navigation Error
+ });
+ } else if (this.data.length < this.configLength || this.data === '') {
+ this.loadSampleConfig();
+ }
+ }
+
+ /** Load sample config based on VIM type @public */
+ public loadSampleConfig(): void {
+ if (this.selectedVimType === 'openstack') {
+ this.defaults['text/x-yaml'] = jsyaml.dump(TYPEOPENSTACK);
+ this.data = JSON.stringify(TYPEOPENSTACK, null, '\t');
+ } else if (this.selectedVimType === 'aws') {
+ this.defaults['text/x-yaml'] = jsyaml.dump(TYPEAWS);
+ this.data = JSON.stringify(TYPEAWS, null, '\t');
+ } else if (this.selectedVimType === 'vmware') {
+ this.defaults['text/x-yaml'] = jsyaml.dump(TYPEVMWARE);
+ this.data = JSON.stringify(TYPEVMWARE, null, '\t');
+ } else if (this.selectedVimType === 'openvim' || this.selectedVimType === 'opennebula') {
+ this.defaults['text/x-yaml'] = jsyaml.dump(TYPEOPENVIMNEBULA);
+ this.data = JSON.stringify(TYPEOPENVIMNEBULA, null, '\t');
+ } else if (this.selectedVimType === 'azure' || this.selectedVimType === 'opennebula') {
+ this.defaults['text/x-yaml'] = jsyaml.dump(TYPEAZURE);
+ this.data = JSON.stringify(TYPEAZURE, null, '\t');
+ } else {
+ this.defaults['text/x-yaml'] = jsyaml.dump(TYPEOTERS);
+ this.data = JSON.stringify(TYPEOTERS, null, '\t');
+ }
+ }
+
+ /** Load sample config based on VIM type in edit @public */
+ public loadConfig(): void {
+ this.clearConfig();
+ if (this.details.vim_type === 'openstack') {
+ this.defaults['text/x-yaml'] = jsyaml.dump(this.config);
+ this.data = JSON.stringify(this.config, null, '\t');
+ } else if (this.details.vim_type === 'aws') {
+ this.defaults['text/x-yaml'] = jsyaml.dump(this.config);
+ this.data = JSON.stringify(this.config, null, '\t');
+ } else if (this.details.vim_type === 'vmware') {
+ this.defaults['text/x-yaml'] = jsyaml.dump(this.config);
+ this.data = JSON.stringify(this.config, null, '\t');
+ } else if (this.details.vim_type === 'openvim' || this.details.vim_type === 'opennebula') {
+ this.defaults['text/x-yaml'] = jsyaml.dump(this.config);
+ this.data = JSON.stringify(this.config, null, '\t');
+ } else if (this.details.vim_type === 'azure' || this.details.vim_type === 'opennebula') {
+ this.defaults['text/x-yaml'] = jsyaml.dump(this.config);
+ this.data = JSON.stringify(this.config, null, '\t');
+ } else {
+ this.defaults['text/x-yaml'] = jsyaml.dump(this.config);
+ this.data = JSON.stringify(this.config, null, '\t');
+ }
+ }
+
+ /** Clear config parameters @public */
+ public clearConfig(): void {
+ this.check = true;
+ if (this.data !== '' && this.data.length > this.configLength) {
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
+ const modalRef: NgbModalRef = this.modalService.open(WarningComponent, { backdrop: 'static' });
+ modalRef.componentInstance.heading = this.translateService.instant('PAGE.VIMDETAILS.VIMHEADER');
+ modalRef.componentInstance.confirmationMessage = this.translateService.instant('PAGE.VIMDETAILS.CLEARCONTENT');
+ modalRef.componentInstance.submitMessage = this.translateService.instant('PAGE.VIMDETAILS.VIMSUBMIT');
+ modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => {
+ if (result.message === CONFIGCONSTANT.done) {
+ this.defaults['text/x-yaml'] = '';
+ this.data = '';
+ this.fileInput.nativeElement.value = null;
+ }
+ }).catch((): void => {
+ // Catch Navigation Error
+ });
+ } else {
+ this.defaults['text/x-yaml'] = '';
+ this.data = '';
+ this.fileInput.nativeElement.value = null;
+ }
+ }
+
+ /** Used to get the AbstractControl of controlName passed @private */
+ private getFormControl(controlName: string): AbstractControl {
+ // eslint-disable-next-line security/detect-object-injection
+ return this.vimNewAccountForm.controls[controlName];
+ }