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('pdpTabController', function ($scope, PolicyAppService, modalService, $modal){
21 $( "#dialog" ).hide();
23 $scope.isDisabled = true;
24 $scope.createPdpGroupId = false;
25 $scope.deletePdpGroupId = false;
26 $scope.editPdpGroupId = false;
28 PolicyAppService.getData('get_LockDownData').then(function(data){
30 $scope.data = JSON.parse(j.data);
31 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
32 if($scope.lockdowndata[0].lockdown == true){
33 $scope.isDisabled = true;
35 $scope.isDisabled = false;
37 console.log($scope.data);
39 PolicyAppService.getData('get_UserRolesData').then(function(data) {
41 $scope.data = JSON.parse(j.data);
42 console.log($scope.data);
43 $scope.userRolesDatas = JSON.parse($scope.data.userRolesDatas);
44 console.log($scope.userRolesDatas);
45 if($scope.isDisabled == false){
46 if($scope.userRolesDatas[0] == 'super-admin' || $scope.userRolesDatas[0] == 'admin'){
47 $scope.createPdpGroupId = true;
48 $scope.deletePdpGroupId = true;
49 $scope.editPdpGroupId = true;
50 }else if($scope.userRolesDatas[0] == 'super-editor' || $scope.userRolesDatas[0] == 'editor'){
51 $scope.editPdpGroupId = true;
52 }else if($scope.userRolesDatas[0] == 'super-guest' || $scope.userRolesDatas[0] == 'guest'){
53 $scope.editPdpGroupId = true;
57 PolicyAppService.getData('get_PDPGroupData').then(function(data){
59 $scope.pdpdatas = JSON.parse(j.data);
60 console.log($scope.pdpdatas);
62 console.log("failed");
65 console.log("failed");
68 console.log("failed");
72 $scope.addNewPDPGroupFunctionPopup = function() {
73 $scope.editPDPGroup = null;
74 $( "#dialog" ).dialog({
79 $scope.editPDPGroup = null;
81 $scope.editPDPGroupFunctionPopup = function(pdpGroupData) {
82 $scope.editPDPGroup = pdpGroupData;
83 $( "#dialog" ).dialog({
88 $scope.editPDPGroupFunctionModalPopup = function(pdpGroupData) {
89 $scope.editPDPGroup = pdpGroupData;
90 if($scope.userRolesDatas[0] == 'super-guest' || $scope.userRolesDatas[0] == 'guest'){
91 var modalInstance = $modal.open({
92 backdrop: 'static', keyboard: false,
93 templateUrl: 'show_policies_pdp_group_popup.html',
94 controller: 'editPDPGrouppopupController',
96 message: function () {
98 pdpGroupData : $scope.editPDPGroup
105 var modalInstance = $modal.open({
106 backdrop: 'static', keyboard: false,
107 templateUrl: 'edit_pdp_group_popup.html',
108 controller: 'editPDPGrouppopupController',
110 message: function () {
112 pdpGroupData : $scope.editPDPGroup
119 modalInstance.result.then(function(response){
120 console.log('response', response);
121 $scope.pdpdatas=response.data;
125 $scope.addNewPDPGroupPopUpWindow = function(editPDPGroup) {
126 $scope.editPDPGroup = null;
127 var modalInstance = $modal.open({
128 backdrop: 'static', keyboard: false,
129 templateUrl : 'add_pdp_group_popup.html',
130 controller: 'editPDPGrouppopupController',
132 message: function () {
134 data: $scope.editPDPGroup
140 modalInstance.result.then(function(response){
141 console.log('response', response);
142 $scope.pdpdatas=JSON.parse(response.data);
146 $scope.addNewPDPGroupFunctionPopup = function() {
147 $scope.editPDPGroup = null;
148 $( "#dialog" ).dialog({
153 $scope.removePDPGroup = function(pdpGroupData) {
154 modalService.popupConfirmWin("Confirm","You are about to delete the PDP Group "+pdpGroupData.name+". Do you want to continue?",
156 var uuu = "pdp_Group/remove_pdp_group.htm";
157 var postData={pdpGroupData: pdpGroupData};
162 contentType: 'application/json',
163 data: JSON.stringify(postData),
164 success : function(data){
165 $scope.$apply(function(){$scope.pdpdata=data.data;});
166 $scope.pdpdatas=JSON.parse(data.data);
168 error : function(data){
170 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);