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('brmsParamDictGridController', function ($scope, PolicyAppService,modalService, $modal){
21 $( "#dialog" ).hide();
23 PolicyAppService.getData('getDictionary/get_BRMSParamData').then(function (data) {
25 $scope.data = JSON.parse(j.data);
26 console.log($scope.data);
27 $scope.brmsParamDictionaryDatas = JSON.parse($scope.data.brmsParamDictionaryDatas);
28 console.log($scope.brmsParamDictionaryDatas);
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.brmsParamDictionaryGrid.columnDefs[0].visible = false;
39 $scope.gridApi.grid.refresh();
41 $scope.brmsParamDictionaryGrid.columnDefs[0].visible = true;
42 $scope.gridApi.grid.refresh();
45 console.log("failed");
48 $scope.brmsParamDictionaryGrid = {
49 data : 'brmsParamDictionaryDatas',
50 enableFiltering: true,
51 exporterCsvFilename: 'BRMSParamDictionary.csv',
53 enableSelectAll: true,
55 field: 'id', enableFiltering: false, headerCellTemplate: '' +
56 '<button id=\'New\' ng-click="grid.appScope.createNewBRMSParamWindow()" class="btn btn-success">' + 'Create</button>',
58 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteBRMSParam(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
60 { field: 'ruleName', displayName : 'Rule Name', sort: { direction: 'asc', priority: 0 }},
61 { field: 'description'},
62 {field: 'userCreatedBy.userName', displayName : 'Created By'},
63 {field: 'createdDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' }
65 exporterMenuPdf: false,
66 exporterPdfDefaultStyle: {fontSize: 9},
67 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
68 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
69 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
70 exporterPdfFooter: function ( currentPage, pageCount ) {
71 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
73 exporterPdfCustomFormatter: function ( docDefinition ) {
74 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
75 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
78 exporterFieldCallback: function(grid, row, col, input) {
79 if( col.name == 'createdDate' || col.name == 'modifiedDate') {
80 var date = new Date(input);
81 return date.toString("yyyy-MM-dd HH:MM:ss a");
86 exporterPdfOrientation: 'portrait',
87 exporterPdfPageSize: 'LETTER',
88 exporterPdfMaxGridWidth: 500,
89 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
90 onRegisterApi: function(gridApi){
91 $scope.gridApi = gridApi;
95 $scope.editBRMSParam = null;
96 $scope.createNewBRMSParamWindow = function(){
97 $scope.editBRMSParam = null;
98 var modalInstance = $modal.open({
99 backdrop: 'static', keyboard: false,
100 templateUrl : 'add_brmsParam_popup.html',
101 controller: 'editBRMSParamController',
103 message: function () {
105 brmsParamDictionaryDatas: $scope.editBRMSParam
111 modalInstance.result.then(function(response){
112 console.log('response', response);
113 $scope.brmsParamDictionaryDatas=response.brmsParamDictionaryDatas;
117 $scope.deleteBRMSParam = function(data) {
118 var uuu = "searchDictionary";
119 var postData={data: data, type: "brmsParam"};
120 var searchString = "\n";
125 contentType: 'application/json',
126 data: JSON.stringify(postData),
127 success : function(resultList){
128 $scope.$apply(function(){
129 $scope.list =resultList.result;});
130 $scope.searchData = JSON.stringify(resultList.result);
131 $scope.searchDatas = JSON.parse($scope.searchData);
132 $scope.success = true;
134 if($scope.searchDatas.length > 0){
135 for(i = 0 ; i < $scope.searchDatas.length; i++){
136 searchString += $scope.searchDatas[i] + "\n";
139 searchString += "No Policies is Using this Value"
142 console.log($scope.list);
144 modalService.popupConfirmWin("Confirm","You are about to delete the BRMS Param Name: "+data.ruleName+". \n used in the following policie(s)\n "+searchString+" \n Do you want to continue?",
146 var uuu = "deleteDictionary/brms_dictionary/remove_brmsParam";
147 var postData={data: data};
152 contentType: 'application/json',
153 data: JSON.stringify(postData),
154 success : function(data){
155 $scope.$apply(function(){$scope.brmsParamDictionaryDatas=data.brmsParamDictionaryDatas;});
157 error : function(data){
159 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);
165 error : function(data){
166 alert("Error while Searching.");