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('termListDictGridController', function ($scope, FWDictionaryService,modalService, $modal, PapUrlService){
24 $( "#dialog" ).hide();
27 PapUrlService.getPapUrl().then(function(data) {
29 papUrl = config.PAP_URL;
32 FWDictionaryService.getTermListDictionaryData(papUrl).then(function (data) {
34 $scope.data = JSON.parse(j.data);
35 console.log($scope.data);
36 $scope.termListDictionaryDatas = JSON.parse($scope.data.termListDictionaryDatas);
37 console.log($scope.termListDictionaryDatas);
39 console.log("failed");
45 $scope.termListDictionaryGrid = {
46 data : 'termListDictionaryDatas',
47 enableFiltering: true,
48 exporterCsvFilename: 'TermList.csv',
50 enableSelectAll: true,
52 field: 'id', enableFiltering: false, headerCellTemplate: '' +
53 '<button id=\'New\' ng-click="grid.appScope.createNewFWTermListWindow()" class="btn btn-success">' + 'Create</button>',
55 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editFWTermListWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
56 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteFWTermList(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
57 },{ field: 'termName', displayName : 'Term-Name'},
58 { field: 'termDescription', displayName : 'Term-Description' },
59 { field: 'fromZone', displayName : 'From Zone' },
60 {field: 'toZone', displayName : 'To Zone' },
61 {field: 'srcIPList', displayName : 'Source-IP-List'},
62 {field: 'destIPList',displayName : 'Destination-IP-List' },
63 {field: 'srcPortList',displayName : 'Source-Port-List' },
64 {field: 'destPortList',displayName : 'Destination-Port-List' },
65 {field: 'action',displayName : 'Action List' },
66 {field: 'userCreatedBy.userName',displayName : 'Created By' },
67 {field: 'userModifiedBy.userName',displayName : 'Modified By'},
68 {field: 'createdDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' },
69 {field: 'modifiedDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' }
71 exporterPdfDefaultStyle: {fontSize: 9},
72 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
73 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
74 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
75 exporterPdfFooter: function ( currentPage, pageCount ) {
76 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
78 exporterPdfCustomFormatter: function ( docDefinition ) {
79 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
80 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
83 exporterPdfOrientation: 'portrait',
84 exporterPdfPageSize: 'LETTER',
85 exporterPdfMaxGridWidth: 500,
86 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
87 onRegisterApi: function(gridApi){
88 $scope.gridApi = gridApi;
92 $scope.editTermList = null;
93 $scope.createNewFWTermListWindow = function(){
94 $scope.editTermList = null;
95 var modalInstance = $modal.open({
96 backdrop: 'static', keyboard: false,
97 templateUrl : 'add_fwTermList_popup.html',
98 controller: 'editFWTermListController',
100 message: function () {
102 termListDictionaryDatas: $scope.editTermList
108 modalInstance.result.then(function(response){
109 console.log('response', response);
110 $scope.termListDictionaryDatas=response.termListDictionaryDatas;
114 $scope.editFWTermListWindow = function(termListDictionaryData) {
115 $scope.editTermList = termListDictionaryData;
116 var modalInstance = $modal.open({
117 backdrop: 'static', keyboard: false,
118 templateUrl : 'add_fwTermList_popup.html',
119 controller: 'editFWTermListController',
121 message: function () {
123 termListDictionaryData: $scope.editTermList
129 modalInstance.result.then(function(response){
130 console.log('response', response);
131 $scope.termListDictionaryDatas = response.termListDictionaryDatas;
135 $scope.deleteFWTermList = function(data) {
136 modalService.popupConfirmWin("Confirm","You are about to delete the TermList "+data.termName+". Do you want to continue?",
138 var uuu = papUrl + "/ecomp/fw_dictionary/remove_termList.htm";
139 var postData={data: data};
144 contentType: 'application/json',
145 data: JSON.stringify(postData),
146 success : function(data){
147 $scope.$apply(function(){$scope.termListDictionaryDatas=data.termListDictionaryDatas;});
149 error : function(data){
151 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);