X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Fapp%2Froles%2Froles-create-edit%2FRolesCreateEditComponent.ts;h=59196eaf11466fe3c51005235a18cb2a962dcf60;hb=382448fed3f9d4d4cf9ac614e1275208d18b752f;hp=87e1b8652a4ecef44aa992789402254e27932a77;hpb=c6c72e359f949e7595f3e7594d5d811ee7fd9d39;p=osm%2FNG-UI.git 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'); }); }