From 95524c8ef8be0d41de8bb2b918f320e464ebb897 Mon Sep 17 00:00:00 2001 From: rb7147 Date: Wed, 18 Jul 2018 12:50:06 -0400 Subject: Decision BlackList Guard Enhancements While creating a decision Bl Guard Policy we are allowing to add Blacklist entries through file upload for bulk from GUI. Issue-ID: POLICY-901 Change-Id: I4031fd4a96937b9facc330cecf72777d701d4678 Signed-off-by: rb7147 --- .../DecisionPolicyController.js | 121 ++++- .../PolicyTemplates/DecisionPolicyTemplate.html | 516 ++++++++++++--------- 2 files changed, 412 insertions(+), 225 deletions(-) (limited to 'POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models') 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 5b2bdb2b2..f560f4d58 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,14 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) { +angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', '$http', function ($scope, PolicyAppService, PolicyNavigator, modalService, $modal, Notification, $http) { $("#dialog").hide(); $scope.policyNavigator; $scope.savebutton = true; $scope.refreshCheck = false; + $scope.disableOnCreate = false; if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){ + $scope.disableOnCreate = true; $scope.temp.policy = { policyType : "Decision" } @@ -45,7 +47,11 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA if($scope.temp.policy.ruleProvider==undefined){ $scope.temp.policy.ruleProvider="Custom"; } - + + if($scope.temp.policy.blackListEntryType==undefined){ + $scope.temp.policy.blackListEntryType="Use Manual Entry"; + } + PolicyAppService.getData('getDictionary/get_OnapNameDataByName').then(function (data) { var j = data; $scope.data = JSON.parse(j.data); @@ -216,9 +222,15 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA $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 = []; - } + if($scope.temp.policy.yamlparams.blackList == null || $scope.temp.policy.yamlparams.blackList.length==0){ + $scope.temp.policy.yamlparams.blackList = []; + } + if($scope.temp.policy.blackListEntries == null || $scope.temp.policy.blackListEntries.length==0){ + $scope.temp.policy.blackListEntries = []; + } + $scope.blackListEntries = []; + $scope.temp.policy.appendBlackListEntries = []; + $scope.blackListEntries = arrayUnique($scope.temp.policy.blackListEntries.concat($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 = []; @@ -259,9 +271,11 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA $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.removeBL = function(id) { + $scope.temp.policy.yamlparams.blackList = $scope.temp.policy.yamlparams.blackList.filter(function (obj){ + return obj !== id; + }); }; $scope.treatmentDatas = [{"treatmentValues" : $scope.temp.policy.rainyday.treatmentTableChoices}]; @@ -324,4 +338,93 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA $scope.temp.policy.attributes = []; } }; + + $scope.importButton = true; + var fd; + $scope.uploadBLFile = function(files) { + fd = new FormData(); + fd.append("file", files[0]); + var fileExtension = files[0].name.split(".")[1]; + if(fileExtension == "xls"){ + $scope.importButton = false; + $scope.$apply(); + }else{ + Notification.error("Upload the BlackList file which extends with .xls format."); + } + }; + + function arrayUnique(array) { + var a = array.concat(); + for(var i=0; i + ng-model="temp.policy.policyDescription" + title="Description field will accept any type of data." />
@@ -41,7 +41,8 @@ class="form-control" ng-disabled="temp.policy.readOnly" ng-model="temp.policy.onapName" ng-options="option for option in onapNameDictionaryDatas track by option" - required pattern="\S+" title="Select the dropdown value driven from OnapName (common)Dictionary."> + required pattern="\S+" + title="Select the dropdown value driven from OnapName (common)Dictionary.">
@@ -67,39 +68,40 @@
+ ng-disabled="temp.policy.readOnly" + ng-model="temp.policy.rainyday.serviceType" + placeholder="Service Type" title="Enter Service Type value." />
+ ng-disabled="temp.policy.readOnly" + ng-model="temp.policy.rainyday.vnfType" placeholder="VNF Type" + title="Enter VNF Type value." />
- +
- +
@@ -107,46 +109,44 @@
-
-
-
- -
-
- -
-
- -
-
- -
-
- +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
-
@@ -158,86 +158,145 @@
-
-
- -
-
- -
+
+
+
-
-
- -
-
- -
+
+
-
-
- -
-
- -
+
+
+
+
-
-
- -
-
- -
+
+
-
-
- -
-
- -
+
+
+
+
-
-
- - -
-
-
-
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ + +
+
+
+
+ ng-disabled="temp.policy.readOnly" + ng-model="temp.policy.yamlparams.blackList[$index]" + placeholder="BlackList" />
-
-
+
- +
@@ -246,113 +305,122 @@
-
-
- -
-
- -
+
+
+
-
-
- -
-
- -
+
+
-
-
- -
-
- -
+
+
+
+
-
-
- - -
-
-
-
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ + +
+
+
+
+ ng-disabled="temp.policy.readOnly" + ng-model="temp.policy.yamlparams.targets[$index]" + placeholder="Target" />
-
-
-
- -
-
- -
+
+
+
+
-
-
- -
-
- -
-
- +
+
+
+
+ +
+
+ +
+
+ -
+
-
-
- -
-
- -
+
+
+
+
-
-
- -
-
- -
+
+ +
+
+
+
+
+
+ +
+
@@ -364,7 +432,8 @@

@@ -375,18 +444,21 @@
+ placeholder="Attribute Value" + title="Enter the Attribute Value without any spaces and special characters" />
@@ -403,7 +475,8 @@
@@ -414,19 +487,22 @@
+ ng-model="settingschoice.value" placeholder="Settings Value" + title="Enter the Settings Attribute Value without any spaces and special characters" />
@@ -443,7 +519,8 @@
@@ -462,7 +539,8 @@ ng-disabled="temp.policy.readOnly" ng-model="ruleAlgorithmschoice.dynamicRuleAlgorithmField1" ng-options="option for option in attributeDictionaryDatas track by option" - name="dynamicRuleAlgorithmField1" title="Select the dropdown value driven from Attribute (common)Dictionary or Settings (Decision)Dictionary."> + name="dynamicRuleAlgorithmField1" + title="Select the dropdown value driven from Attribute (common)Dictionary or Settings (Decision)Dictionary.">
@@ -471,18 +549,21 @@ ng-disabled="temp.policy.readOnly" ng-model="ruleAlgorithmschoice.dynamicRuleAlgorithmCombo" ng-options="option for option in functionDefinitionDatas track by option" - name="dynamicRuleAlgorithmCombo" title="Select the dropdown value driven from FunctionDataType."> + name="dynamicRuleAlgorithmCombo" + title="Select the dropdown value driven from FunctionDataType.">
+ name="dynamicRuleAlgorithmField2" + title="Enter the Value without any spaces and special characters and for rule formation use A1, A2,..etc., based on above Rules." />
@@ -497,11 +578,14 @@
\ No newline at end of file -- cgit 1.2.3-korg