X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=POLICY-SDK-APP%2Fsrc%2Fmain%2Fwebapp%2Fapp%2FpolicyApp%2Fcontroller%2FpdpGroupPopUpController.js;h=0e28dc09f5f764e6809615123e4680c795d48242;hb=refs%2Fchanges%2F21%2F30021%2F4;hp=4b27476352acd18616390b99f419790789a0175f;hpb=066fc4529f36d210a4a4700e8dbfd2cb42f4dc66;p=policy%2Fengine.git 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();