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 var Actiontype = ["REST"];
21 app.controller('actionPolicyDictGridController', function ($scope,modalService, $modal, uiGridConstants,Grid, PolicyAppService){
22 $( "#dialog" ).hide();
23 $scope.type = Actiontype;
25 PolicyAppService.getData('getDictionary/get_ActionPolicyDictData').then(function (data) {
27 $scope.data = JSON.parse(j.data);
28 console.log($scope.data);
29 $scope.actionPolicyDictionaryDatas = JSON.parse($scope.data.actionPolicyDictionaryDatas);
30 console.log($scope.actionPolicyDictionaryDatas);
32 console.log("failed");
36 PolicyAppService.getData('get_LockDownData').then(function(data){
38 $scope.data = JSON.parse(j.data);
39 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
40 if($scope.lockdowndata[0].lockdown == true){
41 $scope.actionPolicyDictionaryGrid.columnDefs[0].visible = false;
42 $scope.gridApi.grid.refresh();
44 $scope.actionPolicyDictionaryGrid.columnDefs[0].visible = true;
45 $scope.gridApi.grid.refresh();
48 console.log("failed");
51 $scope.actionPolicyDictionaryGrid = {
52 enableFiltering: true,
53 data: 'actionPolicyDictionaryDatas',
54 exporterCsvFilename: 'ActionPolicyDictionary.csv',
56 enableSelectAll: true,
59 enableFiltering: false,
60 headerCellTemplate: '' +
61 '<button id=\'New\' ng-click="grid.appScope.createNewActionPolicyDictWindow()" class="btn btn-success">' + 'Create</button>',
62 cellTemplate: '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editActionPolicyDictWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
63 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteActionPolicyDict(row.entity)" ><i class="fa fa-trash-o"></i></button> ',
66 {field: 'attributeName', displayName: 'Attribute Name', sort: { direction: 'asc', priority: 0 }},
70 {field: 'header', displayName: 'Headers'},
71 {field: 'description'},
72 {field: 'userCreatedBy.userName', displayName: 'Created By'},
73 {field: 'userModifiedBy.userName', displayName: 'Modified By'},
74 {field: 'createdDate', type: 'date', cellFilter: 'date:\'yyyy-MM-dd\''},
75 {field: 'modifiedDate', type: 'date', cellFilter: 'date:\'yyyy-MM-dd\''}
77 exporterMenuPdf: false,
78 exporterPdfDefaultStyle: {fontSize: 9},
79 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
80 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
81 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
82 exporterPdfFooter: function ( currentPage, pageCount ) {
83 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
85 exporterPdfCustomFormatter: function ( docDefinition ) {
86 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
87 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
90 exporterFieldCallback: function(grid, row, col, input) {
91 if( col.name == 'createdDate' || col.name == 'modifiedDate') {
92 var date = new Date(input);
93 return date.toString("yyyy-MM-dd HH:MM:ss a");
98 exporterPdfOrientation: 'portrait',
99 exporterPdfPageSize: 'LETTER',
100 exporterPdfMaxGridWidth: 500,
101 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
102 onRegisterApi: function(gridApi){
103 $scope.gridApi = gridApi;
108 $scope.editActionPolicyName = null;
109 $scope.createNewActionPolicyDictWindow = function () {
110 $scope.editActionPolicyName = null;
111 var modalInstance = $modal.open({
112 backdrop: 'static', keyboard: false,
113 templateUrl: 'add_actionPolicyDict_popup.html',
114 controller: 'editActionPolicyDictController',
116 message: function () {
118 actionPolicyDictionaryDatas: $scope.editActionPolicyName
124 modalInstance.result.then(function (response) {
125 console.log('response', response);
126 $scope.actionPolicyDictionaryDatas = response.actionPolicyDictionaryDatas;
130 $scope.editActionPolicyDictWindow = function (actionPolicyDictionaryData) {
131 $scope.editActionPolicyName = actionPolicyDictionaryData;
132 var modalInstance = $modal.open({
133 backdrop: 'static', keyboard: false,
134 templateUrl: 'add_actionPolicyDict_popup.html',
135 controller: 'editActionPolicyDictController',
137 message: function () {
139 actionPolicyDictionaryData: $scope.editActionPolicyName
145 modalInstance.result.then(function (response) {
146 console.log('response', response);
147 $scope.actionPolicyDictionaryDatas = response.actionPolicyDictionaryDatas;
151 $scope.deleteActionPolicyDict = function (data) {
152 modalService.popupConfirmWin("Confirm", "You are about to delete the Action Policy Dictionary Item " + data.attributeName + ". Do you want to continue?",
154 var uuu = "deleteDictionary/action_dictionary/remove_actionPolicyDict";
155 var postData = {data: data};
160 contentType: 'application/json',
161 data: JSON.stringify(postData),
162 success: function (data) {
163 $scope.$apply(function () {
164 $scope.actionPolicyDictionaryDatas = data.actionPolicyDictionaryDatas;
167 error: function (data) {
169 modalService.showFailure("Fail", "Error while deleting: " + data.responseText);