removing unused db file
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / app / policyApp / controller / dictionaryGridController / PSGroupPolicyScopeDictGridController.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ECOMP Policy Engine
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 /**
22  */
23 app.controller('psGroupPolicyScopeDictGridController', function ($scope, PolicyScopeService,modalService, $modal, PapUrlService){
24     $( "#dialog" ).hide();
25     
26         var papUrl;
27         PapUrlService.getPapUrl().then(function(data) {
28                 var config = data;
29                 papUrl = config.PAP_URL;
30                 console.log(papUrl);
31                 
32             PolicyScopeService.getPSGroupPolicyScopeDictionaryData(papUrl).then(function (data) {
33                 var j = data;
34                 $scope.data = JSON.parse(j.data);
35                 console.log($scope.data);
36                 $scope.groupPolicyScopeListDatas = JSON.parse($scope.data.groupPolicyScopeListDatas);
37                 console.log($scope.groupPolicyScopeListDatas);
38             }, function (error) {
39                 console.log("failed");
40             });
41                 
42         });
43         
44     $scope.psGroupPolicyScopeDictionaryGrid = {
45         data : 'groupPolicyScopeListDatas',
46         enableFiltering: true,
47         columnDefs: [{
48             field: 'id', enableFiltering: false, headerCellTemplate: '' +
49             '<button id=\'New\' ng-click="grid.appScope.createNewGroupPolicyScopeWindow()" class="btn btn-success">' + 'Create</button>',
50             cellTemplate:
51             '<button  type="button"  class="btn btn-primary"  ng-click="grid.appScope.editGroupPolicyScopeWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
52             '<button  type="button"  class="btn btn-danger"  ng-click="grid.appScope.deleteGroupPolicyScope(row.entity)" ><i class="fa fa-trash-o"></i></button> ',  width: '8%'
53         },{ field: 'groupName', displayName : 'Policy Scope Group Name'},
54         { field: 'groupList', displayName : 'Policy Scope List'}
55         ],
56         onRegisterApi: function(gridApi){
57                 $scope.gridApi = gridApi;
58                 $scope.gridApi.core.refresh();
59         }
60     };
61    
62     $scope.editPSGroupPolicyScope = null;
63     $scope.createNewGroupPolicyScopeWindow = function(){
64         $scope.editPSGroupPolicyScope = null;
65         var modalInstance = $modal.open({
66                 backdrop: 'static', keyboard: false,
67             templateUrl : 'add_PSGroupPolicyScope_popup.html',
68             controller: 'editPSGroupPolicyScopeController',
69             resolve: {
70                 message: function () {
71                     var message = {
72                                 groupPolicyScopeListDatas: $scope.editPSGroupPolicyScope
73                     };
74                     return message;
75                 }
76             }
77         });
78         modalInstance.result.then(function(response){
79             console.log('response', response);
80             $scope.groupPolicyScopeListDatas=response.groupPolicyScopeListDatas;
81         });
82     };
83
84     $scope.editGroupPolicyScopeWindow = function(groupPolicyScopeListData) {
85         $scope.editPSGroupPolicyScope = groupPolicyScopeListData;
86         var modalInstance = $modal.open({
87                 backdrop: 'static', keyboard: false,
88             templateUrl : 'add_PSGroupPolicyScope_popup.html',
89             controller: 'editPSGroupPolicyScopeController',
90             resolve: {
91                 message: function () {
92                     var message = {
93                                 groupPolicyScopeListData: $scope.editPSGroupPolicyScope
94                     };
95                     return message;
96                 }
97             }
98         });
99         modalInstance.result.then(function(response){
100             console.log('response', response);
101             $scope.groupPolicyScopeListDatas = response.groupPolicyScopeListDatas;
102         });
103     };
104
105     $scope.deleteGroupPolicyScope = function(data) {
106         modalService.popupConfirmWin("Confirm","You are about to delete the Group Policy Scope  "+data.name+". Do you want to continue?",
107             function(){
108                 var uuu = papUrl + "/ecomp/ps_dictionary/remove_GroupPolicyScope.htm";
109                 var postData={data: data};
110                 $.ajax({
111                     type : 'POST',
112                     url : uuu,
113                     dataType: 'json',
114                     contentType: 'application/json',
115                     data: JSON.stringify(postData),
116                     success : function(data){
117                         $scope.$apply(function(){$scope.groupPolicyScopeListDatas=data.groupPolicyScopeListDatas;});
118                     },
119                     error : function(data){
120                         console.log(data);
121                         modalService.showFailure("Fail","Error while deleting: "+ data.responseText);
122                     }
123                 });
124
125             })
126     };
127 });