Remove unused vars and methods
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / controller / AutoPushTabController / RemovePDPGroupPoliciesController.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2017, 2019 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 app.controller('removeGroupPoliciesController' ,  function ($scope, $modalInstance, message, Notification){
21     if(message.selectedPdpGroupData !=null){
22         $scope.label='Remove PDP Group Policies'
23         $scope.disableCd=true;
24     }
25     $scope.policies = message.selectedPdpGroupData.policies;
26     $scope.pdpGroupData = message.selectedPdpGroupData;
27
28     $scope.removePoliciesGrid = {
29         data : 'policies',
30         enableFiltering: true,
31         columnDefs: [
32             { field: 'root', displayName : 'Root', width : '10%'},
33             { field: 'name', displayName : 'Name' },
34             { field: 'version' , width : '10%'},
35             { field: 'id' }
36         ]
37     };
38
39     $scope.removePoliciesGrid.onRegisterApi = function(gridApi){
40         //set gridApi on scope
41         $scope.gridApi = gridApi;
42         gridApi.selection.on.rowSelectionChanged($scope,function(row){
43         });
44
45         gridApi.selection.on.rowSelectionChangedBatch($scope,function(rows){
46         });
47     };
48
49     $scope.removePolicies = function() {
50         $scope.removeGroupData = [];
51         angular.forEach($scope.gridApi.selection.getSelectedRows(), function (data, index) {
52                 $scope.removeGroupData.push(data);    
53         });
54         if($scope.removeGroupData.length > 0){
55                  var uuu = "auto_Push/remove_GroupPolicies.htm";
56              var postData={data: $scope.removeGroupData,
57                         activePdpGroup : $scope.pdpGroupData};
58              $.ajax({
59                  type : 'POST',
60                  url : uuu,
61                  dataType: 'json',
62                  contentType: 'application/json',
63                  data: JSON.stringify(postData),
64                  success : function(data){
65                      $scope.$apply(function(){
66                          $scope.data=data.data;});
67                      console.log($scope.data);
68                      $modalInstance.close({data:$scope.data});
69                      Notification.success("Policy Removed Successfully");
70                  },
71                  error : function(data){
72                         Notification.error("Error Occured while removing Policy");
73                  }
74              });
75         }else{
76                 Notification.error("Please select atleast one Policy to remove");
77         }
78     };
79
80     $scope.close = function() {
81         $modalInstance.close();
82     };
83 });