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('prefixListDictGridController', function ($scope, PolicyAppService, modalService, $modal){
21 $( "#dialog" ).hide();
23 PolicyAppService.getData('getDictionary/get_PrefixListData').then(function (data) {
25 $scope.data = JSON.parse(j.data);
26 console.log($scope.data);
27 $scope.prefixListDictionaryDatas = JSON.parse($scope.data.prefixListDictionaryDatas);
28 console.log($scope.prefixListDictionaryDatas);
30 console.log("failed");
33 PolicyAppService.getData('get_LockDownData').then(function(data){
35 $scope.data = JSON.parse(j.data);
36 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
37 if($scope.lockdowndata[0].lockdown == true){
38 $scope.prefixListDictionaryGrid.columnDefs[0].visible = false;
39 $scope.gridApi.grid.refresh();
41 $scope.prefixListDictionaryGrid.columnDefs[0].visible = true;
42 $scope.gridApi.grid.refresh();
45 console.log("failed");
48 $scope.prefixListDictionaryGrid = {
49 data : 'prefixListDictionaryDatas',
50 enableFiltering: true,
51 exporterCsvFilename: 'PrefixList.csv',
53 enableSelectAll: true,
55 field: 'id', enableFiltering: false, headerCellTemplate: '' +
56 '<button id=\'New\' ng-click="grid.appScope.createNewFWPrefixListWindow()" class="btn btn-success">' + 'Create</button>',
58 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editFWPrefixListWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
59 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteFWPrefixList(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
60 },{ field: 'prefixListName', displayName : 'PrefixList Name', sort: { direction: 'asc', priority: 0 }},
61 { field: 'description' },
62 {field: 'prefixListValue', displayName : 'PrefixList Value' }
64 exporterMenuPdf: false,
65 exporterPdfDefaultStyle: {fontSize: 9},
66 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
67 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
68 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
69 exporterPdfFooter: function ( currentPage, pageCount ) {
70 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
72 exporterPdfCustomFormatter: function ( docDefinition ) {
73 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
74 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
77 exporterPdfOrientation: 'portrait',
78 exporterPdfPageSize: 'LETTER',
79 exporterPdfMaxGridWidth: 500,
80 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
81 onRegisterApi: function(gridApi){
82 $scope.gridApi = gridApi;
87 $scope.editPrefixList = null;
88 $scope.createNewFWPrefixListWindow = function(){
89 $scope.editPrefixList = null;
90 var modalInstance = $modal.open({
91 backdrop: 'static', keyboard: false,
92 templateUrl : 'add_FWPrefixList_popup.html',
93 controller: 'editFWPrefixListController',
95 message: function () {
97 prefixListDictionaryDatas: $scope.editPrefixList
103 modalInstance.result.then(function(response){
104 console.log('response', response);
105 $scope.prefixListDictionaryDatas=response.prefixListDictionaryDatas;
109 $scope.editFWPrefixListWindow = function(prefixListDictionaryData) {
110 $scope.editPrefixList = prefixListDictionaryData;
111 var modalInstance = $modal.open({
112 backdrop: 'static', keyboard: false,
113 templateUrl : 'add_FWPrefixList_popup.html',
114 controller: 'editFWPrefixListController',
116 message: function () {
118 prefixListDictionaryData: $scope.editPrefixList
124 modalInstance.result.then(function(response){
125 console.log('response', response);
126 $scope.prefixListDictionaryDatas = response.prefixListDictionaryDatas;
130 $scope.deleteFWPrefixList = function(data) {
131 modalService.popupConfirmWin("Confirm","You are about to delete the Prefix List "+data.prefixListName+". Do you want to continue?",
133 var uuu = "deleteDictionary/fw_dictionary/remove_PrefixList";
134 var postData={data: data};
139 contentType: 'application/json',
140 data: JSON.stringify(postData),
141 success : function(data){
142 $scope.$apply(function(){$scope.prefixListDictionaryDatas=data.prefixListDictionaryDatas;});
144 error : function(data){
146 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);