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('zoneDictGridController', function ($scope, FWDictionaryService,modalService, $modal, PapUrlService){
24 $( "#dialog" ).hide();
27 PapUrlService.getPapUrl().then(function(data) {
29 papUrl = config.PAP_URL;
32 FWDictionaryService.getZoneDictionaryData(papUrl).then(function (data) {
34 $scope.data = JSON.parse(j.data);
35 console.log($scope.data);
36 $scope.zoneDictionaryDatas = JSON.parse($scope.data.zoneDictionaryDatas);
37 console.log($scope.zoneDictionaryDatas);
39 console.log("failed");
45 $scope.zoneDictionaryGrid = {
46 data : 'zoneDictionaryDatas',
47 enableFiltering: true,
48 exporterCsvFilename: 'Zone.csv',
50 enableSelectAll: true,
52 field: 'id', enableFiltering: false, headerCellTemplate: '' +
53 '<button id=\'New\' ng-click="grid.appScope.createNewFWZoneWindow()" class="btn btn-success">' + 'Create</button>',
55 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editFWZoneWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
56 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteFWZone(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
57 },{ field: 'zoneName', displayName : 'Zone Name'},
58 { field: 'zoneValue', displayName : 'Zone Value' }
60 exporterPdfDefaultStyle: {fontSize: 9},
61 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
62 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
63 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
64 exporterPdfFooter: function ( currentPage, pageCount ) {
65 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
67 exporterPdfCustomFormatter: function ( docDefinition ) {
68 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
69 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
72 exporterPdfOrientation: 'portrait',
73 exporterPdfPageSize: 'LETTER',
74 exporterPdfMaxGridWidth: 500,
75 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
76 onRegisterApi: function(gridApi){
77 $scope.gridApi = gridApi;
81 $scope.editZoneName = null;
82 $scope.createNewFWZoneWindow = function(){
83 $scope.editZoneName = null;
84 var modalInstance = $modal.open({
85 backdrop: 'static', keyboard: false,
86 templateUrl : 'add_FWZone_popup.html',
87 controller: 'editFWZoneController',
89 message: function () {
91 zoneDictionaryDatas: $scope.editZoneName
97 modalInstance.result.then(function(response){
98 console.log('response', response);
99 $scope.zoneDictionaryDatas=response.zoneDictionaryDatas;
103 $scope.editFWZoneWindow = function(zoneDictionaryData) {
104 $scope.editZoneName = zoneDictionaryData;
105 var modalInstance = $modal.open({
106 backdrop: 'static', keyboard: false,
107 templateUrl : 'add_FWZone_popup.html',
108 controller: 'editFWZoneController',
110 message: function () {
112 zoneDictionaryData: $scope.editZoneName
118 modalInstance.result.then(function(response){
119 console.log('response', response);
120 $scope.zoneDictionaryDatas = response.zoneDictionaryDatas;
124 $scope.deleteFWZone = function(data) {
125 modalService.popupConfirmWin("Confirm","You are about to delete the Zone Name "+data.zoneName+". Do you want to continue?",
127 var uuu = papUrl + "/ecomp/fw_dictionary/remove_zone.htm";
128 var postData={data: data};
133 contentType: 'application/json',
134 data: JSON.stringify(postData),
135 success : function(data){
136 $scope.$apply(function(){$scope.zoneDictionaryDatas=data.zoneDictionaryDatas;});
138 error : function(data){
140 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);