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('varbindDictGridController', function ($scope, PolicyAppService, modalService, $modal){
21 $( "#dialog" ).hide();
23 PolicyAppService.getData('getDictionary/get_VarbindDictionaryData').then(function (data) {
25 $scope.data = JSON.parse(j.data);
26 console.log($scope.data);
27 $scope.varbindDictionaryDatas = JSON.parse($scope.data.varbindDictionaryDatas);
28 console.log($scope.varbindDictionaryDatas);
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.varbindDictionaryGrid.columnDefs[0].visible = false;
39 $scope.gridApi.grid.refresh();
41 $scope.varbindDictionaryGrid.columnDefs[0].visible = true;
42 $scope.gridApi.grid.refresh();
45 console.log("failed");
48 $scope.varbindDictionaryGrid = {
49 data : 'varbindDictionaryDatas',
50 enableFiltering: true,
51 exporterCsvFilename: 'VarbindDictionary.csv',
53 enableSelectAll: true,
55 field: 'id', enableFiltering: false, headerCellTemplate: '' +
56 '<button id=\'New\' ng-click="grid.appScope.createNewVarbindDictWindow()" class="btn btn-success">' + 'Create</button>',
58 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editVarbindDictWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
59 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteVarbindDictionary(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
61 { field: 'varbindName', displayName : 'Varbind Name', sort: { direction: 'asc', priority: 0 }},
62 { field: 'varbindDescription', displayName : 'Varbind Description'},
63 { field: 'varbindOID', displayName : 'Varbind OID'},
64 {field: 'userCreatedBy.userName', displayName : 'Created By'},
65 {field: 'userModifiedBy.userName', displayName : 'Modified By'},
66 {field: 'createdDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' },
67 {field: 'modifiedDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' }
69 exporterMenuPdf: false,
70 exporterPdfDefaultStyle: {fontSize: 9},
71 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
72 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
73 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
74 exporterPdfFooter: function ( currentPage, pageCount ) {
75 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
77 exporterPdfCustomFormatter: function ( docDefinition ) {
78 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
79 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
82 exporterPdfOrientation: 'portrait',
83 exporterPdfPageSize: 'LETTER',
84 exporterPdfMaxGridWidth: 500,
85 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
86 onRegisterApi: function(gridApi){
87 $scope.gridApi = gridApi;
91 $scope.editCLVarbind = null;
92 $scope.createNewVarbindDictWindow = function(){
93 $scope.editCLVarbind = null;
94 var modalInstance = $modal.open({
95 backdrop: 'static', keyboard: false,
96 templateUrl : 'add_varbind_popup.html',
97 controller: 'editCLVarbindController',
99 message: function () {
101 varbindDictionaryDatas: $scope.editCLVarbind
107 modalInstance.result.then(function(response){
108 console.log('response', response);
109 $scope.varbindDictionaryDatas=response.varbindDictionaryDatas;
113 $scope.editVarbindDictWindow = function(varbindDictionaryData) {
114 $scope.editCLVarbind = varbindDictionaryData;
115 var modalInstance = $modal.open({
116 backdrop: 'static', keyboard: false,
117 templateUrl : 'add_varbind_popup.html',
118 controller: 'editCLVarbindController',
120 message: function () {
122 varbindDictionaryData: $scope.editCLVarbind
128 modalInstance.result.then(function(response){
129 console.log('response', response);
130 $scope.varbindDictionaryDatas = response.varbindDictionaryDatas;
134 $scope.deleteVarbindDictionary = function(data) {
135 var uuu = "searchDictionary";
136 var postData={data: data, type: "clVarbind"};
137 var searchString = "\n";
142 contentType: 'application/json',
143 data: JSON.stringify(postData),
144 success : function(resultList){
145 $scope.$apply(function(){
146 $scope.list =resultList.result;});
147 $scope.searchData = JSON.stringify(resultList.result);
148 $scope.searchDatas = JSON.parse($scope.searchData);
149 $scope.success = true;
151 if($scope.searchDatas.length > 0){
152 for(i = 0 ; i < $scope.searchDatas.length; i++){
153 searchString += $scope.searchDatas[i].name + "\n";
156 searchString += "No Policies is Using this Value"
159 console.log($scope.list);
161 modalService.popupConfirmWin("Confirm","You are about to delete the Varbind Dictionary "+data.varbindName+". \n "+searchString+" \n Do you want to continue?",
163 var uuu = "deleteDictionary/cl_dictionary/remove_varbindDict";
164 var postData={data: data};
169 contentType: 'application/json',
170 data: JSON.stringify(postData),
171 success : function(data){
172 $scope.$apply(function(){$scope.varbindDictionaryDatas=data.varbindDictionaryDatas;});
174 error : function(data){
176 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);
182 error : function(data){
183 alert("Error while Searching.");