X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=POLICY-SDK-APP%2Fsrc%2Fmain%2Fwebapp%2Fapp%2FpolicyApp%2Fpolicy-models%2FEditor%2FPolicyTemplateController%2FDecisionPolicyController.js;h=72b6f06ca227661d196e474d51a34f1a5decfb65;hb=e92ff832cf993db876f22b2d27562fedf59f5043;hp=f5932e2f4a05aef4b1b2b95e0a3e99842d09e711;hpb=a330af579866dacbe595e2e4ad1dd29cd3c96945;p=policy%2Fengine.git diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js index f5932e2f4..72b6f06ca 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js @@ -17,10 +17,24 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -angular.module('abs').controller('decisionPolicyController', function ($scope, PolicyAppService, modalService, $modal, Notification) { +angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) { $("#dialog").hide(); + + $scope.policyNavigator; $scope.savebutton = true; - $scope.finalPath = null; + $scope.refreshCheck = false; + + $scope.refresh = function(){ + if($scope.refreshCheck){ + $scope.policyNavigator.refresh(); + } + $scope.modal('createNewPolicy', true); + $scope.temp.policy = ""; + }; + + $scope.modal = function(id, hide) { + return $('#' + id).modal(hide ? 'hide' : 'show'); + }; if($scope.temp.policy.ruleProvider==undefined){ $scope.temp.policy.ruleProvider="Custom"; @@ -66,7 +80,25 @@ angular.module('abs').controller('decisionPolicyController', function ($scope, P console.log("failed"); }); + PolicyAppService.getData('getDictionary/get_RainyDayDictionaryDataByName').then(function (data) { + var j = data; + $scope.data = JSON.parse(j.data); + console.log($scope.data); + $scope.rainyDayDictionaryDatas = JSON.parse($scope.data.rainyDayDictionaryDatas); + console.log($scope.rainyDayDictionaryDatas); + }, function (error) { + console.log("failed"); + }); + PolicyAppService.getData('getDictionary/get_RainyDayDictionaryData').then(function (data) { + var j = data; + $scope.data = JSON.parse(j.data); + console.log($scope.data); + $scope.rainyDayDictionaryDataEntity = JSON.parse($scope.data.rainyDayDictionaryDatas); + console.log($scope.rainyDayDictionaryDatasEntity); + }, function (error) { + console.log("failed"); + }); function extend(obj, src) { for (var key in src) { @@ -76,6 +108,11 @@ angular.module('abs').controller('decisionPolicyController', function ($scope, P } $scope.saveDecisionPolicy = function(policy){ + if(policy.itemContent != undefined){ + $scope.refreshCheck = true; + $scope.policyNavigator = policy.itemContent; + policy.itemContent = ""; + } $scope.savebutton = false; console.log(policy); var uuu = "policycreation/save_policy"; @@ -144,19 +181,47 @@ angular.module('abs').controller('decisionPolicyController', function ($scope, P if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){ $scope.temp.policy.attributes = []; - $scope.temp.policy.settings = []; - $scope.temp.policy.ruleAlgorithmschoices = []; - }else{ + $scope.temp.policy.settings = []; + $scope.temp.policy.ruleAlgorithmschoices = []; + if(!$scope.temp.policy.yamlparams){ + $scope.temp.policy.yamlparams = {}; + } + if(!$scope.temp.policy.yamlparams.targets){ + $scope.temp.policy.yamlparams.targets = []; + } + if(!$scope.temp.policy.yamlparams.blackList){ + $scope.temp.policy.yamlparams.blackList = []; + } + if(!$scope.temp.policy.rainyday){ + $scope.temp.policy.rainyday = {}; + } + if(!$scope.temp.policy.rainyday.treatmentTableChoices){ + $scope.temp.policy.rainyday.treatmentTableChoices = []; + } + + }else if($scope.temp.policy.ruleProvider=="Custom"){ if($scope.temp.policy.attributes.length == 0){ - $scope.temp.policy.attributes = []; + $scope.temp.policy.attributes = []; } if($scope.temp.policy.settings.length == 0){ $scope.temp.policy.settings = []; } - if($scope.temp.policy.ruleAlgorithmschoices.length == 0){ + if($scope.temp.policy.ruleAlgorithmschoices == null || $scope.temp.policy.ruleAlgorithmschoices.length == 0){ $scope.temp.policy.ruleAlgorithmschoices = []; } - } + }else if($scope.temp.policy.ruleProvider=="GUARD_BL_YAML"){ + if($scope.temp.policy.yamlparams.blackList.length==0){ + $scope.temp.policy.yamlparams.blackList = []; + } + }else if($scope.temp.policy.ruleProvider=="GUARD_YAML"){ + if($scope.temp.policy.yamlparams.targets.length==0){ + $scope.temp.policy.yamlparams.targets = []; + } + }else if($scope.temp.policy.ruleProvider=="Rainy_Day"){ + if($scope.temp.policy.rainyday.treatmentTableChoices == null || $scope.temp.policy.rainyday.treatmentTableChoices.length == 0){ + $scope.temp.policy.rainyday.treatmentTableChoices = []; + } + } $scope.attributeDatas = [{"attributes" : $scope.temp.policy.attributes}]; $scope.addNewChoice = function() { var newItemNo = $scope.temp.policy.attributes.length+1; @@ -167,7 +232,6 @@ angular.module('abs').controller('decisionPolicyController', function ($scope, P $scope.temp.policy.attributes.splice(lastItem); }; - $scope.settingsDatas = [{"settings" : $scope.temp.policy.settings}]; $scope.addNewSettingsChoice = function() { var newItemNo = $scope.temp.policy.settings.length+1; @@ -178,6 +242,54 @@ angular.module('abs').controller('decisionPolicyController', function ($scope, P $scope.temp.policy.settings.splice(lastItem); }; + $scope.addNewTarget = function(){ + $scope.temp.policy.yamlparams.targets.push(''); + }; + $scope.removeTarget = function(){ + var lastItem = $scope.temp.policy.yamlparams.targets.length-1; + $scope.temp.policy.yamlparams.targets.splice(lastItem); + }; + + $scope.addNewBL = function() { + $scope.temp.policy.yamlparams.blackList.push(''); + }; + $scope.removeBL = function() { + var lastItem = $scope.temp.policy.yamlparams.blackList.length-1; + $scope.temp.policy.yamlparams.blackList.splice(lastItem); + }; + + $scope.treatmentDatas = [{"treatmentValues" : $scope.temp.policy.rainyday.treatmentTableChoices}]; + $scope.addNewTreatment = function() { + $scope.temp.policy.rainyday.treatmentTableChoices.push({}); + }; + $scope.removeTreatment = function() { + var lastItem = $scope.temp.policy.rainyday.treatmentTableChoices.length-1; + $scope.temp.policy.rainyday.treatmentTableChoices.splice(lastItem); + }; + + $scope.workstepDictionaryDatas = []; + $scope.getWorkstepValues = function(bbidValue){ + for (var i = 0; i < $scope.rainyDayDictionaryDataEntity.length; ++i) { + var obj = $scope.rainyDayDictionaryDataEntity[i]; + if (obj.bbid == bbidValue){ + $scope.workstepDictionaryDatas.push(obj.workstep); + } + } + }; + + $scope.allowedTreatmentsDatas = []; + $scope.getTreatmentValues = function(bbidValue, workstepValue){ + for (var i = 0; i < $scope.rainyDayDictionaryDataEntity.length; ++i) { + var obj = $scope.rainyDayDictionaryDataEntity[i]; + if (obj.bbid == bbidValue && obj.workstep == workstepValue){ + var splitAlarm = obj.treatments.split(','); + for (var j = 0; j < splitAlarm.length; ++j) { + $scope.allowedTreatmentsDatas.push(splitAlarm[j]); + } + } + } + }; + $scope.ItemNo = 0; $scope.ruleAlgorithmDatas = [{"ruleAlgorithms" : $scope.temp.policy.ruleAlgorithmschoices }]; @@ -206,4 +318,4 @@ angular.module('abs').controller('decisionPolicyController', function ($scope, P $scope.temp.policy.attributes = []; } }; -}); \ No newline at end of file +}]); \ No newline at end of file