ddd6b232c19629c441359e9f8170d9e477734efa
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / controller / PolicyRolesController.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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  * ============LICENSE_END=========================================================
19  */
20 app.controller('policyRolesController', function ($scope, PolicyAppService, modalService, $modal, Notification){
21     $( "#dialog" ).hide();
22     
23     $scope.isDisabled = true;
24     
25     PolicyAppService.getData('get_LockDownData').then(function(data){
26                  var j = data;
27                  $scope.data = JSON.parse(j.data);
28                  $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
29                  if($scope.lockdowndata[0].lockdown == true){
30                          $scope.isDisabled = true;
31                  }else{
32                          $scope.isDisabled = false;
33                  }
34                  console.log($scope.data);
35          },function(error){
36                  console.log("failed");
37          });
38          
39     $scope.scopeDatas = [];
40     PolicyAppService.getData('get_RolesData').then(function (data) {
41         var j = data;
42         $scope.data = JSON.parse(j.data);
43         console.log($scope.data);
44         $scope.rolesDatas = JSON.parse($scope.data.rolesDatas);
45         console.log($scope.rolesDatas);
46     }, function (error) {
47         console.log("failed");
48     });
49
50     $scope.rolesTableGrid = {
51         data : 'rolesDatas',
52         enableFiltering: true,
53         columnDefs: [{
54             field: 'id', enableFiltering: false, 
55             cellTemplate:
56             '<button  type="button"  class="btn btn-primary"  ng-click="grid.appScope.editRolesWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button>' ,  width: '4%'
57         },
58         { field: 'loginId.userName', displayName : 'Name', sort: { direction: 'asc', priority: 0 }},
59         { field: 'scope', displayName : 'Scope' },
60         { field: 'role', displayName : 'Role' }
61         ]
62     };
63
64
65     $scope.editRoleName = null;
66    
67     $scope.editRolesWindow = function(editRoleData) {
68         if($scope.lockdowndata[0].lockdown == true){
69                 Notification.error("Policy Application has been Locked")
70         }else{
71                 $scope.editRoleName = editRoleData;
72                 var modalInstance = $modal.open({
73                         backdrop: 'static', keyboard: false,
74                         templateUrl : 'edit_Role_popup.html',
75                         controller: 'editRoleController',
76                         resolve: {
77                                 message: function () {
78                                         var message = {
79                                                         editRoleData: $scope.editRoleName
80                                         };
81                                         return message;
82                                 }
83                         }
84                 });
85                 modalInstance.result.then(function(response){
86                         console.log('response', response);
87                 });
88         }
89        
90     };
91
92 });