2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017, 2019 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('pepOptionsDictGridController', function ($scope, PolicyAppService, modalService, $modal, Notification){
21 $( "#dialog" ).hide();
24 PolicyAppService.getData('getDictionary/get_PEPOptionsData').then(function (data) {
26 $scope.data = JSON.parse(j.data);
27 console.log($scope.data);
28 $scope.pepOptionsDictionaryDatas = JSON.parse($scope.data.pepOptionsDictionaryDatas);
29 console.log($scope.pepOptionsDictionaryDatas);
31 console.log("failed");
34 PolicyAppService.getData('get_LockDownData').then(function(data){
36 $scope.data = JSON.parse(j.data);
37 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
38 if($scope.lockdowndata[0].lockdown == true){
39 $scope.pepOptionsDictionaryGrid.columnDefs[0].visible = false;
40 $scope.gridApi.grid.refresh();
42 $scope.pepOptionsDictionaryGrid.columnDefs[0].visible = true;
43 $scope.gridApi.grid.refresh();
46 console.log("failed");
49 $scope.pepOptionsDictionaryGrid = {
50 data : 'pepOptionsDictionaryDatas',
51 enableFiltering: true,
52 exporterCsvFilename: 'PEPOptions.csv',
54 enableSelectAll: true,
56 field: 'id', enableFiltering: false, headerCellTemplate: '' +
57 '<button id=\'New\' ng-click="grid.appScope.createNewPEPOptionsWindow()" class="btn btn-success">' + 'Create</button>',
59 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editPEPOptionsWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
60 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deletePEPOptions(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
62 { field: 'pepName', displayName : 'PEP Name', sort: { direction: 'asc', priority: 0 }},
63 { field: 'actions', displayName : 'Actions'},
64 { field: 'description'},
65 {field: 'userCreatedBy.userName', displayName : 'Created By'},
66 {field: 'userModifiedBy.userName', displayName : 'Modified By'},
67 {field: 'createdDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' },
68 {field: 'modifiedDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' }
70 exporterMenuPdf: false,
71 exporterPdfDefaultStyle: {fontSize: 9},
72 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
73 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
74 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
75 exporterPdfFooter: function ( currentPage, pageCount ) {
76 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
78 exporterPdfCustomFormatter: function ( docDefinition ) {
79 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
80 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
83 exporterFieldCallback: function(grid, row, col, input) {
84 if( col.name == 'createdDate' || col.name == 'modifiedDate') {
85 var date = new Date(input);
86 return date.toString("yyyy-MM-dd HH:MM:ss a");
91 exporterPdfOrientation: 'portrait',
92 exporterPdfPageSize: 'LETTER',
93 exporterPdfMaxGridWidth: 500,
94 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
95 onRegisterApi: function(gridApi){
96 $scope.gridApi = gridApi;
100 $scope.editPEPOptions = null;
101 $scope.createNewPEPOptionsWindow = function(){
102 $scope.editOnapName = null;
103 var modalInstance = $modal.open({
104 backdrop: 'static', keyboard: false,
105 templateUrl : 'add_PEPOptions_popup.html',
106 controller: 'editPEPOptionsController',
108 message: function () {
110 pepOptionsDictionaryDatas: $scope.editPEPOptions
116 modalInstance.result.then(function(response){
117 console.log('response', response);
118 $scope.pepOptionsDictionaryDatas=response.pepOptionsDictionaryDatas;
122 $scope.editPEPOptionsWindow = function(pepOptionsDictionaryData) {
123 $scope.editPEPOptions = pepOptionsDictionaryData;
124 var modalInstance = $modal.open({
125 backdrop: 'static', keyboard: false,
126 templateUrl : 'add_PEPOptions_popup.html',
127 controller: 'editPEPOptionsController',
129 message: function () {
131 pepOptionsDictionaryData: $scope.editPEPOptions
137 modalInstance.result.then(function(response){
138 console.log('response', response);
139 $scope.pepOptionsDictionaryDatas = response.pepOptionsDictionaryDatas;
143 $scope.deletePEPOptions = function(data) {
144 var uuu = "searchDictionary";
145 var postData={data: data, type: "pepOptions"};
146 var searchString = "\n";
151 contentType: 'application/json',
152 data: JSON.stringify(postData),
153 success : function(resultList){
154 $scope.$apply(function(){
155 $scope.list =resultList.result;});
156 $scope.searchData = JSON.stringify(resultList.result);
157 $scope.searchDatas = JSON.parse($scope.searchData);
158 $scope.success = true;
160 if($scope.searchDatas.length > 0){
161 for(i = 0 ; i < $scope.searchDatas.length; i++){
162 searchString += $scope.searchDatas[i] + "\n";
165 searchString += "No Policies is Using this Value"
168 console.log($scope.list);
170 modalService.popupConfirmWin("Confirm","You are about to delete the PEP Options : "+data.pepName+". \n "+searchString+" \n Do you want to continue?",
172 var uuu = "deleteDictionary/cl_dictionary/remove_pepOptions";
173 var postData={data: data};
178 contentType: 'application/json',
179 data: JSON.stringify(postData),
180 success : function(data){
181 $scope.$apply(function(){$scope.pepOptionsDictionaryDatas=data.pepOptionsDictionaryDatas;});
183 error : function(data){
185 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);
191 error : function(data){
192 Notification.error("Error while Searching.");