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=========================================================
23 app.controller('enforcerDictGridController', function ($scope, DictionaryService,modalService, $modal, PapUrlService){
24 $( "#dialog" ).hide();
27 PapUrlService.getPapUrl().then(function(data) {
29 papUrl = config.PAP_URL;
33 DictionaryService.getEnforcerDictionaryData(papUrl).then(function (data) {
35 $scope.data = JSON.parse(j.data);
36 console.log($scope.data);
37 $scope.enforcerDictionaryDatas = JSON.parse($scope.data.enforcerDictionaryDatas);
38 console.log($scope.enforcerDictionaryDatas);
40 console.log("failed");
45 $scope.enforcerDictionaryGrid = {
46 data : 'enforcerDictionaryDatas',
47 enableFiltering: true,
49 field: 'id', enableFiltering: false, headerCellTemplate: '' +
50 '<button id=\'New\' ng-click="grid.appScope.createNewEnforcerTypeWindow()" class="btn btn-success">' + 'Create</button>',
52 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editEnforcerTypeWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
53 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteEnforcerType(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
54 },{ field: 'enforcingType', displayName : 'Enforcing Type'},
55 { field: 'script' , displayName : 'Script'},
56 {field: 'connectionQuery', displayName : 'Connection Query' },
57 {field: 'valueQuery', displayName : 'Value Query'}
61 $scope.editEnforcerType = null;
62 $scope.createNewEnforcerTypeWindow = function(){
63 $scope.editEnforcerType = null;
64 var modalInstance = $modal.open({
65 backdrop: 'static', keyboard: false,
66 templateUrl : 'add_EnforcerType_popup.html',
67 controller: 'editEnforcerTypeController',
69 message: function () {
71 enforcerDictionaryDatas: $scope.editEnforcerType
77 modalInstance.result.then(function(response){
78 console.log('response', response);
79 $scope.enforcerDictionaryDatas=response.enforcerDictionaryDatas;
83 $scope.editEnforcerTypeWindow = function(enforcerDictionaryData) {
84 $scope.editEnforcerType = enforcerDictionaryData;
85 var modalInstance = $modal.open({
86 backdrop: 'static', keyboard: false,
87 templateUrl : 'add_EnforcerType_popup.html',
88 controller: 'editEnforcerTypeController',
90 message: function () {
92 enforcerDictionaryData: $scope.editEnforcerType
98 modalInstance.result.then(function(response){
99 console.log('response', response);
100 $scope.enforcerDictionaryDatas = response.enforcerDictionaryDatas;
104 $scope.deleteEnforcerType = function(data) {
105 modalService.popupConfirmWin("Confirm","You are about to delete the Enforcing Type "+data.enforcingType+". Do you want to continue?",
107 var uuu = papUrl + "/ecomp/enforcer_dictionary/remove_enforcer.htm";
108 var postData={data: data};
113 contentType: 'application/json',
114 data: JSON.stringify(postData),
115 success : function(data){
116 $scope.$apply(function(){$scope.enforcerDictionaryDatas=data.enforcerDictionaryDatas;});
118 error : function(data){
120 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);