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('riskTypeDictGridController', function ($scope, PolicyAppService, modalService, $modal, uiGridConstants,Grid){
21 $( "#dialog" ).hide();
23 PolicyAppService.getData('getDictionary/get_RiskTypeData').then(function (data) {
25 $scope.data = JSON.parse(j.data);
26 console.log($scope.data);
27 $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
28 console.log($scope.riskTypeDictionaryDatas);
30 console.log("failed");
33 PolicyAppService.getData('get_LockDownData').then(function(data){
35 $scope.data = JSON.parse(j.data);
36 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
37 if($scope.lockdowndata[0].lockdown == true){
38 $scope.riskTypeDictionaryGrid.columnDefs[0].visible = false;
39 $scope.gridApi.grid.refresh();
41 $scope.riskTypeDictionaryGrid.columnDefs[0].visible = true;
42 $scope.gridApi.grid.refresh();
45 console.log("failed");
48 $scope.riskTypeDictionaryGrid = {
49 data : 'riskTypeDictionaryDatas',
50 enableFiltering: true,
51 enableSelectAll: true,
53 field: 'id', enableFiltering: false, headerCellTemplate: '' +
54 '<button id=\'New\' ng-click="grid.appScope.createNewRiskType()" class="btn btn-success">' + 'Create</button>',
56 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editRiskTypeWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
57 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteRiskType(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
59 { field: 'riskName', displayName : 'Risk Type Name', sort: { direction: 'asc', priority: 0 } },
60 { field: 'description', width: '20%' },
61 {field: 'userCreatedBy.userName', displayName : 'Created By'},
62 {field: 'userModifiedBy.userName', displayName : 'Modified By' },
63 {field: 'createdDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\''},
64 {field: 'modifiedDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\''}
66 enableColumnResize : true,
67 onRegisterApi: function(gridApi){
68 $scope.gridApi = gridApi;
69 $scope.gridApi.core.refresh();
73 $scope.editRiskType = null;
74 $scope.createNewRiskType = function(){
75 $scope.editRiskType = null;
76 var modalInstance = $modal.open({
77 backdrop: 'static', keyboard: false,
78 templateUrl : 'add_riskType_popup.html',
79 controller: 'editRiskTypeController',
81 message: function () {
83 riskTypeDictionaryDatas: $scope.editRiskType
89 modalInstance.result.then(function(response){
90 console.log('response', response);
91 $scope.riskTypeDictionaryDatas=response.riskTypeDictionaryDatas;
95 $scope.editRiskTypeWindow = function(riskTypeDictionaryData) {
96 $scope.editRiskType = riskTypeDictionaryData;
97 var modalInstance = $modal.open({
98 backdrop: 'static', keyboard: false,
99 templateUrl : 'add_riskType_popup.html',
100 controller: 'editRiskTypeController',
102 message: function () {
104 riskTypeDictionaryData: $scope.editRiskType
110 modalInstance.result.then(function(response){
111 console.log('response', response);
112 $scope.riskTypeDictionaryDatas = response.riskTypeDictionaryData;
116 $scope.deleteRiskType = function(data) {
117 modalService.popupConfirmWin("Confirm","You are about to delete the Onap Name "+data.riskType+". Do you want to continue?",
119 var uuu = "deleteDictionary/sp_dictionary/remove_riskType";
120 var postData={data: data};
125 contentType: 'application/json',
126 data: JSON.stringify(postData),
127 success : function(data){
128 $scope.$apply(function(){$scope.riskTypeDictionaryDatas=data.riskTypeDictionaryDatas;});
130 error : function(data){
132 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);