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,AdminService,modalService){
22 AdminService.getRoles().then(function(data){
25 $scope.data = JSON.parse(j.data);
26 $scope.availableRoles =JSON.parse($scope.data.availableRoles);
31 console.log("failed");
35 //console.log($scope.availableRoles);
36 $scope.toggleRole = function(selected,availableRole) {
37 //alert('toggleRole: '+selected);
38 var toggleType = null;
40 toggleType = "activate";
42 toggleType = "inactivate";
45 modalService.popupConfirmWinWithCancel("Confirm","You are about to "+toggleType+" the test role "+availableRole.name+". Do you want to continue?",
47 var uuu = "role_list/toggleRole";
49 var postData={role:availableRole};
54 contentType: 'application/json',
55 data: JSON.stringify(postData),
56 success : function(data){
58 $scope.$apply(function(){$scope.availableRoles=data.availableRoles;});
59 console.log($scope.availableRoles);
61 error : function(data){
63 modalService.showFailure("Fail","Error while saving.");
69 availableRole.active=!availableRole.active;
75 $scope.removeRole = function(role) {
77 modalService.popupConfirmWin("Confirm","You are about to delete the role "+role.name+". Do you want to continue?",
79 var uuu = "role_list/removeRole";
80 var postData={role:role};
85 contentType: 'application/json',
86 data: JSON.stringify(postData),
87 success : function(data){
88 $scope.$apply(function(){$scope.availableRoles=data.availableRoles;});
90 error : function(data){
92 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);