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('serviceListDictGridController', function ($scope, PolicyAppService, modalService, $modal){
21 $( "#dialog" ).hide();
23 PolicyAppService.getData('getDictionary/get_ServiceListData').then(function (data) {
25 $scope.data = JSON.parse(j.data);
26 console.log($scope.data);
27 $scope.serviceListDictionaryDatas = JSON.parse($scope.data.serviceListDictionaryDatas);
28 console.log($scope.serviceListDictionaryDatas);
30 console.log("failed");
33 PolicyAppService.getData('getDictionary/get_ProtocolListData').then(function (data) {
35 $scope.data = JSON.parse(j.data);
36 console.log($scope.data);
37 $scope.protocolListDictionaryDatas = JSON.parse($scope.data.protocolListDictionaryDatas);
38 console.log($scope.protocolListDictionaryDatas);
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.serviceListDictionaryGrid.columnDefs[0].visible = false;
49 $scope.gridApi.grid.refresh();
51 $scope.serviceListDictionaryGrid.columnDefs[0].visible = true;
52 $scope.gridApi.grid.refresh();
55 console.log("failed");
58 $scope.serviceListDictionaryGrid = {
59 data : 'serviceListDictionaryDatas',
60 enableFiltering: true,
61 exporterCsvFilename: 'ServiceList.csv',
63 enableSelectAll: true,
65 field: 'id', enableFiltering: false, headerCellTemplate: '' +
66 '<button id=\'New\' ng-click="grid.appScope.createNewFWServiceListWindow()" class="btn btn-success">' + 'Create</button>',
68 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editFWServiceListWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
69 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteFWServiceList(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
70 },{ field: 'serviceName', displayName : 'Service Name', sort: { direction: 'asc', priority: 0 }},
71 { field: 'serviceDescription' , displayName : 'Description'},
72 {field: 'serviceType', displayName : 'Service Type' },
73 {field: 'serviceTransProtocol', displayName : 'Transport Protocol'},
74 {field: 'serviceAppProtocol',displayName : 'APP Protocol' },
75 {field: 'servicePorts',displayName : 'Ports' }
77 exporterMenuPdf: false,
78 exporterPdfDefaultStyle: {fontSize: 9},
79 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
80 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
81 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
82 exporterPdfFooter: function ( currentPage, pageCount ) {
83 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
85 exporterPdfCustomFormatter: function ( docDefinition ) {
86 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
87 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
90 exporterPdfOrientation: 'portrait',
91 exporterPdfPageSize: 'LETTER',
92 exporterPdfMaxGridWidth: 500,
93 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
94 onRegisterApi: function(gridApi){
95 $scope.gridApi = gridApi;
99 $scope.editServiceList = null;
100 $scope.createNewFWServiceListWindow = function(){
101 $scope.editServiceList = null;
102 var modalInstance = $modal.open({
103 backdrop: 'static', keyboard: false,
104 templateUrl : 'add_FWServiceList_popup.html',
105 controller: 'editFWServiceListController',
107 message: function () {
109 serviceListDictionaryDatas: $scope.editServiceList
115 modalInstance.result.then(function(response){
116 console.log('response', response);
117 $scope.serviceListDictionaryDatas=response.serviceListDictionaryDatas;
121 $scope.editFWServiceListWindow = function(serviceListDictionaryData) {
122 $scope.editServiceList = serviceListDictionaryData;
123 var modalInstance = $modal.open({
124 backdrop: 'static', keyboard: false,
125 templateUrl : 'add_FWServiceList_popup.html',
126 controller: 'editFWServiceListController',
128 message: function () {
130 serviceListDictionaryData: $scope.editServiceList
136 modalInstance.result.then(function(response){
137 console.log('response', response);
138 $scope.serviceListDictionaryDatas = response.serviceListDictionaryDatas;
142 $scope.deleteFWServiceList = function(data) {
143 modalService.popupConfirmWin("Confirm","You are about to delete the Service List "+data.serviceName+". Do you want to continue?",
145 var uuu = "deleteDictionary/fw_dictionary/remove_serviceList";
146 var postData={data: data};
151 contentType: 'application/json',
152 data: JSON.stringify(postData),
153 success : function(data){
154 $scope.$apply(function(){$scope.serviceListDictionaryDatas=data.serviceListDictionaryDatas;});
156 error : function(data){
158 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);