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('attributeDictGridController', function ($scope, PolicyAppService, modalService, $modal){
21 $( "#dialog" ).hide();
23 PolicyAppService.getData('getDictionary/get_AttributeData').then(function (data) {
25 $scope.data = JSON.parse(j.data);
26 console.log($scope.data);
27 $scope.attributeDictionaryDatas = JSON.parse($scope.data.attributeDictionaryDatas);
28 console.log($scope.attributeDictionaryDatas);
30 console.log("failed");
34 $scope.exportData = function () {
35 var blob = new Blob([document.getElementById('attributeTable').innerHTML], {
36 type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
38 saveAs(blob, "Attribute.xls");
41 PolicyAppService.getData('get_LockDownData').then(function(data){
43 $scope.data = JSON.parse(j.data);
44 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
45 if($scope.lockdowndata[0].lockdown == true){
46 $scope.attributeDictionaryGrid.columnDefs[0].visible = false;
47 $scope.gridApi.grid.refresh();
49 $scope.attributeDictionaryGrid.columnDefs[0].visible = true;
50 $scope.gridApi.grid.refresh();
53 console.log("failed");
56 $scope.attributeDictionaryGrid = {
57 data : 'attributeDictionaryDatas',
58 enableFiltering: true,
59 exporterCsvFilename: 'Attribute.csv',
61 enableSelectAll: true,
63 field: 'id' , enableFiltering: false, headerCellTemplate: '' +
64 '<button id=\'New\' ng-click="grid.appScope.createNewAttributeWindow()" class="btn btn-success">' + 'Create</button>',
66 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editAttributeWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
67 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteAttribute(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
68 },{ field: 'xacmlId', displayName : 'Attribute ID', sort: { direction: 'asc', priority: 0 }},
69 { field: 'datatypeBean.shortName', displayName : 'Data Type' },
70 { field: 'attributeValue'},
71 { field: 'description' },
72 { field: 'priority' , displayName : 'Priority'},
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 exporterPdfOrientation: 'portrait',
92 exporterPdfPageSize: 'LETTER',
93 exporterPdfMaxGridWidth: 500,
94 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
95 onRegisterApi: function(gridApi){
96 $scope.gridApi = gridApi;
101 $scope.editAttributeName = null;
102 $scope.createNewAttributeWindow = function(){
103 $scope.editAttributeName = null;
104 var modalInstance = $modal.open({
105 backdrop: 'static', keyboard: false,
106 templateUrl : 'add_Attribute_popup.html',
107 controller: 'editAttributeController',
109 message: function () {
111 attributeDictionaryDatas: $scope.editAttributeName
117 modalInstance.result.then(function(response){
118 console.log('response', response);
119 $scope.attributeDictionaryDatas=response.attributeDictionaryDatas;
123 $scope.editAttributeWindow = function(attributeDictionaryData) {
124 $scope.editAttributeName = attributeDictionaryData;
125 var modalInstance = $modal.open({
126 backdrop: 'static', keyboard: false,
127 templateUrl : 'add_Attribute_popup.html',
128 controller: 'editAttributeController',
130 message: function () {
132 attributeDictionaryData: $scope.editAttributeName
138 modalInstance.result.then(function(response){
139 console.log('response', response);
140 $scope.attributeDictionaryDatas = response.attributeDictionaryDatas;
144 $scope.deleteAttribute = function(data) {
145 var uuu = "searchDictionary";
146 var postData={data: data, type: "attribute"};
147 var searchString = "\n";
152 contentType: 'application/json',
153 data: JSON.stringify(postData),
154 success : function(resultList){
155 $scope.$apply(function(){
156 $scope.list =resultList.result;});
157 $scope.searchData = JSON.stringify(resultList.result);
158 $scope.searchDatas = JSON.parse($scope.searchData);
159 $scope.success = true;
161 if($scope.searchDatas.length > 0){
162 for(i = 0 ; i < $scope.searchDatas.length; i++){
163 searchString += $scope.searchDatas[i] + "\n";
166 searchString += "No Policies is Using this Value"
169 console.log($scope.list);
171 modalService.popupConfirmWin("Confirm","You are about to delete the Attribute Dictionary : "+data.xacmlId+". \n "+searchString+" \n Do you want to continue?",
173 var uuu = "deleteDictionary/attribute_dictionary/remove_attribute";
174 var postData={data: data};
179 contentType: 'application/json',
180 data: JSON.stringify(postData),
181 success : function(data){
182 $scope.$apply(function(){$scope.attributeDictionaryDatas=data.attributeDictionaryDatas;});
184 error : function(data){
186 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);
192 error : function(data){
193 alert("Error while Searching.");