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('serviceListDictGridController', function ($scope, FWDictionaryService,modalService, $modal, PapUrlService){
24 $( "#dialog" ).hide();
27 PapUrlService.getPapUrl().then(function(data) {
29 papUrl = config.PAP_URL;
32 FWDictionaryService.getServiceListDictionaryData(papUrl).then(function (data) {
34 $scope.data = JSON.parse(j.data);
35 console.log($scope.data);
36 $scope.serviceListDictionaryDatas = JSON.parse($scope.data.serviceListDictionaryDatas);
37 console.log($scope.serviceListDictionaryDatas);
39 console.log("failed");
42 FWDictionaryService.getProtocolListDictionaryData(papUrl).then(function (data) {
44 $scope.data = JSON.parse(j.data);
45 console.log($scope.data);
46 $scope.protocolListDictionaryDatas = JSON.parse($scope.data.protocolListDictionaryDatas);
47 console.log($scope.protocolListDictionaryDatas);
49 console.log("failed");
56 $scope.serviceListDictionaryGrid = {
57 data : 'serviceListDictionaryDatas',
58 enableFiltering: true,
59 exporterCsvFilename: 'ServiceList.csv',
61 enableSelectAll: true,
63 field: 'id', enableFiltering: false, headerCellTemplate: '' +
64 '<button id=\'New\' ng-click="grid.appScope.createNewFWServiceListWindow()" class="btn btn-success">' + 'Create</button>',
66 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editFWServiceListWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
67 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteFWServiceList(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
68 },{ field: 'serviceName', displayName : 'Service Name'},
69 { field: 'serviceDescription' , displayName : 'Description'},
70 {field: 'serviceType', displayName : 'Service Type' },
71 {field: 'serviceTransProtocol', displayName : 'Transport Protocol'},
72 {field: 'serviceAppProtocol',displayName : 'APP Protocol' },
73 {field: 'servicePorts',displayName : 'Ports' }
75 exporterPdfDefaultStyle: {fontSize: 9},
76 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
77 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
78 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
79 exporterPdfFooter: function ( currentPage, pageCount ) {
80 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
82 exporterPdfCustomFormatter: function ( docDefinition ) {
83 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
84 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
87 exporterPdfOrientation: 'portrait',
88 exporterPdfPageSize: 'LETTER',
89 exporterPdfMaxGridWidth: 500,
90 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
91 onRegisterApi: function(gridApi){
92 $scope.gridApi = gridApi;
96 $scope.editServiceList = null;
97 $scope.createNewFWServiceListWindow = function(){
98 $scope.editServiceList = null;
99 var modalInstance = $modal.open({
100 backdrop: 'static', keyboard: false,
101 templateUrl : 'add_FWServiceList_popup.html',
102 controller: 'editFWServiceListController',
104 message: function () {
106 serviceListDictionaryDatas: $scope.editServiceList
112 modalInstance.result.then(function(response){
113 console.log('response', response);
114 $scope.serviceListDictionaryDatas=response.serviceListDictionaryDatas;
118 $scope.editFWServiceListWindow = function(serviceListDictionaryData) {
119 $scope.editServiceList = serviceListDictionaryData;
120 var modalInstance = $modal.open({
121 backdrop: 'static', keyboard: false,
122 templateUrl : 'add_FWServiceList_popup.html',
123 controller: 'editFWServiceListController',
125 message: function () {
127 serviceListDictionaryData: $scope.editServiceList
133 modalInstance.result.then(function(response){
134 console.log('response', response);
135 $scope.serviceListDictionaryDatas = response.serviceListDictionaryDatas;
139 $scope.deleteFWServiceList = function(data) {
140 modalService.popupConfirmWin("Confirm","You are about to delete the Service List "+data.serviceName+". Do you want to continue?",
142 var uuu = papUrl + "/ecomp/fw_dictionary/remove_serviceList.htm";
143 var postData={data: data};
148 contentType: 'application/json',
149 data: JSON.stringify(postData),
150 success : function(data){
151 $scope.$apply(function(){$scope.serviceListDictionaryDatas=data.serviceListDictionaryDatas;});
153 error : function(data){
155 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);