2 * ============LICENSE_START=======================================================
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
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',
21 function ($scope, PolicyAppService, modalService, $modal, Notification,$filter){
22 $( "#dialog" ).hide();
24 $scope.isDisabled = true;
25 $scope.loading = true;
27 PolicyAppService.getData('get_LockDownData').then(function(data){
29 $scope.data = JSON.parse(j.data);
30 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
31 if($scope.lockdowndata[0].lockdown == true){
32 $scope.isDisabled = true;
34 $scope.isDisabled = false;
39 PolicyAppService.getData('get_PDPGroupData').then(function (data) {
41 $scope.pdpdata = JSON.parse(j.data);
42 $scope.pushTabPDPGrid.data = $scope.pdpdata;
45 $scope.getPDPData = function(){
46 $scope.pushTabPDPGrid.data = $scope.pdpdata;
48 $scope.filterPdpGroup;
49 $scope.filterPDPGroupData = function() {
50 $scope.pushTabPDPGrid.data = $filter('filter')($scope.pdpdata, $scope.filterPdpGroup, undefined);
53 $scope.pushTabPDPGrid = {
54 onRegisterApi: function(gridApi) {
55 $scope.gridApi = gridApi;
57 enableFiltering: true,
59 { field: 'default',displayName : '', enableFiltering : false, enableSorting : false,
60 cellTemplate: '<button type="button" ng-click="grid.appScope.editPDPGroupWindow(row.entity)"><a class="fa fa-pencil-square-o"></a></i></button> ',
63 { field: 'id', displayName : 'ID'},
64 { field: 'name', displayName : 'Name' },
65 { field: 'description' }
70 $scope.editPDPGroupWindow = function (selectedPdpGroupData) {
71 $scope.removePDPGroupPolicies = selectedPdpGroupData;
72 if($scope.isDisabled){
73 Notification.error("Policy Application has been LockDown.");
75 var modalInstance = $modal.open({
76 backdrop: 'static', keyboard: false,
77 templateUrl: 'remove_PDPGroupPolicies_popup.html',
78 controller: 'removeGroupPoliciesController',
80 message: function () {
82 selectedPdpGroupData: $scope.removePDPGroupPolicies
88 modalInstance.result.then(function (response) {
89 $scope.pdpdata = JSON.parse(response.data);
90 $scope.pushTabPDPGrid.data = $scope.pdpdata;
95 $scope.gridOptions = {
97 onRegisterApi: function(gridApi) {
98 $scope.gridPolicyApi = gridApi;
101 enableFiltering: true,
102 showTreeExpandNoChildren: true,
103 paginationPageSizes: [10, 20, 50, 100],
104 paginationPageSize: 20,
105 columnDefs: [{name: 'policyName', displayName : 'Policy Name', sort: { direction: 'asc', priority: 0 }},
106 {name: 'activeVersion', displayName : 'Version'},
107 {name: 'modifiedDate', displayName : 'Last Modified',type: 'date', cellFilter: 'date:\'yyyy-MM-dd HH:MM:ss a\'' }]
111 PolicyAppService.getData('get_AutoPushPoliciesContainerData').then(function (data) {
112 $scope.loading = false;
114 $scope.data = JSON.parse(j.data);
115 $scope.policydatas =JSON.parse($scope.data.policydatas);
118 $scope.pushPoliciesButton = function(){
119 var policySelection = $scope.gridPolicyApi.selection.getSelectedRows();
120 var currentSelection = $scope.gridApi.selection.getSelectedRows();
121 if(policySelection.length == 0 && currentSelection.length == 0){
122 Notification.error("Please Select Policy and PDP Group to Push");
124 if(policySelection.length == 0 && currentSelection.length != 0){
125 Notification.error("Please Select Policy to Push");
127 if(policySelection.length != 0 && currentSelection.length == 0){
128 Notification.error("Please Select PDP Group to Push");
130 if(policySelection.length != 0 && currentSelection.length != 0){
132 "pdpDatas": currentSelection,
133 "policyDatas": policySelection
135 var uuu = "auto_Push/PushPolicyToPDP.htm";
136 var postData={pushTabData: finalData};
141 contentType: 'application/json',
142 data: JSON.stringify(postData),
143 success : function(data){
144 $scope.$apply(function(){
145 $scope.data=data.data;
146 $scope.pdpdata = JSON.parse(data.data);
147 $scope.pushTabPDPGrid.data = $scope.pdpdata;
148 Notification.success("Policy Pushed Successfully");
151 error : function(data){
152 Notification.error("Error Occured while Pushing Policy.");