From: SANDHYA.JS Date: Thu, 12 Oct 2023 09:01:00 +0000 (+0530) Subject: Fix Bug 2294: Incorrect notification in update descriptor X-Git-Tag: release-v15.0-start~3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F58%2F13958%2F3;p=osm%2FNG-UI.git Fix Bug 2294: Incorrect notification in update descriptor - Fixed the update descriptor issue to show 'Please Change something' when no changes is made. Change-Id: I042835c1934c1b94a8e8d880dae8d97b289750df Signed-off-by: SANDHYA.JS --- diff --git a/src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent.ts b/src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent.ts index e653e7c..16ecadd 100644 --- a/src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent.ts +++ b/src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent.ts @@ -139,7 +139,6 @@ export class OsmRepoCreateUpdateComponent implements OnInit { if (this.osmrepoForm.invalid) { return; } - this.isLoadingResults = true; const modalData: MODALCLOSERESPONSEDATA = { message: 'Done' }; @@ -160,10 +159,11 @@ export class OsmRepoCreateUpdateComponent implements OnInit { /** This function used to add the osm repo @public */ public addOsmRepo(apiURLHeader: APIURLHEADER, modalData: MODALCLOSERESPONSEDATA): void { + this.isLoadingResults = true; this.restService.postResource(apiURLHeader, this.osmrepoForm.value).subscribe(() => { + this.isLoadingResults = false; this.activeModal.close(modalData); this.notifierService.notify('success', this.translateService.instant('PAGE.OSMREPO.CREATEDSUCCESSFULLY')); - this.isLoadingResults = false; }, (error: ERRORDATA) => { this.isLoadingResults = false; this.restService.handleError(error, 'post'); @@ -172,10 +172,15 @@ export class OsmRepoCreateUpdateComponent implements OnInit { /** This function used to Edit the osm repo @public */ public editOsmRepo(apiURLHeader: APIURLHEADER, modalData: MODALCLOSERESPONSEDATA): void { + if (!this.osmrepoForm.dirty) { + this.notifierService.notify('warning', this.translateService.instant('PAGE.TOPOLOGY.DATAEMPTY')); + return; + } + this.isLoadingResults = true; this.restService.patchResource(apiURLHeader, this.osmrepoForm.value).subscribe(() => { - this.activeModal.close(modalData); - this.notifierService.notify('success', this.translateService.instant('PAGE.OSMREPO.UPDATEDSUCCESSFULLY')); this.isLoadingResults = false; + this.notifierService.notify('success', this.translateService.instant('PAGE.OSMREPO.UPDATEDSUCCESSFULLY')); + this.activeModal.close(modalData); }, (error: ERRORDATA) => { this.isLoadingResults = false; this.restService.handleError(error, 'patch'); diff --git a/src/app/projects/project-create-update/ProjectCreateUpdateComponent.ts b/src/app/projects/project-create-update/ProjectCreateUpdateComponent.ts index 9f8cc83..af6388d 100644 --- a/src/app/projects/project-create-update/ProjectCreateUpdateComponent.ts +++ b/src/app/projects/project-create-update/ProjectCreateUpdateComponent.ts @@ -213,6 +213,10 @@ export class ProjectCreateUpdateComponent implements OnInit { } /** Edit project @public */ public editProject(): void { + if (!this.projectForm.dirty) { + this.notifierService.notify('warning', this.translateService.instant('PAGE.TOPOLOGY.DATAEMPTY')); + return; + } this.isLoadingResults = true; const apiURLHeader: APIURLHEADER = { url: environment.PROJECTS_URL + '/' + this.projectRef @@ -226,6 +230,7 @@ export class ProjectCreateUpdateComponent implements OnInit { this.isLoadingResults = false; this.projectService.setHeaderProjects(); this.notifierService.notify('success', this.translateService.instant('PAGE.PROJECT.UPDATEDSUCCESSFULLY')); + this.activeModal.close(this.modalData); }, (error: ERRORDATA): void => { this.restService.handleError(error, 'patch'); this.isLoadingResults = false; diff --git a/src/app/roles/roles-create-edit/RolesCreateEditComponent.ts b/src/app/roles/roles-create-edit/RolesCreateEditComponent.ts index 87e1b86..59196ea 100644 --- a/src/app/roles/roles-create-edit/RolesCreateEditComponent.ts +++ b/src/app/roles/roles-create-edit/RolesCreateEditComponent.ts @@ -70,6 +70,15 @@ export class RolesCreateEditComponent implements OnInit { /** Contains view selection value either text or preview @public */ public viewMode: string = 'text'; + /** Contains current permissions data @private */ + private currentPermissions: string; + + /** Contains current role name @private */ + private currentRoleName: string; + + /** Contains modified role name @private */ + private modifiedRoleName: string; + /** Contains role id value @private */ private roleRef: string; @@ -193,7 +202,7 @@ export class RolesCreateEditComponent implements OnInit { this.notifierService.notify('success', this.translateService.instant('PAGE.ROLES.CREATEDSUCCESSFULLY')); this.router.navigate(['/roles/details']).catch((): void => { // Catch Navigation Error - }); + }); }, (error: ERRORDATA) => { this.isLoadingResults = false; this.restService.handleError(error, 'post'); @@ -206,16 +215,15 @@ export class RolesCreateEditComponent implements OnInit { url: environment.ROLES_URL + '/' + this.roleRef, httpOptions: { headers: this.headers } }; + this.modifiedRoleName = this.roleForm.value.roleName; let permissionData: Object = {}; this.sharedService.cleanForm(this.roleForm); if (!this.roleForm.invalid) { if (this.viewMode === 'preview') { - this.isLoadingResults = true; permissionData = this.generatePermissions(); this.roleEditAPI(apiURLHeader, permissionData); } else { if (this.checkPermission()) { - this.isLoadingResults = true; permissionData = this.roleForm.value.permissions !== '' ? JSON.parse(this.roleForm.value.permissions) : {}; this.roleEditAPI(apiURLHeader, permissionData); } @@ -225,6 +233,11 @@ export class RolesCreateEditComponent implements OnInit { /** Method to handle role edit API call */ public roleEditAPI(apiURLHeader: APIURLHEADER, permissionData: {}): void { + if ((JSON.stringify(permissionData, null, '\t') === this.currentPermissions) && (this.modifiedRoleName === this.currentRoleName)) { + this.notifierService.notify('warning', this.translateService.instant('PAGE.TOPOLOGY.DATAEMPTY')); + return; + } + this.isLoadingResults = true; const postData: {} = { name: this.roleForm.value.roleName, permissions: !isNullOrUndefined(permissionData) ? permissionData : {} @@ -233,7 +246,7 @@ export class RolesCreateEditComponent implements OnInit { this.notifierService.notify('success', this.translateService.instant('PAGE.ROLES.UPDATEDSUCCESSFULLY')); this.router.navigate(['/roles/details']).catch((): void => { // Catch Navigation Error - }); + }); }, (error: ERRORDATA) => { this.isLoadingResults = false; this.restService.handleError(error, 'patch'); @@ -304,10 +317,12 @@ export class RolesCreateEditComponent implements OnInit { this.roleForm.setValue({ roleName: data.name, permissions: JSON.stringify(data.permissions, null, '\t') }); this.filterRoleData(data.permissions); this.isLoadingResults = false; + this.currentRoleName = data.name; + this.currentPermissions = JSON.stringify(data.permissions, null, '\t'); }, (error: ERRORDATA) => { this.router.navigate(['/roles/details']).catch((): void => { // Catch Navigation Error - }); + }); this.restService.handleError(error, 'get'); }); } diff --git a/src/app/users/project-role/ProjectRoleComponent.ts b/src/app/users/project-role/ProjectRoleComponent.ts index 3a7e612..0c1121b 100644 --- a/src/app/users/project-role/ProjectRoleComponent.ts +++ b/src/app/users/project-role/ProjectRoleComponent.ts @@ -210,6 +210,10 @@ export class ProjectRoleComponent implements OnInit { this.projectRoleMap.project_role_mappings.push({ project: res.project_name, role: res.role_name }); }); if (this.projectRoleMap.project_role_mappings.length !== 0) { + if (!this.projectRoleForm.dirty) { + this.notifierService.notify('warning', this.translateService.instant('PAGE.TOPOLOGY.DATAEMPTY')); + return; + } this.isLoadingResults = true; this.restService.patchResource(apiURLHeader, this.projectRoleMap).subscribe((result: {}): void => { this.isLoadingResults = false; diff --git a/src/app/utilities/edit-packages/EditPackagesComponent.ts b/src/app/utilities/edit-packages/EditPackagesComponent.ts index 42998b8..3cf75c9 100644 --- a/src/app/utilities/edit-packages/EditPackagesComponent.ts +++ b/src/app/utilities/edit-packages/EditPackagesComponent.ts @@ -141,6 +141,9 @@ export class EditPackagesComponent implements OnInit { /** Data @private */ private data: string = ''; + /** Contains updated data @private */ + private updateData: string; + /** contains http options @private */ private httpOptions: HttpHeaders; @@ -239,7 +242,7 @@ export class EditPackagesComponent implements OnInit { /** Update function @public */ public update(showgraph: boolean): void { - if (this.data === '') { + if (this.data === '' || this.data === this.updateData) { this.notifierService.notify('warning', this.translateService.instant('PAGE.TOPOLOGY.DATAEMPTY')); } else { this.updateCheck(showgraph); @@ -255,11 +258,11 @@ export class EditPackagesComponent implements OnInit { if (packageType === 'nsd') { this.router.navigate(['/packages/ns/compose/' + this.paramsID]).catch((): void => { // Catch Navigation Error - }); + }); } else if (packageType === 'vnf') { this.router.navigate(['/packages/vnf/compose/' + this.paramsID]).catch((): void => { // Catch Navigation Error - }); + }); } } this.getEditFileData(); @@ -277,10 +280,11 @@ export class EditPackagesComponent implements OnInit { }; let descriptorInfo: string = ''; if (this.mode === 'text/json') { - descriptorInfo = jsyaml.dump(JSON.parse(this.data), {sortKeys: true}); + descriptorInfo = jsyaml.dump(JSON.parse(this.data), { sortKeys: true }); } else { descriptorInfo = this.data; } + this.updateData = this.data; if (this.getFileContentType !== 'nst') { this.sharedService.targzFile({ packageType: this.pacakgeType, id: this.paramsID, descriptor: descriptorInfo }) .then((content: ArrayBuffer): void => { @@ -309,10 +313,10 @@ export class EditPackagesComponent implements OnInit { this.isLoadingResults = false; }, (error: ERRORDATA) => { error.error = typeof error.error === 'string' ? jsyaml.load(error.error) : error.error; - if (error.error.status === HttpStatus.NOT_FOUND || error.error.status === HttpStatus.UNAUTHORIZED ) { + if (error.error.status === HttpStatus.NOT_FOUND || error.error.status === HttpStatus.UNAUTHORIZED) { this.router.navigateByUrl('404', { skipLocationChange: true }).catch((): void => { // Catch Navigation Error - }); + }); } else { this.restService.handleError(error, 'get'); }