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 ================================================================================
21 <%-- <%@ include file="/WEB-INF/fusion/jsp/include.jsp" %> --%>
23 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
24 <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
25 <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
26 <%@ include file="/WEB-INF/fusion/jsp/popup_modal.html" %>
28 <div class="pageTitle">
29 <h1 class="heading1" style="margin-top:20px;">Roles</h1>
32 Click on a Role to view its details.
34 <div ng-controller="roleListController" >
35 <div id="dialog" title="Roles">
36 <table att-table table-data="availableRoles" current-page="1">
37 <thead att-table-row type="header">
39 <th att-table-header width="70%">Name</th>
40 <th att-table-header width="10%">Priority</th>
41 <th att-table-header width="10%">Active?</th>
42 <th att-table-header width="10%">Delete?</th>
45 <tbody att-table-row type="body" row-repeat="availableRole in availableRoles" style="max-height: 980px;" ><!-- background colors will alternate not properly with multiple tbody-->
46 <!-- <tr ng-repeat="availableRole in availableRoles track by availableRole.id"> -->
48 <td width="70%"><a href="role.htm?role_id={{availableRole.id}}">{{ availableRole.name }}</a></td>
49 <td width="10%">{{ availableRole.priority }}</td>
51 <div ng-click="toggleRole(availableRole.active,availableRole);">
52 <input type="checkbox" ng-model="availableRole.active" att-toggle-main>
55 <td att-table-body width="10%">
56 <div ng-click="removeRole(availableRole);" style="font-size:20px;"><a href="javascript:void(0)" class="ion-trash-b"></a></div>
63 <div align="left" style="marin-bottom: 50px;">
64 <button type="submit" onClick="window.location='role.htm';" att-button
65 btn-type="primary" size="small">Create</button>
74 app.controller('roleListController', function ($scope,modalService){
76 $scope.availableRoles=${availableRoles};
77 //console.log($scope.availableRoles);
78 $scope.toggleRole = function(selected,availableRole) {
79 //alert('toggleRole: '+selected);
80 var toggleType = null;
82 toggleType = "activate";
84 toggleType = "inactivate";
87 modalService.popupConfirmWinWithCancel("Confirm","You are about to "+toggleType+" the test role "+availableRole.name+". Do you want to continue?",
89 var uuu = "role_list/toggleRole";
91 var postData={role:availableRole};
96 contentType: 'application/json',
97 data: JSON.stringify(postData),
98 success : function(data){
100 $scope.$apply(function(){$scope.availableRoles=data.availableRoles;});
101 console.log($scope.availableRoles);
103 error : function(data){
105 modalService.showFailure("Fail","Error while saving.");
111 availableRole.active=!availableRole.active;
116 $scope.removeRole = function(role) {
117 modalService.popupConfirmWin("Confirm","You are about to delete the role "+role.name+". Do you want to continue?",
119 var uuu = "role_list/removeRole";
120 var postData={role:role};
125 contentType: 'application/json',
126 data: JSON.stringify(postData),
127 success : function(data){
128 $scope.$apply(function(){$scope.availableRoles=data.availableRoles;});
130 error : function(data){
132 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);