+ },function(error){
+ $scope.showSpinner = false;
+ confirmBoxService.showInformation('Failed to get roles. Please try again!').then(isConfirmed => {});
+ $scope.availableRoles = [];
+ $log.debug('failed');
+ });
+ }
+
+ $scope.fnManageRoleFunctions = function(){
+ RoleService.setManageRoleDetails($scope.centralizedApps, $scope.apps.selectedCentralizedApp);
+ };
+
+ function init(){
+ $scope.apps = {
+ selectedCentralizedApp:''
+ };
+ $scope.getCentralizedApps(sessionStorage.userId);
+ }
+
+ init();
+
+ // edit Role
+ $scope.editRoleModalPopup = function(appId, availableRole) {
+ $scope.showSpinner = true;
+ if(!availableRole.active)
+ return confirmBoxService.showInformation('Edit is diabled! Please toggle the role to activate it.').then(isConfirmed => {});
+ $scope.editRole = availableRole;
+ if(appId != undefined && availableRole.id != undefined){
+ RoleService.getRole(appId, availableRole.id).then(function(data){
+ $scope.showSpinner = false;
+ var response = JSON.parse(data.data);
+ var role = JSON.parse(response.role);
+ var availableRoles = JSON.parse(response.availableRoles);
+ var availableRoleFunctions = JSON.parse(response.availableRoleFunctions);
+ $scope.availableRoleFunctions = response.roleFunctions;
+ var modalInstance = $modal.open({
+ templateUrl: 'app/views/role/popup_createedit_role.html',
+ controller: 'roleCreateEditController',
+ sizeClass: 'modal-large',
+ windowClass: "modal-docked",
+ resolve: {
+ message: function () {
+ var message = {
+ availableRoles: availableRoles,
+ availableRoleFunctions: availableRoleFunctions,
+ appId: $scope.apps.selectedCentralizedApp,
+ role: role
+ };
+ return message;
+ }
+ }
+ });
+ modalInstance.result.then(function (confirmed) {
+ if(confirmed == 'confirmed'){
+ $scope.getRolesForSelectedCentralizedApp(appId);
+ }
+ });
+ },function(error){
+ $log.debug('Failed to editRole');
+ $scope.showSpinner = false;
+ });
+ }
+