2 * ============LICENSE_START=======================================================
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
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 * ============LICENSE_END=========================================================
20 app.controller('enforcerDictGridController', function ($scope, PolicyAppService,modalService, $modal){
21 $( "#dialog" ).hide();
23 PolicyAppService.getData('getDictionary/get_EnforcerTypeData').then(function (data) {
25 $scope.data = JSON.parse(j.data);
26 console.log($scope.data);
27 $scope.enforcerDictionaryDatas = JSON.parse($scope.data.enforcerDictionaryDatas);
28 console.log($scope.enforcerDictionaryDatas);
30 console.log("failed");
33 $scope.enforcerDictionaryGrid = {
34 data : 'enforcerDictionaryDatas',
35 enableFiltering: true,
37 field: 'id', enableFiltering: false, headerCellTemplate: '' +
38 '<button id=\'New\' ng-click="grid.appScope.createNewEnforcerTypeWindow()" class="btn btn-success">' + 'Create</button>',
40 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editEnforcerTypeWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
41 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteEnforcerType(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
42 },{ field: 'enforcingType', displayName : 'Enforcing Type', sort: { direction: 'asc', priority: 0 }},
43 { field: 'script' , displayName : 'Script'},
44 {field: 'connectionQuery', displayName : 'Connection Query' },
45 {field: 'valueQuery', displayName : 'Value Query'}
49 $scope.editEnforcerType = null;
50 $scope.createNewEnforcerTypeWindow = function(){
51 $scope.editEnforcerType = null;
52 var modalInstance = $modal.open({
53 backdrop: 'static', keyboard: false,
54 templateUrl : 'add_EnforcerType_popup.html',
55 controller: 'editEnforcerTypeController',
57 message: function () {
59 enforcerDictionaryDatas: $scope.editEnforcerType
65 modalInstance.result.then(function(response){
66 console.log('response', response);
67 $scope.enforcerDictionaryDatas=response.enforcerDictionaryDatas;
71 $scope.editEnforcerTypeWindow = function(enforcerDictionaryData) {
72 $scope.editEnforcerType = enforcerDictionaryData;
73 var modalInstance = $modal.open({
74 backdrop: 'static', keyboard: false,
75 templateUrl : 'add_EnforcerType_popup.html',
76 controller: 'editEnforcerTypeController',
78 message: function () {
80 enforcerDictionaryData: $scope.editEnforcerType
86 modalInstance.result.then(function(response){
87 console.log('response', response);
88 $scope.enforcerDictionaryDatas = response.enforcerDictionaryDatas;
92 $scope.deleteEnforcerType = function(data) {
93 modalService.popupConfirmWin("Confirm","You are about to delete the Enforcing Type "+data.enforcingType+". Do you want to continue?",
95 var uuu = "deleteDictionary/enforcer_dictionary/remove_enforcer";
96 var postData={data: data};
101 contentType: 'application/json',
102 data: JSON.stringify(postData),
103 success : function(data){
104 $scope.$apply(function(){$scope.enforcerDictionaryDatas=data.enforcerDictionaryDatas;});
106 error : function(data){
108 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);