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: 'body', visible : false},
72 {field: 'description'},
73 {field: 'userCreatedBy.userName', displayName: 'Created By'},
74 {field: 'userModifiedBy.userName', displayName: 'Modified By'},
75 {field: 'createdDate', type: 'date', cellFilter: 'date:\'yyyy-MM-dd\''},
76 {field: 'modifiedDate', type: 'date', cellFilter: 'date:\'yyyy-MM-dd\''}
78 exporterMenuPdf: false,
79 exporterPdfDefaultStyle: {fontSize: 9},
80 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
81 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
82 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
83 exporterPdfFooter: function ( currentPage, pageCount ) {
84 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
86 exporterPdfCustomFormatter: function ( docDefinition ) {
87 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
88 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
91 exporterFieldCallback: function(grid, row, col, input) {
92 if( col.name == 'createdDate' || col.name == 'modifiedDate') {
93 var date = new Date(input);
94 return date.toString("yyyy-MM-dd HH:MM:ss a");
99 exporterPdfOrientation: 'portrait',
100 exporterPdfPageSize: 'LETTER',
101 exporterPdfMaxGridWidth: 500,
102 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
103 onRegisterApi: function(gridApi){
104 $scope.gridApi = gridApi;
109 $scope.editActionPolicyName = null;
110 $scope.createNewActionPolicyDictWindow = function () {
111 $scope.editActionPolicyName = null;
112 var modalInstance = $modal.open({
113 backdrop: 'static', keyboard: false,
114 templateUrl: 'add_actionPolicyDict_popup.html',
115 controller: 'editActionPolicyDictController',
117 message: function () {
119 actionPolicyDictionaryDatas: $scope.editActionPolicyName
125 modalInstance.result.then(function (response) {
126 console.log('response', response);
127 $scope.actionPolicyDictionaryDatas = response.actionPolicyDictionaryDatas;
131 $scope.editActionPolicyDictWindow = function (actionPolicyDictionaryData) {
132 $scope.editActionPolicyName = actionPolicyDictionaryData;
133 var modalInstance = $modal.open({
134 backdrop: 'static', keyboard: false,
135 templateUrl: 'add_actionPolicyDict_popup.html',
136 controller: 'editActionPolicyDictController',
138 message: function () {
140 actionPolicyDictionaryData: $scope.editActionPolicyName
146 modalInstance.result.then(function (response) {
147 console.log('response', response);
148 $scope.actionPolicyDictionaryDatas = response.actionPolicyDictionaryDatas;
152 $scope.deleteActionPolicyDict = function (data) {
153 modalService.popupConfirmWin("Confirm", "You are about to delete the Action Policy Dictionary Item " + data.attributeName + ". Do you want to continue?",
155 var uuu = "deleteDictionary/action_dictionary/remove_actionPolicyDict";
156 var postData = {data: data};
161 contentType: 'application/json',
162 data: JSON.stringify(postData),
163 success: function (data) {
164 $scope.$apply(function () {
165 $scope.actionPolicyDictionaryDatas = data.actionPolicyDictionaryDatas;
168 error: function (data) {
170 modalService.showFailure("Fail", "Error while deleting: " + data.responseText);