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('securityZoneDictGridController', function ($scope, PolicyAppService, modalService, $modal){
21 $( "#dialog" ).hide();
23 PolicyAppService.getData('getDictionary/get_SecurityZoneData').then(function (data) {
25 $scope.data = JSON.parse(j.data);
26 console.log($scope.data);
27 $scope.securityZoneDictionaryDatas = JSON.parse($scope.data.securityZoneDictionaryDatas);
28 console.log($scope.securityZoneDictionaryDatas);
30 console.log("failed");
33 PolicyAppService.getData('get_LockDownData').then(function(data){
35 $scope.data = JSON.parse(j.data);
36 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
37 if($scope.lockdowndata[0].lockdown == true){
38 $scope.securityZoneDictionaryGrid.columnDefs[0].visible = false;
39 $scope.gridApi.grid.refresh();
41 $scope.securityZoneDictionaryGrid.columnDefs[0].visible = true;
42 $scope.gridApi.grid.refresh();
45 console.log("failed");
48 $scope.securityZoneDictionaryGrid = {
49 data : 'securityZoneDictionaryDatas',
50 enableFiltering: true,
51 exporterCsvFilename: 'SecurityZone.csv',
53 enableSelectAll: true,
55 field: 'id', enableFiltering: false, headerCellTemplate: '' +
56 '<button id=\'New\' ng-click="grid.appScope.createNewFWSecurityZoneWindow()" class="btn btn-success">' + 'Create</button>',
58 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editFWSecurityZoneWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
59 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteFWSecurityZone(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
60 },{ field: 'zoneName', displayName : 'Zone Name', sort: { direction: 'asc', priority: 0 }},
61 { field: 'zoneValue', displayName : 'Zone Value' }
63 exporterMenuPdf: false,
64 exporterPdfDefaultStyle: {fontSize: 9},
65 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
66 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
67 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
68 exporterPdfFooter: function ( currentPage, pageCount ) {
69 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
71 exporterPdfCustomFormatter: function ( docDefinition ) {
72 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
73 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
76 exporterPdfOrientation: 'portrait',
77 exporterPdfPageSize: 'LETTER',
78 exporterPdfMaxGridWidth: 500,
79 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
80 onRegisterApi: function(gridApi){
81 $scope.gridApi = gridApi;
85 $scope.editSecurityZone = null;
86 $scope.createNewFWSecurityZoneWindow = function(){
87 $scope.editSecurityZone = null;
88 var modalInstance = $modal.open({
89 backdrop: 'static', keyboard: false,
90 templateUrl : 'add_fwSecurityZone_popup.html',
91 controller: 'editfwSecurityZoneController',
93 message: function () {
95 securityZoneDictionaryDatas: $scope.editSecurityZone
101 modalInstance.result.then(function(response){
102 console.log('response', response);
103 $scope.securityZoneDictionaryDatas=response.securityZoneDictionaryDatas;
107 $scope.editFWSecurityZoneWindow = function(securityZoneDictionaryData) {
108 $scope.editSecurityZone = securityZoneDictionaryData;
109 var modalInstance = $modal.open({
110 backdrop: 'static', keyboard: false,
111 templateUrl : 'add_fwSecurityZone_popup.html',
112 controller: 'editfwSecurityZoneController',
114 message: function () {
116 securityZoneDictionaryData: $scope.editSecurityZone
122 modalInstance.result.then(function(response){
123 console.log('response', response);
124 $scope.securityZoneDictionaryDatas = response.securityZoneDictionaryDatas;
128 $scope.deleteFWSecurityZone = function(data) {
129 modalService.popupConfirmWin("Confirm","You are about to delete the Security Zone "+data.zoneName+". Do you want to continue?",
131 var uuu = "deleteDictionary/fw_dictionary/remove_securityZone";
132 var postData={data: data};
137 contentType: 'application/json',
138 data: JSON.stringify(postData),
139 success : function(data){
140 $scope.$apply(function(){$scope.securityZoneDictionaryDatas=data.securityZoneDictionaryDatas;});
142 error : function(data){
144 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);