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('safePolicyWarningDictGridController', function ($scope, PolicyAppService, modalService, $modal){
21 $( "#dialog" ).hide();
23 PolicyAppService.getData('getDictionary/get_SafePolicyWarningData').then(function (data) {
25 $scope.data = JSON.parse(j.data);
26 console.log($scope.data);
27 $scope.safePolicyWarningDatas = JSON.parse($scope.data.safePolicyWarningDatas);
28 console.log($scope.safePolicyWarningDatas);
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.safePolicyWarningDictionaryGrid.columnDefs[0].visible = false;
39 $scope.gridApi.grid.refresh();
41 $scope.safePolicyWarningDictionaryGrid.columnDefs[0].visible = true;
42 $scope.gridApi.grid.refresh();
45 console.log("failed");
48 $scope.safePolicyWarningDictionaryGrid = {
49 data : 'safePolicyWarningDatas',
50 enableFiltering: true,
52 field: 'id', enableFiltering: false, headerCellTemplate: '' +
53 '<button id=\'New\' ng-click="grid.appScope.createNewSafePolicyWarningWindow()" class="btn btn-success">' + 'Create</button>',
55 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editSafePolicyWarningWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
56 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteSafePolicyWarning(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
57 },{ field: 'name', displayName : 'Safe Policy Warning Name', sort: { direction: 'asc', priority: 0 }},
58 { field: 'riskType', displayName : 'Risk Type'},{ field: 'message', displayName : 'Message'}
60 onRegisterApi: function(gridApi){
61 $scope.gridApi = gridApi;
62 $scope.gridApi.core.refresh();
66 $scope.editSafePolicyWarning = null;
67 $scope.createNewSafePolicyWarningWindow = function(){
68 $scope.editSafePolicyWarning = null;
69 var modalInstance = $modal.open({
70 backdrop: 'static', keyboard: false,
71 templateUrl : 'add_SafePolicyWarning_popup.html',
72 controller: 'editSafePolicyWarningController',
74 message: function () {
76 safePolicyWarningDatas: $scope.editSafePolicyWarningScope
82 modalInstance.result.then(function(response){
83 console.log('response', response);
84 $scope.safePolicyWarningDatas=response.safePolicyWarningDatas;
88 $scope.editSafePolicyWarningWindow = function(safePolicyWarningData) {
89 $scope.editSafePolicyWarning = safePolicyWarningData;
90 var modalInstance = $modal.open({
91 backdrop: 'static', keyboard: false,
92 templateUrl : 'add_SafePolicyWarning_popup.html',
93 controller: 'editSafePolicyWarningController',
95 message: function () {
97 safePolicyWarningData: $scope.editSafePolicyWarning
103 modalInstance.result.then(function(response){
104 console.log('response', response);
105 $scope.groupPolicyScopeListDatas = response.safePolicyWarningData;
109 $scope.deleteSafePolicyWarning = function(data) {
110 modalService.popupConfirmWin("Confirm","You are about to delete the Safe Policy Warning "+data.name+". Do you want to continue?",
112 var uuu = "deleteDictionary/sp_dictionary/remove_SafePolicyWarning";
113 var postData={data: data};
118 contentType: 'application/json',
119 data: JSON.stringify(postData),
120 success : function(data){
121 $scope.$apply(function(){$scope.safePolicyWarningDatas=data.safePolicyWarningDatas;});
123 error : function(data){
125 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);