X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Fapp%2Fvim-accounts%2Fnew-vimaccount%2FNewVimaccountComponent.ts;h=05fe4a2b0b784152706d0becb9d81031397fa911;hb=46ea49db958888a91926317adf784252695a9359;hp=724bef211d4998b529dfe29838cdb4af4c181105;hpb=5f8c802910e7c64d476296448487b9cfa774380d;p=osm%2FNG-UI.git diff --git a/src/app/vim-accounts/new-vimaccount/NewVimaccountComponent.ts b/src/app/vim-accounts/new-vimaccount/NewVimaccountComponent.ts index 724bef2..05fe4a2 100644 --- a/src/app/vim-accounts/new-vimaccount/NewVimaccountComponent.ts +++ b/src/app/vim-accounts/new-vimaccount/NewVimaccountComponent.ts @@ -171,6 +171,15 @@ export class NewVimaccountComponent implements OnInit { // eslint-disable-next-line @typescript-eslint/no-magic-numbers private configLength: number = 3; + /** Contains config length from get api @private */ + private getConfigLength: number; + + /** Contains config when update @private */ + private updateConfig: object; + + /** Contains config length when update @private */ + private updateConfigLength: number; + /** Instance of the rest service @private */ private restService: RestService; @@ -266,6 +275,7 @@ export class NewVimaccountComponent implements OnInit { } } delete this.details.config.location; + this.getConfigLength = Object.keys(this.details.config).length; this.getFormControl('schema_type').disable(); this.getFormControl('vim_url').disable(); this.getFormControl('vim_type').disable(); @@ -332,9 +342,23 @@ export class NewVimaccountComponent implements OnInit { delete this.vimNewAccountForm.value.config[res]; } }); - if (!isNullOrUndefined(this.vimID)) { + delete this.vimNewAccountForm.value.config.location; + if (!isNullOrUndefined(this.data)) { + this.updateConfig = jsyaml.load(this.data, { json: true }); + if (!isNullOrUndefined(this.updateConfig)) { + this.updateConfigLength = Object.keys(this.updateConfig).length; + } + } + if (this.updateConfig === undefined) { + this.notifierService.notify('warning', this.translateService.instant('PAGE.VIMDETAILS.VIMDELETE')); + this.isLocationLoadingResults = false; + } else if (this.getConfigLength > this.updateConfigLength) { + this.notifierService.notify('warning', this.translateService.instant('PAGE.VIMDETAILS.VIMEMPTY')); + this.isLocationLoadingResults = false; + } + if (!isNullOrUndefined(this.vimID) && ((this.getConfigLength <= this.updateConfigLength))) { this.editVIM(); - } else { + } else if (isNullOrUndefined(this.vimID)) { this.createNewVIM(); } }