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('riskTypeDictGridController', function ($scope, SafePolicyService,modalService,PapUrlService, $modal, uiGridConstants,Grid){
24 $( "#dialog" ).hide();
27 PapUrlService.getPapUrl().then(function(data) {
29 papUrl = config.PAP_URL;
32 SafePolicyService.getRiskTypeDictionaryData(papUrl).then(function (data) {
34 $scope.data = JSON.parse(j.data);
35 console.log($scope.data);
36 $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
37 console.log($scope.riskTypeDictionaryDatas);
39 console.log("failed");
43 $scope.riskTypeDictionaryGrid = {
44 data : 'riskTypeDictionaryDatas',
45 enableFiltering: true,
46 exporterCsvFilename: 'RiskType.csv',
48 enableSelectAll: true,
50 field: 'id', enableFiltering: false, headerCellTemplate: '' +
51 '<button id=\'New\' ng-click="grid.appScope.createNewRiskType()" class="btn btn-success">' + 'Create</button>',
53 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editRiskTypeWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
54 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteRiskType(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
56 { field: 'riskName', displayName : 'Risk Type Name' },
57 { field: 'description', width: '20%' },
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 enableColumnResize : true,
64 exporterPdfDefaultStyle: {fontSize: 9},
65 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
66 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
67 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
68 exporterPdfFooter: function ( currentPage, pageCount ) {
69 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
71 exporterPdfCustomFormatter: function ( docDefinition ) {
72 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
73 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
76 exporterPdfOrientation: 'portrait',
77 exporterPdfPageSize: 'LETTER',
78 exporterPdfMaxGridWidth: 500,
79 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
80 onRegisterApi: function(gridApi){
81 $scope.gridApi = gridApi;
86 $scope.editRiskType = null;
87 $scope.createNewRiskType = function(){
88 $scope.editRiskType = null;
89 var modalInstance = $modal.open({
90 backdrop: 'static', keyboard: false,
91 templateUrl : 'add_riskType_popup.html',
92 controller: 'editRiskTypeController',
94 message: function () {
96 riskTypeDictionaryDatas: $scope.editRiskType
102 modalInstance.result.then(function(response){
103 console.log('response', response);
104 $scope.riskTypeDictionaryDatas=response.riskTypeDictionaryDatas;
108 $scope.editRiskTypeWindow = function(riskTypeDictionaryData) {
109 $scope.editRiskType = riskTypeDictionaryData;
110 var modalInstance = $modal.open({
111 backdrop: 'static', keyboard: false,
112 templateUrl : 'add_riskType_popup.html',
113 controller: 'editRiskTypeController',
115 message: function () {
117 riskTypeDictionaryData: $scope.editRiskType
123 modalInstance.result.then(function(response){
124 console.log('response', response);
125 $scope.riskTypeDictionaryDatas = response.riskTypeDictionaryData;
129 $scope.deleteRiskType = function(data) {
130 modalService.popupConfirmWin("Confirm","You are about to delete the Ecomp Name "+data.riskType+". Do you want to continue?",
132 var uuu = papUrl + "/ecomp/sp_dictionary/remove_riskType.htm";
133 var postData={data: data};
138 contentType: 'application/json',
139 data: JSON.stringify(postData),
140 success : function(data){
141 $scope.$apply(function(){$scope.riskTypeDictionaryDatas=data.riskTypeDictionaryDatas;});
143 error : function(data){
145 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);