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('policyPushController', function ($scope, PolicyAppService, modalService, $modal, Notification,$filter){
21 $( "#dialog" ).hide();
23 $scope.isDisabled = true;
24 $scope.loading = true;
26 PolicyAppService.getData('get_LockDownData').then(function(data){
28 $scope.data = JSON.parse(j.data);
29 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
30 if($scope.lockdowndata[0].lockdown == true){
31 $scope.isDisabled = true;
33 $scope.isDisabled = false;
35 console.log($scope.data);
37 console.log("failed");
41 PolicyAppService.getData('get_PDPGroupData').then(function (data) {
43 $scope.pdpdata = JSON.parse(j.data);
44 console.log($scope.pdpdata);
45 $scope.pushTabPDPGrid.data = $scope.pdpdata;
47 console.log("failed");
50 $scope.getPDPData = function(){
51 $scope.pushTabPDPGrid.data = $scope.pdpdata;
53 $scope.filterPdpGroup;
54 $scope.filterPDPGroupData = function() {
55 $scope.pushTabPDPGrid.data = $filter('filter')($scope.pdpdata, $scope.filterPdpGroup, undefined);
58 $scope.pushTabPDPGrid = {
59 onRegisterApi: function(gridApi) {
60 $scope.gridApi = gridApi;
62 enableFiltering: true,
64 { field: 'default',displayName : '', enableFiltering : false, enableSorting : false,
65 cellTemplate: '<button type="button" ng-click="grid.appScope.editPDPGroupWindow(row.entity)"><a class="fa fa-pencil-square-o"></a></i></button> ',
68 { field: 'id', displayName : 'ID'},
69 { field: 'name', displayName : 'Name' },
70 { field: 'description' }
75 $scope.editPDPGroupWindow = function (selectedPdpGroupData) {
76 $scope.removePDPGroupPolicies = selectedPdpGroupData;
77 if($scope.isDisabled){
78 Notification.error("Policy Application has been LockDown.");
80 var modalInstance = $modal.open({
81 backdrop: 'static', keyboard: false,
82 templateUrl: 'remove_PDPGroupPolicies_popup.html',
83 controller: 'removeGroupPoliciesController',
85 message: function () {
87 selectedPdpGroupData: $scope.removePDPGroupPolicies
93 modalInstance.result.then(function (response) {
94 console.log('response', response);
95 $scope.pdpdata = JSON.parse(response.data);
96 $scope.pushTabPDPGrid.data = $scope.pdpdata;
101 $scope.gridOptions = {
102 data : 'policydatas',
103 onRegisterApi: function(gridApi) {
104 $scope.gridPolicyApi = gridApi;
107 enableFiltering: true,
108 showTreeExpandNoChildren: true,
109 paginationPageSizes: [10, 20, 50, 100],
110 paginationPageSize: 20,
111 columnDefs: [{name: 'policyName', displayName : 'Policy Name', sort: { direction: 'asc', priority: 0 }},
112 {name: 'activeVersion', displayName : 'Version'},
113 {name: 'modifiedDate', displayName : 'Last Modified',type: 'date', cellFilter: 'date:\'yyyy-MM-dd HH:MM:ss a\'' }]
117 PolicyAppService.getData('get_AutoPushPoliciesContainerData').then(function (data) {
118 $scope.loading = false;
120 $scope.data = JSON.parse(j.data);
121 console.log($scope.data);
122 $scope.policydatas =JSON.parse($scope.data.policydatas);
123 console.log($scope.policydatas);
124 }, function (error) {
125 console.log("failed");
128 $scope.pushPoliciesButton = function(){
129 var policySelection = $scope.gridPolicyApi.selection.getSelectedRows();
130 console.log(policySelection);
131 var currentSelection = $scope.gridApi.selection.getSelectedRows();
132 if(policySelection.length == 0 && currentSelection.length == 0){
133 Notification.error("Please Select Policy and PDP Group to Push");
135 if(policySelection.length == 0 && currentSelection.length != 0){
136 Notification.error("Please Select Policy to Push");
138 if(policySelection.length != 0 && currentSelection.length == 0){
139 Notification.error("Please Select PDP Group to Push");
141 if(policySelection.length != 0 && currentSelection.length != 0){
143 "pdpDatas": currentSelection,
144 "policyDatas": policySelection
146 console.log(finalData);
147 var uuu = "auto_Push/PushPolicyToPDP.htm";
148 var postData={pushTabData: finalData};
153 contentType: 'application/json',
154 data: JSON.stringify(postData),
155 success : function(data){
156 $scope.$apply(function(){
157 $scope.data=data.data;
158 $scope.pdpdata = JSON.parse(data.data);
159 $scope.pushTabPDPGrid.data = $scope.pdpdata;
160 Notification.success("Policy Pushed Successfully");
162 console.log($scope.data);
164 error : function(data){
165 Notification.error("Error Occured while Pushing Policy.");