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('prefixListDictGridController', function ($scope, FWDictionaryService,modalService, $modal, PapUrlService){
24 $( "#dialog" ).hide();
27 PapUrlService.getPapUrl().then(function(data) {
29 papUrl = config.PAP_URL;
32 FWDictionaryService.getPrefixListDictionaryData(papUrl).then(function (data) {
34 $scope.data = JSON.parse(j.data);
35 console.log($scope.data);
36 $scope.prefixListDictionaryDatas = JSON.parse($scope.data.prefixListDictionaryDatas);
37 console.log($scope.prefixListDictionaryDatas);
39 console.log("failed");
44 $scope.prefixListDictionaryGrid = {
45 data : 'prefixListDictionaryDatas',
46 enableFiltering: true,
47 exporterCsvFilename: 'PrefixList.csv',
49 enableSelectAll: true,
51 field: 'id', enableFiltering: false, headerCellTemplate: '' +
52 '<button id=\'New\' ng-click="grid.appScope.createNewFWPrefixListWindow()" class="btn btn-success">' + 'Create</button>',
54 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editFWPrefixListWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
55 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteFWPrefixList(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
56 },{ field: 'prefixListName', displayName : 'PrefixList Name'},
57 { field: 'description' },
58 {field: 'prefixListValue', displayName : 'PrefixList 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;
82 $scope.editPrefixList = null;
83 $scope.createNewFWPrefixListWindow = function(){
84 $scope.editPrefixList = null;
85 var modalInstance = $modal.open({
86 backdrop: 'static', keyboard: false,
87 templateUrl : 'add_FWPrefixList_popup.html',
88 controller: 'editFWPrefixListController',
90 message: function () {
92 prefixListDictionaryDatas: $scope.editPrefixList
98 modalInstance.result.then(function(response){
99 console.log('response', response);
100 $scope.prefixListDictionaryDatas=response.prefixListDictionaryDatas;
104 $scope.editFWPrefixListWindow = function(prefixListDictionaryData) {
105 $scope.editPrefixList = prefixListDictionaryData;
106 var modalInstance = $modal.open({
107 backdrop: 'static', keyboard: false,
108 templateUrl : 'add_FWPrefixList_popup.html',
109 controller: 'editFWPrefixListController',
111 message: function () {
113 prefixListDictionaryData: $scope.editPrefixList
119 modalInstance.result.then(function(response){
120 console.log('response', response);
121 $scope.prefixListDictionaryDatas = response.prefixListDictionaryDatas;
125 $scope.deleteFWPrefixList = function(data) {
126 modalService.popupConfirmWin("Confirm","You are about to delete the Prefix List "+data.prefixListName+". Do you want to continue?",
128 var uuu = papUrl + "/ecomp/fw_dictionary/remove_PrefixList.htm";
129 var postData={data: data};
134 contentType: 'application/json',
135 data: JSON.stringify(postData),
136 success : function(data){
137 $scope.$apply(function(){$scope.prefixListDictionaryDatas=data.prefixListDictionaryDatas;});
139 error : function(data){
141 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);