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 app.controller('decisionSettingsDictGridController', function ($scope, DictionaryService,modalService, $modal, PapUrlService){
24 $( "#dialog" ).hide();
26 PapUrlService.getPapUrl().then(function(data) {
28 papUrl = config.PAP_URL;
31 DictionaryService.getDecisionSettingsDictionaryData(papUrl).then(function (data) {
33 $scope.data = JSON.parse(j.data);
34 console.log($scope.data);
35 $scope.settingsDictionaryDatas = JSON.parse($scope.data.settingsDictionaryDatas);
36 console.log($scope.settingsDictionaryDatas);
38 console.log("failed");
43 $scope.decisionSettingsDictionaryGrid = {
44 data : 'settingsDictionaryDatas',
45 enableFiltering: true,
46 exporterCsvFilename: 'Settings.csv',
48 enableSelectAll: true,
50 field: 'id', enableFiltering: false, headerCellTemplate: '' +
51 '<button id=\'New\' ng-click="grid.appScope.createNewSettingsDictWindow()" class="btn btn-success">' + 'Create</button>',
53 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editSettingsDictWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
54 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteSettingsDict(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
55 },{ field: 'xacmlId', displayName : 'Settings ID'},
56 { field: 'datatypeBean.shortName', displayName : 'Data Type' },
57 { field: 'description' },
58 {field: 'userCreatedBy.userName', displayName : 'Created By' },
59 {field: 'userModifiedBy.userName', displayName : 'Modified By'},
60 {field: 'createdDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' },
61 {field: 'modifiedDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' }
63 exporterPdfDefaultStyle: {fontSize: 9},
64 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
65 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
66 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
67 exporterPdfFooter: function ( currentPage, pageCount ) {
68 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
70 exporterPdfCustomFormatter: function ( docDefinition ) {
71 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
72 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
75 exporterPdfOrientation: 'portrait',
76 exporterPdfPageSize: 'LETTER',
77 exporterPdfMaxGridWidth: 500,
78 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
79 onRegisterApi: function(gridApi){
80 $scope.gridApi = gridApi;
84 $scope.editSettingsDict = null;
85 $scope.createNewSettingsDictWindow = function(){
86 $scope.editSettingsDict = null;
87 var modalInstance = $modal.open({
88 backdrop: 'static', keyboard: false,
89 templateUrl : 'add_SettingsDict_popup.html',
90 controller: 'editSettingsDictController',
92 message: function () {
94 settingsDictionaryDatas: $scope.editSettingsDict
100 modalInstance.result.then(function(response){
101 console.log('response', response);
102 $scope.settingsDictionaryDatas=response.settingsDictionaryDatas;
106 $scope.editSettingsDictWindow = function(settingsDictionaryData) {
107 $scope.editSettingsDict = settingsDictionaryData;
108 var modalInstance = $modal.open({
109 backdrop: 'static', keyboard: false,
110 templateUrl : 'add_SettingsDict_popup.html',
111 controller: 'editSettingsDictController',
113 message: function () {
115 settingsDictionaryData: $scope.editSettingsDict
121 modalInstance.result.then(function(response){
122 console.log('response', response);
123 $scope.settingsDictionaryDatas = response.settingsDictionaryDatas;
127 $scope.deleteSettingsDict = function(data) {
128 modalService.popupConfirmWin("Confirm","You are about to delete the Settings Dictionary "+data.xacmlId+". Do you want to continue?",
130 var uuu = papUrl + "/ecomp/settings_dictionary/remove_settings.htm";
131 var postData={data: data};
136 contentType: 'application/json',
137 data: JSON.stringify(postData),
138 success : function(data){
139 $scope.$apply(function(){$scope.settingsDictionaryDatas=data.settingsDictionaryDatas;});
141 error : function(data){
143 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);