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;
58 console.log("failed");
61 console.log("failed");
65 $scope.addNewPDPGroupFunctionPopup = function() {
66 $scope.editPDPGroup = null;
67 $( "#dialog" ).dialog({
72 $scope.editPDPGroup = null;
73 $scope.editPDPGroupFunctionPopup = function(pdpGroupData) {
74 $scope.editPDPGroup = pdpGroupData;
75 $( "#dialog" ).dialog({
80 $scope.editPDPGroupFunctionModalPopup = function(pdpGroupData) {
81 $scope.editPDPGroup = pdpGroupData;
83 if($scope.userRolesDatas[0] == 'super-guest' || $scope.userRolesDatas[0] == 'guest'){
84 modalInstance = $modal.open({
85 backdrop: 'static', keyboard: false,
86 templateUrl: 'show_policies_pdp_group_popup.html',
87 controller: 'editPDPGrouppopupController',
89 message: function () {
91 pdpGroupData : $scope.editPDPGroup
98 modalInstance = $modal.open({
99 backdrop: 'static', keyboard: false,
100 templateUrl: 'edit_pdp_group_popup.html',
101 controller: 'editPDPGrouppopupController',
103 message: function () {
105 pdpGroupData : $scope.editPDPGroup
112 modalInstance.result.then(function(response){
113 console.log('response', response);
118 function getPDPGroups(){
119 PolicyAppService.getData('get_PDPGroupData').then(function(data){
121 $scope.pdpdatas = JSON.parse(j.data);
122 console.log($scope.pdpdatas);
124 console.log("failed");
128 $scope.addNewPDPGroupPopUpWindow = function(editPDPGroup) {
129 $scope.editPDPGroup = null;
130 var modalInstance = $modal.open({
131 backdrop: 'static', keyboard: false,
132 templateUrl : 'add_pdp_group_popup.html',
133 controller: 'editPDPGrouppopupController',
135 message: function () {
137 data: $scope.editPDPGroup
143 modalInstance.result.then(function(response){
144 console.log('response', response);
145 $scope.pdpdatas=JSON.parse(response.data);
149 $scope.addNewPDPGroupFunctionPopup = function() {
150 $scope.editPDPGroup = null;
151 $( "#dialog" ).dialog({
156 $scope.removePDPGroup = function(pdpGroupData) {
157 modalService.popupConfirmWin("Confirm","You are about to delete the PDP Group "+pdpGroupData.name+". Do you want to continue?",
159 var uuu = "pdp_Group/remove_pdp_group.htm";
160 var postData={pdpGroupData: pdpGroupData};
165 contentType: 'application/json',
166 data: JSON.stringify(postData),
167 success : function(response){
168 $scope.$apply(function(){$scope.pdpdatas=JSON.parse(response.data);});
170 error : function(data){
172 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);