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