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