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('termListDictGridController', function ($scope, PolicyAppService, modalService, $modal){
21 $( "#dialog" ).hide();
23 PolicyAppService.getData('getDictionary/get_TermListData').then(function (data) {
25 $scope.data = JSON.parse(j.data);
26 console.log($scope.data);
27 $scope.termListDictionaryDatas = JSON.parse($scope.data.termListDictionaryDatas);
28 console.log($scope.termListDictionaryDatas);
30 console.log("failed");
33 PolicyAppService.getData('getDictionary/get_TagListData').then(function (data) {
35 $scope.data = JSON.parse(j.data);
36 console.log($scope.data);
37 $scope.fwTagDictionaryDatasByName = JSON.parse($scope.data.fwTagDictionaryDatas);
38 console.log($scope.fwTagDictionaryDatasByName);
40 console.log("failed");
43 PolicyAppService.getData('get_LockDownData').then(function(data){
45 $scope.data = JSON.parse(j.data);
46 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
47 if($scope.lockdowndata[0].lockdown == true){
48 $scope.termListDictionaryGrid.columnDefs[0].visible = false;
49 $scope.gridApi.grid.refresh();
51 $scope.termListDictionaryGrid.columnDefs[0].visible = true;
52 $scope.gridApi.grid.refresh();
55 console.log("failed");
58 $scope.termListDictionaryGrid = {
59 data : 'termListDictionaryDatas',
60 enableFiltering: true,
61 exporterCsvFilename: 'TermList.csv',
63 enableSelectAll: true,
65 field: 'id', enableFiltering: false, headerCellTemplate: '' +
66 '<button id=\'New\' ng-click="grid.appScope.createNewFWTermListWindow()" class="btn btn-success">' + 'Create</button>',
68 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editFWTermListWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
69 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteFWTermList(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
70 },{ field: 'termName', displayName : 'Term-Name', sort: { direction: 'asc', priority: 0 }},
71 { field: 'termDescription', displayName : 'Term-Description' },
72 { field: 'fromZone', displayName : 'From Zone' },
73 {field: 'toZone', displayName : 'To Zone' },
74 {field: 'srcIPList', displayName : 'Source-IP-List'},
75 {field: 'destIPList',displayName : 'Destination-IP-List' },
76 {field: 'srcPortList',displayName : 'Source-Port-List' },
77 {field: 'destPortList',displayName : 'Destination-Port-List' },
78 {field: 'action',displayName : 'Action List' },
79 {field: 'userCreatedBy.userName',displayName : 'Created By' },
80 {field: 'userModifiedBy.userName',displayName : 'Modified By'},
81 {field: 'createdDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' },
82 {field: 'modifiedDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' }
84 exporterMenuPdf: false,
85 exporterPdfDefaultStyle: {fontSize: 9},
86 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
87 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
88 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
89 exporterPdfFooter: function ( currentPage, pageCount ) {
90 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
92 exporterPdfCustomFormatter: function ( docDefinition ) {
93 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
94 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
97 exporterPdfOrientation: 'portrait',
98 exporterPdfPageSize: 'LETTER',
99 exporterPdfMaxGridWidth: 500,
100 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
101 onRegisterApi: function(gridApi){
102 $scope.gridApi = gridApi;
106 $scope.editTermList = null;
107 $scope.createNewFWTermListWindow = function(){
108 $scope.editTermList = null;
109 var modalInstance = $modal.open({
110 backdrop: 'static', keyboard: false,
111 templateUrl : 'add_fwTermList_popup.html',
112 controller: 'editFWTermListController',
114 message: function () {
116 termListDictionaryDatas: $scope.editTermList
122 modalInstance.result.then(function(response){
123 console.log('response', response);
124 $scope.termListDictionaryDatas=response.termListDictionaryDatas;
128 $scope.editFWTermListWindow = function(termListDictionaryData) {
129 $scope.editTermList = termListDictionaryData;
130 var modalInstance = $modal.open({
131 backdrop: 'static', keyboard: false,
132 templateUrl : 'add_fwTermList_popup.html',
133 controller: 'editFWTermListController',
135 message: function () {
137 termListDictionaryData: $scope.editTermList
143 modalInstance.result.then(function(response){
144 console.log('response', response);
145 $scope.termListDictionaryDatas = response.termListDictionaryDatas;
149 $scope.deleteFWTermList = function(data) {
150 modalService.popupConfirmWin("Confirm","You are about to delete the TermList "+data.termName+". Do you want to continue?",
152 var uuu = "deleteDictionary/fw_dictionary/remove_termList";
153 var postData={data: data};
158 contentType: 'application/json',
159 data: JSON.stringify(postData),
160 success : function(data){
161 $scope.$apply(function(){$scope.termListDictionaryDatas=data.termListDictionaryDatas;});
163 error : function(data){
165 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);