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=========================================================
21 app.controller('pdpTabController', function ($scope,PDPService,modalService, $modal, AdminTabService){
22 $( "#dialog" ).hide();
24 $scope.isDisabled = true;
25 $scope.createPdpGroupId = false;
26 $scope.deletePdpGroupId = false;
27 $scope.editPdpGroupId = false;
29 AdminTabService.getData().then(function(data){
31 $scope.data = JSON.parse(j.data);
32 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
33 if($scope.lockdowndata[0].lockdown == true){
34 $scope.isDisabled = true;
36 $scope.isDisabled = false;
38 console.log($scope.data);
40 AdminTabService.getRolesData().then(function(data) {
42 $scope.data = JSON.parse(j.data);
43 console.log($scope.data);
44 $scope.userRolesDatas = JSON.parse($scope.data.userRolesDatas);
45 console.log($scope.userRolesDatas);
46 if($scope.isDisabled == false){
47 if($scope.userRolesDatas[0] == 'super-admin' || $scope.userRolesDatas[0] == 'admin'){
48 $scope.createPdpGroupId = true;
49 $scope.deletePdpGroupId = true;
50 $scope.editPdpGroupId = true;
51 }else if($scope.userRolesDatas[0] == 'super-editor' || $scope.userRolesDatas[0] == 'editor'){
52 $scope.editPdpGroupId = true;
53 }else if($scope.userRolesDatas[0] == 'super-guest' || $scope.userRolesDatas[0] == 'guest'){
54 $scope.editPdpGroupId = true;
58 PDPService.getPDPGroupEntityData().then(function(data){
60 $scope.pdpdatas = JSON.parse(j.data);
61 console.log($scope.pdpdatas);
63 console.log("failed");
66 console.log("failed");
69 console.log("failed");
73 $scope.addNewPDPGroupFunctionPopup = function() {
74 $scope.editPDPGroup = null;
75 $( "#dialog" ).dialog({
80 $scope.editPDPGroup = null;
82 $scope.editPDPGroupFunctionPopup = function(pdpGroupData) {
83 $scope.editPDPGroup = pdpGroupData;
84 $( "#dialog" ).dialog({
89 $scope.editPDPGroupFunctionModalPopup = function(pdpGroupData) {
90 $scope.editPDPGroup = pdpGroupData;
91 if($scope.userRolesDatas[0] == 'super-guest' || $scope.userRolesDatas[0] == 'guest'){
92 var modalInstance = $modal.open({
93 backdrop: 'static', keyboard: false,
94 templateUrl: 'show_policies_pdp_group_popup.html',
95 controller: 'editPDPGrouppopupController',
97 message: function () {
99 pdpGroupData : $scope.editPDPGroup
106 var modalInstance = $modal.open({
107 backdrop: 'static', keyboard: false,
108 templateUrl: 'edit_pdp_group_popup.html',
109 controller: 'editPDPGrouppopupController',
111 message: function () {
113 pdpGroupData : $scope.editPDPGroup
120 modalInstance.result.then(function(response){
121 console.log('response', response);
122 $scope.pdpdatas=response.data;
126 $scope.addNewPDPGroupPopUpWindow = function(editPDPGroup) {
127 $scope.editPDPGroup = null;
128 var modalInstance = $modal.open({
129 backdrop: 'static', keyboard: false,
130 templateUrl : 'add_pdp_group_popup.html',
131 controller: 'editPDPGrouppopupController',
133 message: function () {
135 data: $scope.editPDPGroup
141 modalInstance.result.then(function(response){
142 console.log('response', response);
143 $scope.pdpdatas=JSON.parse(response.data);
147 $scope.addNewPDPGroupFunctionPopup = function() {
148 $scope.editPDPGroup = null;
149 $( "#dialog" ).dialog({
154 $scope.removePDPGroup = function(pdpGroupData) {
155 modalService.popupConfirmWin("Confirm","You are about to delete the PDP Group "+pdpGroupData.name+". Do you want to continue?",
157 var uuu = "pdp_Group/remove_pdp_group.htm";
158 var postData={pdpGroupData: pdpGroupData};
163 contentType: 'application/json',
164 data: JSON.stringify(postData),
165 success : function(data){
166 $scope.$apply(function(){$scope.pdpdata=data.data;});
167 $scope.pdpdatas=JSON.parse(data.data);
169 error : function(data){
171 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);