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('attributeDictGridController', function ($scope, DictionaryService, PapUrlService, modalService, $modal){
24 $( "#dialog" ).hide();
26 PapUrlService.getPapUrl().then(function(data) {
28 papUrl = config.PAP_URL;
30 DictionaryService.getAttributeDictionaryData(papUrl).then(function (data) {
32 $scope.data = JSON.parse(j.data);
33 console.log($scope.data);
34 $scope.attributeDictionaryDatas = JSON.parse($scope.data.attributeDictionaryDatas);
35 console.log($scope.attributeDictionaryDatas);
37 console.log("failed");
41 $scope.exportData = function () {
42 var blob = new Blob([document.getElementById('attributeTable').innerHTML], {
43 type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
45 saveAs(blob, "Attribute.xls");
48 $scope.attributeDictionaryGrid = {
49 data : 'attributeDictionaryDatas',
50 enableFiltering: true,
51 exporterCsvFilename: 'Attribute.csv',
53 enableSelectAll: true,
55 field: 'id' , enableFiltering: false, headerCellTemplate: '' +
56 '<button id=\'New\' ng-click="grid.appScope.createNewAttributeWindow()" class="btn btn-success">' + 'Create</button>',
58 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editAttributeWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
59 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteAttribute(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
60 },{ field: 'xacmlId', displayName : 'Attribute ID'},
61 { field: 'datatypeBean.shortName', displayName : 'Data Type' },
62 { field: 'attributeValue'},
63 { field: 'description' },
64 { field: 'priority' , displayName : 'Priority'},
65 {field: 'userCreatedBy.userName', displayName : 'Created By' },
66 {field: 'userModifiedBy.userName', displayName : 'Modified By'},
67 {field: 'createdDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' },
68 {field: 'modifiedDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' }
70 exporterPdfDefaultStyle: {fontSize: 9},
71 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
72 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
73 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
74 exporterPdfFooter: function ( currentPage, pageCount ) {
75 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
77 exporterPdfCustomFormatter: function ( docDefinition ) {
78 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
79 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
82 exporterPdfOrientation: 'portrait',
83 exporterPdfPageSize: 'LETTER',
84 exporterPdfMaxGridWidth: 500,
85 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
86 onRegisterApi: function(gridApi){
87 $scope.gridApi = gridApi;
92 $scope.editAttributeName = null;
93 $scope.createNewAttributeWindow = function(){
94 $scope.editAttributeName = null;
95 var modalInstance = $modal.open({
96 backdrop: 'static', keyboard: false,
97 templateUrl : 'add_Attribute_popup.html',
98 controller: 'editAttributeController',
100 message: function () {
102 attributeDictionaryDatas: $scope.editAttributeName
108 modalInstance.result.then(function(response){
109 console.log('response', response);
110 $scope.attributeDictionaryDatas=response.attributeDictionaryDatas;
114 $scope.editAttributeWindow = function(attributeDictionaryData) {
115 $scope.editAttributeName = attributeDictionaryData;
116 var modalInstance = $modal.open({
117 backdrop: 'static', keyboard: false,
118 templateUrl : 'add_Attribute_popup.html',
119 controller: 'editAttributeController',
121 message: function () {
123 attributeDictionaryData: $scope.editAttributeName
129 modalInstance.result.then(function(response){
130 console.log('response', response);
131 $scope.attributeDictionaryDatas = response.attributeDictionaryDatas;
135 $scope.deleteAttribute = function(data) {
136 modalService.popupConfirmWin("Confirm","You are about to delete the Attribute Dictionary : "+data.xacmlId+". \n "+searchString+" \n Do you want to continue?",
138 var uuu = papUrl + "/ecomp/attribute_dictionary/remove_attribute.htm";
139 var postData={data: data};
144 contentType: 'application/json',
145 data: JSON.stringify(postData),
146 success : function(data){
147 $scope.$apply(function(){$scope.attributeDictionaryDatas=data.attributeDictionaryDatas;});
149 error : function(data){
151 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);