nexus site path corrected
[portal.git] / ecomp-portal-BE / war / WEB-INF / fusion / jsp / role_list.jsp
1 <%--
2   ================================================================================
3   eCOMP Portal
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
10   
11        http://www.apache.org/licenses/LICENSE-2.0
12   
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   ================================================================================
19   --%>
20
21 <%-- <%@ include file="/WEB-INF/fusion/jsp/include.jsp" %> --%>
22
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
27 <script src= "static/ebz/angular_js/angular.js"></script> 
28 <script src= "static/ebz/angular_js/angular-sanitize.js"></script>
29 <script src= "static/ebz/angular_js/att_abs_tpls.js"></script>
30 <script src= "static/ebz/angular_js/app.js"></script>
31 <script src= "static/ebz/angular_js/gestures.js"></script>
32
33 <script src="static/js/jquery-1.10.2.js"></script>
34 <script src="static/js/modalService.js"></script>
35 <script src="static/js/jquery.mask.min.js" type="text/javascript"></script>
36 <script src="static/js/jquery-ui.js" type="text/javascript"></script>
37
38 <div class="pageTitle">
39         <h1 class="heading1" style="margin-top:20px;">Roles</h1>
40 </div>
41 <br>
42 Click on a Role to view its details.
43      
44 <div ng-controller="roleListController" >       
45         <div id="dialog" title="Roles">
46           <table att-table table-data="availableRoles" current-page="1">
47                 <thead att-table-row type="header">
48                         <tr>
49                                 <th att-table-header width="70%">Name</th>
50                                 <th att-table-header width="10%">Priority</th>
51                                 <th att-table-header width="10%">Active?</th>
52                                 <th att-table-header width="10%">Delete?</th>
53                         </tr>
54                 </thead>
55                 <tbody att-table-row type="body" row-repeat="availableRole in availableRoles track by availableRole.id" style="max-height: 980px;" ><!-- background colors will alternate not properly with multiple tbody-->
56 <!--              <tr ng-repeat="availableRole in availableRoles track by availableRole.id">                     -->
57                   <tr>
58                     <td width="70%"><a href="role.htm?role_id={{availableRole.id}}">{{ availableRole.name }}</a></td>
59                     <td width="10%">{{ availableRole.priority }}</td>
60                     <td width="10%">
61                         <div ng-click="toggleRole(availableRole.active,availableRole);">
62                         <input type="checkbox" ng-model="availableRole.active" att-toggle-main>
63                         </div>
64                     </td>
65                      <td att-table-body width="10%">
66                         <div ng-click="removeRole(availableRole);" style="font-size:20px;"><a href="javascript:void(0)" class="icon-trash"></a></div>
67                      </td>
68                   </tr>
69                 </tbody>
70                 </table>
71         </div>
72         
73         <div align="left" style="marin-bottom: 50px;">
74                 <button type="submit" onClick="window.location='role.htm';" att-button
75                         btn-type="primary" size="small">Create</button>
76         </div>
77         
78 </div>
79
80
81
82
83 <script>
84 app.controller('roleListController', function ($scope){
85         
86         $scope.availableRoles=${availableRoles};
87         //console.log($scope.availableRoles);
88                 $scope.toggleRole = function(selected,availableRole) {
89                                 //alert('toggleRole: '+selected);
90                                 var toggleType = null;
91                                 if(selected) {
92                                         toggleType = "activate";
93                                 } else {
94                                         toggleType = "inactivate";
95                                 }
96                                 
97                                 if (confirm("You are about to "+toggleType+" the test role "+availableRole.name+". Do you want to continue?")) {
98
99                                         var uuu = "role_list/toggleRole";
100                                         
101                                         var postData={role:availableRole};
102                                           $.ajax({
103                                                  type : 'POST',
104                                                  url : uuu,
105                                                  dataType: 'json',
106                                                  contentType: 'application/json',
107                                                  data: JSON.stringify(postData),
108                                                  success : function(data){
109                                                         console.log(data);
110                                                         $scope.$apply(function(){$scope.availableRoles=data.availableRoles;}); 
111                                                         console.log($scope.availableRoles);
112                                                  },
113                                                  error : function(data){
114                                                          console.log(data);
115                                                          alert("Error while saving. ");
116                                                  }
117                                           });
118                                 }                               
119                                   
120                 };
121
122                 $scope.removeRole = function(role) {
123                         if (confirm("You are about to delete the role "+role.name+". Do you want to continue?")) {
124                                 //alert('deleted'+role.name);
125                                 var uuu = "role_list/removeRole";
126                                   var postData={role:role};
127                                   $.ajax({
128                                          type : 'POST',
129                                          url : uuu,
130                                          dataType: 'json',
131                                          contentType: 'application/json',
132                                          data: JSON.stringify(postData),
133                                          success : function(data){
134                                                 $scope.$apply(function(){$scope.availableRoles=data.availableRoles;});  
135                                          },
136                                          error : function(data){
137                                                  console.log(data);
138                                                  alert("Error while deleting: "+ data.responseText);
139                                          }
140                                   });
141                         }
142                         
143                 };
144                 
145
146 });
147 </script>