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=========================================================
23 var Actiontype = ["REST"];
24 app.controller('actionPolicyDictGridController', function ($scope, DictionaryService,modalService, $modal, uiGridConstants,Grid, PapUrlService){
25 $( "#dialog" ).hide();
26 $scope.type = Actiontype;
29 PapUrlService.getPapUrl().then(function(data) {
31 papUrl = config.PAP_URL;
34 DictionaryService.getActionPolicyDictionaryData(papUrl).then(function (data) {
36 $scope.data = JSON.parse(j.data);
37 console.log($scope.data);
38 $scope.actionPolicyDictionaryDatas = JSON.parse($scope.data.actionPolicyDictionaryDatas);
39 console.log($scope.actionPolicyDictionaryDatas);
41 console.log("failed");
46 $scope.actionPolicyDictionaryGrid = {
47 enableFiltering: true,
48 data: 'actionPolicyDictionaryDatas',
49 exporterCsvFilename: 'ActionPolicyDictionary.csv',
51 enableSelectAll: true,
54 enableFiltering: false,
55 headerCellTemplate: '' +
56 '<button id=\'New\' ng-click="grid.appScope.createNewActionPolicyDictWindow()" class="btn btn-success">' + 'Create</button>',
57 cellTemplate: '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editActionPolicyDictWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
58 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteActionPolicyDict(row.entity)" ><i class="fa fa-trash-o"></i></button> ',
61 {field: 'attributeName', displayName: 'Attribute Name'},
65 {field: 'header', displayName: 'Headers'},
66 {field: 'description'},
67 {field: 'userCreatedBy.userName', displayName: 'Created By'},
68 {field: 'userModifiedBy.userName', displayName: 'Modified By'},
69 {field: 'createdDate', type: 'date', cellFilter: 'date:\'yyyy-MM-dd\''},
70 {field: 'modifiedDate', type: 'date', cellFilter: 'date:\'yyyy-MM-dd\''}
72 exporterPdfDefaultStyle: {fontSize: 9},
73 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
74 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
75 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
76 exporterPdfFooter: function ( currentPage, pageCount ) {
77 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
79 exporterPdfCustomFormatter: function ( docDefinition ) {
80 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
81 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
84 exporterPdfOrientation: 'portrait',
85 exporterPdfPageSize: 'LETTER',
86 exporterPdfMaxGridWidth: 500,
87 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
88 onRegisterApi: function(gridApi){
89 $scope.gridApi = gridApi;
94 $scope.editActionPolicyName = null;
95 $scope.createNewActionPolicyDictWindow = function () {
96 $scope.editActionPolicyName = null;
97 var modalInstance = $modal.open({
98 backdrop: 'static', keyboard: false,
99 templateUrl: 'add_actionPolicyDict_popup.html',
100 controller: 'editActionPolicyDictController',
102 message: function () {
104 actionPolicyDictionaryDatas: $scope.editActionPolicyName
110 modalInstance.result.then(function (response) {
111 console.log('response', response);
112 $scope.actionPolicyDictionaryDatas = response.actionPolicyDictionaryDatas;
116 $scope.editActionPolicyDictWindow = function (actionPolicyDictionaryData) {
117 $scope.editActionPolicyName = actionPolicyDictionaryData;
118 var modalInstance = $modal.open({
119 backdrop: 'static', keyboard: false,
120 templateUrl: 'add_actionPolicyDict_popup.html',
121 controller: 'editActionPolicyDictController',
123 message: function () {
125 actionPolicyDictionaryData: $scope.editActionPolicyName
131 modalInstance.result.then(function (response) {
132 console.log('response', response);
133 $scope.actionPolicyDictionaryDatas = response.actionPolicyDictionaryDatas;
137 $scope.deleteActionPolicyDict = function (data) {
138 modalService.popupConfirmWin("Confirm", "You are about to delete the Action Policy Dictionary Item " + data.attributeName + ". Do you want to continue?",
140 var uuu = papUrl + "/ecomp/action_dictionary/remove_actionPolicyDict.htm";
141 var postData = {data: data};
146 contentType: 'application/json',
147 data: JSON.stringify(postData),
148 success: function (data) {
149 $scope.$apply(function () {
150 $scope.actionPolicyDictionaryDatas = data.actionPolicyDictionaryDatas;
153 error: function (data) {
155 modalService.showFailure("Fail", "Error while deleting: " + data.responseText);