diff options
author | Jorge Hernandez <jh1730@att.com> | 2018-02-01 19:43:13 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-02-01 19:43:13 +0000 |
commit | d9b21bad7e932ee60a8f2c64ca42d42cc9eac2cc (patch) | |
tree | 2737611fbb15a9160df8710926c0ce1b2df62517 /POLICY-SDK-APP/src/main/webapp/app/policyApp/controller | |
parent | 06f456d8d06840a21f48531b0bd35b1a429b10f9 (diff) | |
parent | 1148834bc4b10d00c1b1830b087357e63af8293f (diff) |
Merge "Included Policy GUI Enhancements and validations"
Diffstat (limited to 'POLICY-SDK-APP/src/main/webapp/app/policyApp/controller')
-rw-r--r-- | POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/pdpController.js | 32 | ||||
-rw-r--r-- | POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/pdpGroupPopUpController.js | 80 |
2 files changed, 64 insertions, 48 deletions
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/pdpController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/pdpController.js index cab5d26c0..966a0913e 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/pdpController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/pdpController.js @@ -53,14 +53,7 @@ app.controller('pdpTabController', function ($scope, PolicyAppService, modalServ $scope.editPdpGroupId = true; } } - - PolicyAppService.getData('get_PDPGroupData').then(function(data){ - var j = data; - $scope.pdpdatas = JSON.parse(j.data); - console.log($scope.pdpdatas); - },function(error){ - console.log("failed"); - }); + getPDPGroups(); },function (error) { console.log("failed"); }); @@ -77,7 +70,6 @@ app.controller('pdpTabController', function ($scope, PolicyAppService, modalServ }; $scope.editPDPGroup = null; - var dialog = null; $scope.editPDPGroupFunctionPopup = function(pdpGroupData) { $scope.editPDPGroup = pdpGroupData; $( "#dialog" ).dialog({ @@ -87,8 +79,9 @@ app.controller('pdpTabController', function ($scope, PolicyAppService, modalServ $scope.editPDPGroupFunctionModalPopup = function(pdpGroupData) { $scope.editPDPGroup = pdpGroupData; + var modalInstance; if($scope.userRolesDatas[0] == 'super-guest' || $scope.userRolesDatas[0] == 'guest'){ - var modalInstance = $modal.open({ + modalInstance = $modal.open({ backdrop: 'static', keyboard: false, templateUrl: 'show_policies_pdp_group_popup.html', controller: 'editPDPGrouppopupController', @@ -102,7 +95,7 @@ app.controller('pdpTabController', function ($scope, PolicyAppService, modalServ } }); }else{ - var modalInstance = $modal.open({ + modalInstance = $modal.open({ backdrop: 'static', keyboard: false, templateUrl: 'edit_pdp_group_popup.html', controller: 'editPDPGrouppopupController', @@ -118,10 +111,20 @@ app.controller('pdpTabController', function ($scope, PolicyAppService, modalServ } modalInstance.result.then(function(response){ console.log('response', response); - $scope.pdpdatas=response.data; + getPDPGroups(); }); }; + function getPDPGroups(){ + PolicyAppService.getData('get_PDPGroupData').then(function(data){ + var j = data; + $scope.pdpdatas = JSON.parse(j.data); + console.log($scope.pdpdatas); + },function(error){ + console.log("failed"); + }); + } + $scope.addNewPDPGroupPopUpWindow = function(editPDPGroup) { $scope.editPDPGroup = null; var modalInstance = $modal.open({ @@ -161,9 +164,8 @@ app.controller('pdpTabController', function ($scope, PolicyAppService, modalServ dataType: 'json', contentType: 'application/json', data: JSON.stringify(postData), - success : function(data){ - $scope.$apply(function(){$scope.pdpdata=data.data;}); - $scope.pdpdatas=JSON.parse(data.data); + success : function(response){ + $scope.$apply(function(){$scope.pdpdatas=JSON.parse(response.data);}); }, error : function(data){ console.log(data); diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/pdpGroupPopUpController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/pdpGroupPopUpController.js index 4b2747635..0e28dc09f 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/pdpGroupPopUpController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/pdpGroupPopUpController.js @@ -18,15 +18,16 @@ * ============LICENSE_END========================================================= */ app.controller('editPDPGrouppopupController' , function ($scope, $modalInstance, message, modalService, $modal, Notification){ - if(message.pdpGroupData==null) + if(message.pdpGroupData==null){ $scope.label='Add New PDP Group' - else{ - $scope.label='Edit PDP Group' - $scope.disableCd=true; - $scope.policies = message.pdpGroupData.policies; - $scope.pdps = message.pdpGroupData.pdps; - $scope.selectedPdp = message.pdpGroupData; - } + }else{ + $scope.label='Edit PDP Group' + $scope.disableCd=true; + $scope.policies = message.pdpGroupData.policies; + $scope.pdps = message.pdpGroupData.pdps; + $scope.selectedPdp = message.pdpGroupData; + } + $scope.editPDPGroup = message.pdpGroupData; $scope.policiesGrid = { @@ -76,7 +77,7 @@ app.controller('editPDPGrouppopupController' , function ($scope, $modalInstance }); modalInstance.result.then(function(response){ console.log('response', response); - $scope.data=response.data; + refreshPDPGroupDatas(response); }); }; @@ -98,34 +99,34 @@ app.controller('editPDPGrouppopupController' , function ($scope, $modalInstance }); modalInstance.result.then(function(response){ console.log('response', response); - $scope.data=response.data; + refreshPDPGroupDatas(response); }); }; $scope.deletePDPFromGroup = function(data){ modalService.popupConfirmWin("Confirm","You are about to delete the PDP Group : "+data.name+". Do you want to continue?", - function(){ - var uuu = "pdp_Group/remove_pdpFromGroup.htm"; - var postData={data: data, - activePDP : $scope.selectedPdp}; - $.ajax({ - type : 'POST', - url : uuu, - dataType: 'json', - contentType: 'application/json', - data: JSON.stringify(postData), - success : function(data){ - $scope.$apply(function(){$scope.data=data.data;}); - Notification.success("PDP Group Deleted Successfully"); - }, - error : function(data){ - console.log(data); - Notification.error("Error Occured While Deleting a PDP Group") - //modalService.showFailure("Fail","Error while deleting: "+ data.responseText); - } - }); - - }) + function(){ + var uuu = "pdp_Group/remove_pdpFromGroup.htm"; + var postData={data: data, + activePDP : $scope.selectedPdp}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){ + refreshPDPGroupDatas(data); + }); + Notification.success("PDP Group Deleted Successfully"); + }, + error : function(data){ + console.log(data); + Notification.error("Error Occured While Deleting a PDP Group"); + } + }); + }) }; $scope.statusOfPDP = function(status){ @@ -167,10 +168,23 @@ app.controller('editPDPGrouppopupController' , function ($scope, $modalInstance $modalInstance.close({data:$scope.data}); }, error : function(data){ - alert("Error while saving."); + Notification.error("Error while saving PDP Group."); } }); }; + + function refreshPDPGroupDatas(response){ + $scope.selectedPDPName = $scope.selectedPdp.id; + if(response != undefined){ + $scope.data = JSON.parse(response.data); + for(var i=0; i< $scope.data.length; i++){ + if($scope.data[i].id === $scope.selectedPDPName){ + $scope.policies = $scope.data[i].policies; + $scope.pdps = $scope.data[i].pdps; + } + } + } + }; $scope.close = function() { $modalInstance.close(); |