2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
20 app.controller('roleListController', function ($scope,RoleService,confirmBoxService,conf,$state,$http,$log){
21 $scope.showSpinner = true;
23 RoleService.getRoles().then(function(data){
24 $scope.showSpinner = true;
26 $scope.data = JSON.parse(j.data);
27 $scope.availableRoles =JSON.parse($scope.data.availableRoles);
28 $scope.showSpinner = false;
35 $scope.goToUrl = function(roleIdVal) {
36 $state.go("root.role", {"roleId":roleIdVal});
38 $scope.toggleRole = function(selected,availableRole) {
39 var toggleType = null;
41 toggleType = "activate";
43 toggleType = "inactivate";
46 confirmBoxService.confirm("You are about to "+toggleType+" the role "+availableRole.name+". Do you want to continue?").then(
50 var uuu = conf.api.toggleRole;
52 var postData={role:availableRole};
53 $http.post(uuu, postData).then(function(response) {
54 var data = response.data;
55 if (typeof data === 'object') {
56 $log.debug('data:'+data);
57 $scope.availableRoles=data.availableRoles;
58 $log.debug('role::availableRoles:'+$scope.availableRoles);
63 }, function(response) {
64 debug.log('response:'+response);
65 availableRole.active=!availableRole.active;
66 confirmBoxService.showInformation("Error while saving.");
71 }) .catch(function(err) {
72 $log.error('roleListController::confirmBoxService.confirm error:', err);
73 availableRole.active=!availableRole.active;
79 $scope.removeRole = function(role) {
81 confirmBoxService.confirm("You are about to delete the role "+role.name+". Do you want to continue?").then(
83 var uuu = conf.api.removeRole;
84 var postData={role:role};
88 $http.post(uuu, postData).then(function(response) {
89 var data = response.data;
90 if (typeof data === 'object') {
91 $scope.availableRoles=data.availableRoles;
96 }, function(response) {
97 $log.debug('response:'+response.data);
98 confirmBoxService.showInformation("Error while deleting: "+ data.responseText);