diff options
Diffstat (limited to 'POLICY-SDK-APP/src/main/webapp/app')
10 files changed, 597 insertions, 140 deletions
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/MSModelDictionaryData.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/MSModelDictionaryData.html new file mode 100644 index 000000000..2a7d49cb7 --- /dev/null +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/MSModelDictionaryData.html @@ -0,0 +1,59 @@ +<!--/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2019 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */--> +<script type="text/ng-template" id="add_dictionaryData_popup.html"> +<div class="modal" tabindex="-1"> + <div class="modal-dialog modal-lg"> + <div class="modal-content"> + <div class="modal-header"> + <h2 class="font-showcase-font-name" style="color : #157bb2">{{label}}</h2> + </div> + <form name="formdata" ng-submit="saveMSDictionatyData(editMSDictData);" novalidate> + <div class="modal-body"> + <div class="form-group row"> + <div class="form-group col-sm-6"> + <label>Dictionary Name:<sup><b>*</b></sup></label><br> + <input type="text" ng-model="editMSDictData.dictionaryName" class="form-control" name= "dictionaryName" required/> + <p ng-show="formdata.name.$invalid && !formdata.name.$pristine" class="help-block">Dictionary Name is required.</p> + </div> + </div> + <div class="form-group row"> + <div class="form-group col-sm-6"> + <label>URL:<sup><b>*</b></sup></label><br> + <input type="text" ng-model="editMSDictData.dictionaryUrl" class="form-control" name= "dictionaryUrl" required/> + <p ng-show="formdata.name.$invalid && !formdata.name.$pristine" class="help-block">URL is required.</p> + </div> + </div> + <div class="form-group row"> + <div class="form-group col-sm-6"> + <label>Dictionary Data Name:<sup><b>*</b></sup></label><br> + <input type="text" ng-model="editMSDictData.dictionaryDataByName" class="form-control" name= "dictionaryDataByName" required/> + <p ng-show="formdata.name.$invalid && !formdata.name.$pristine" class="help-block">Dictionary Data Name is required.</p> + </div> + </div> + </div> + <div class="modal-footer"> + <button class="btn btn-success" type="submit" ng-disabled="formdata.$invalid">Save</button> + <button class="btn btn-default" type="button" ng-click="close()">Close</button> + </div> + </form> + </div> + </div> +</div> +</script> diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/DictionaryController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/DictionaryController.js index d12523879..6becb28e6 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/DictionaryController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/DictionaryController.js @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. @@ -27,7 +27,7 @@ var subDictionarys = [["Action Dictionary"], ["Settings Dictionary","Rainy Day Allowed Treatments"], ["Descriptive Scope"], ["Action List", "Address Group", "Parent Dictionary List", "Port List", "Prefix List", "Protocol List", "Security Zone", "Service Group", "Service List", "Tag List", "Tag Picker List", "Term List", "Zone"], - ["DCAE UUID","Header Default Values","MicroService ConfigName","MicroService Location", "MicroService Models", "MicroService Dictionary"], + ["DCAE UUID","Header Default Values","MicroService ConfigName","MicroService Location", "MicroService Models", "MicroService Dictionary","MicroService Dictionary Input"], ["ONAP Optimization Models"], ["Closed Loop", "Group Policy Scope", "Resource", "Service", "Type"], ["Risk Type", "Safe Policy Warning"]]; @@ -79,4 +79,4 @@ app.controller('dictionaryTabController', function ($scope, PolicyAppService, mo }); }; -});
\ No newline at end of file +}); diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSDictionaryController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSDictionaryController.js new file mode 100644 index 000000000..21b89697d --- /dev/null +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSDictionaryController.js @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2019 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +app.controller('editMSDictController' , function ($scope, $modalInstance, message, UserInfoServiceDS2, Notification){ + if(message.microServiceDictionaryDatas==null) + $scope.label='Add Dictionary input' + else{ + $scope.label='Edit Dictionary input' + $scope.disableCd=true; + } + + + /*getting user info from session*/ + var userid = null; + UserInfoServiceDS2.getFunctionalMenuStaticDetailSession() + .then(function (response) { + userid = response.userid; + }); + + $scope.editMSDictData = message.microServiceDictionaryDatas; + + $scope.saveMSDictionatyData = function(microServiceDictionaryDatas) { + var regex = new RegExp("^[a-zA-Z0-9_]*$"); + if(!regex.test(microServiceDictionaryDatas.name)) { + Notification.error("Enter Valid Dictionary Name without spaces or special characters"); + }else{ + var uuu = "saveDictionary/ms_dictionary/save_DictionaryData"; + var postData={microServiceDictionaryDatas: microServiceDictionaryDatas, userid: userid}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){ + $scope.microServiceDictionaryDatas=data.microServiceDictionaryDatas;}); + if($scope.microServiceDictionaryDatas == "Duplicate"){ + Notification.error("MS Dictionary data exists with Same Name.") + }else{ + console.log($scope.microServiceDictionaryDatas); + $modalInstance.close({microServiceDictionaryDatas:$scope.microServiceDictionaryDatas}); + } + }, + error : function(data){ + alert("Error while saving."); + } + }); + } + }; + + $scope.close = function() { + $modalInstance.close(); + }; +});
\ No newline at end of file diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSModelsDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSModelsDictController.js index 262b2adea..abecfdbbd 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSModelsDictController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSModelsDictController.js @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. @@ -65,6 +65,7 @@ app.controller('editMSModelController' , function ($scope, $modalInstance, mess $scope.modalDatas = data.modelDatas; $scope.modelType= data.modelType; $scope.dataOrderInfo= data.dataOrderInfo; + $scope.ruleFormation = data.ruleFormation; console.log($scope.classListDatas); } }).error( ); @@ -78,7 +79,7 @@ app.controller('editMSModelController' , function ($scope, $modalInstance, mess $scope.saveMSModel = function(microServiceModelsDictionaryData) { if(valid){ var uuu = "saveDictionary/ms_dictionary/save_model"; - var postData={microServiceModelsDictionaryData: microServiceModelsDictionaryData, userid: userid, classMap: $scope.modalDatas,modelType:$scope.modelType, dataOrderInfo:$scope.dataOrderInfo}; + var postData={microServiceModelsDictionaryData: microServiceModelsDictionaryData, userid: userid, classMap: $scope.modalDatas,modelType:$scope.modelType, dataOrderInfo:$scope.dataOrderInfo, ruleFormation:$scope.ruleFormation}; $.ajax({ type : 'POST', url : uuu, @@ -108,4 +109,4 @@ app.controller('editMSModelController' , function ($scope, $modalInstance, mess $scope.close = function() { $modalInstance.close(); }; -});
\ No newline at end of file +}); diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/MSModelDictionaryDataController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/MSModelDictionaryDataController.js new file mode 100644 index 000000000..c4234b969 --- /dev/null +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/MSModelDictionaryDataController.js @@ -0,0 +1,127 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2019 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +app.controller('MSModelDictionaryDataController', function ($scope, PolicyAppService, modalService, $modal){ + $( "#dialog" ).hide(); + + PolicyAppService.getData('getDictionary/get_MicroServiceDictData').then(function (data) { + var j = data; + $scope.data = JSON.parse(j.data); + console.log($scope.data); + $scope.microServiceDictionaryDatas = JSON.parse($scope.data.microServiceDictionaryDatas); + console.log($scope.microServiceDictionaryDatas); + }, function (error) { + console.log("failed"); + }); + + PolicyAppService.getData('get_LockDownData').then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + $scope.lockdowndata = JSON.parse($scope.data.lockdowndata); + $scope.msModelsDictionaryDataGrid.columnDefs[0].visible = !$scope.lockdowndata[0].lockdown; + $scope.gridApi.grid.refresh(); + },function(error){ + console.log("failed"); + }); + + $scope.msModelsDictionaryDataGrid = { + data : 'microServiceDictionaryDatas', + enableFiltering: true, + columnDefs: [{ + field: 'id', enableFiltering: false, headerCellTemplate: '' + + '<button id=\'New\' ng-click="grid.appScope.createNewMSDictNameWindow()" class="btn btn-success">' + 'Create</button>', + cellTemplate: + '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editMSDictNameWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' + + '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteMSDictName(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%' + },{ field: 'dictionaryName', displayName : 'Dictionary Name', sort: { direction: 'asc', priority: 0 }}, + { field: 'dictionaryUrl', displayName : 'URL' }, + {field: 'dictionaryDataByName', displayName : 'Dictionary Data Name'} + ], + onRegisterApi: function(gridApi){ + $scope.gridApi = gridApi; + } + }; + + $scope.editMSDictData = null; + $scope.createNewMSDictNameWindow = function(){ + $scope.editMSDictData = null; + var modalInstance = $modal.open({ + backdrop: 'static', keyboard: false, + templateUrl : 'add_dictionaryData_popup.html', + controller: 'editMSDictController', + resolve: { + message: function () { + var message = { + microServiceDictionaryDatas: $scope.editMSDictData + }; + return message; + } + } + }); + modalInstance.result.then(function(response){ + console.log('response', response); + $scope.microServiceDictionaryDatas=response.microServiceDictionaryDatas; + }); + }; + + $scope.editMSDictNameWindow = function(microServiceDictionaryDatas) { + $scope.editMSDictData = microServiceDictionaryDatas; + var modalInstance = $modal.open({ + backdrop: 'static', keyboard: false, + templateUrl : 'add_dictionaryData_popup.html', + controller: 'editMSDictController', + resolve: { + message: function () { + var message = { + microServiceDictionaryDatas: $scope.editMSDictData + }; + return message; + } + } + }); + modalInstance.result.then(function(response){ + console.log('response', response); + $scope.microServiceDictionaryDatas = response.microServiceDictionaryDatas; + }); + }; + + $scope.deleteMSDictName = function(data) { + modalService.popupConfirmWin("Confirm","You are about to delete the Micro Service Config Name "+data.name+". Do you want to continue?", + function(){ + var uuu = "deleteDictionary/ms_dictionary/remove_msDictionaryData"; + var postData={data: data}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){$scope.microServiceDictionaryDatas=data.microServiceDictionaryDatas;}); + }, + error : function(data){ + console.log(data); + modalService.showFailure("Fail","Error while deleting: "+ data.responseText); + } + }); + + }) + }; + +});
\ No newline at end of file diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html index 430907a65..6efb8b637 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. @@ -158,6 +158,7 @@ <script src= "app/policyApp/controller/dictionaryGridController/MSHeaderDefaultValuesDictGridController.js"></script> <script src= "app/policyApp/controller/dictionaryGridController/MSDcaeUUIDDictGridController.js"></script> <script src= "app/policyApp/controller/dictionaryGridController/MSLocationDictGridController.js"></script> + <script src= "app/policyApp/controller/dictionaryGridController/MSModelDictionaryDataController.js"></script> <script src= "app/policyApp/controller/dictionaryGridController/MSModelDictGridController.js"></script> <script src= "app/policyApp/controller/dictionaryGridController/ModelAttributeDictGridController.js"></script> <script src= "app/policyApp/controller/dictionaryGridController/OptimizationModelDictGridController.js"></script> @@ -201,6 +202,7 @@ <script src= "app/policyApp/controller/dictionaryController/FWZoneDictController.js"></script> <script src= "app/policyApp/controller/dictionaryController/MSHeaderDefaultValuesDictController.js"></script> <script src= "app/policyApp/controller/dictionaryController/MSConfigNameDictController.js"></script> + <script src= "app/policyApp/controller/dictionaryController/MSDictionaryController.js"></script> <script src= "app/policyApp/controller/dictionaryController/MSDcaeUUIDDictController.js"></script> <script src= "app/policyApp/controller/dictionaryController/MSLocationDictController.js"></script> <script src= "app/policyApp/controller/dictionaryController/MSModelsDictController.js"></script> @@ -268,6 +270,7 @@ <div ng-include src="'app/policyApp/Windows/Dictionary/MSDCAEUUIDDictionary.html'"></div> <div ng-include src="'app/policyApp/Windows/Dictionary/MSLocationDictionary.html'"></div> <div ng-include src="'app/policyApp/Windows/Dictionary/MSModelsDictionary.html'"></div> + <div ng-include src="'app/policyApp/Windows/Dictionary/MSModelDictionaryData.html'"></div> <div ng-include src="'app/policyApp/Windows/Dictionary/ModelAttributeDictionary.html'"></div> <div ng-include src="'app/policyApp/Windows/Dictionary/OptimizationModelsDictionary.html'"></div> <div ng-include src="'app/policyApp/Windows/Dictionary/PSClosedLoopDictionary.html'"></div> diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Dictionary/MSModelDictionaryData.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Dictionary/MSModelDictionaryData.html new file mode 100644 index 000000000..3238d023e --- /dev/null +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Dictionary/MSModelDictionaryData.html @@ -0,0 +1,22 @@ +<!--/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2019 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */--> +<div ng-app ng-controller = "MSModelDictionaryDataController"> + <div ui-grid = "msModelsDictionaryDataGrid" ui-grid-pagination ui-grid-selection ui-grid-exporter class= "grid"></div> +</div>
\ No newline at end of file diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js index 5a3c62e3c..cffa46f53 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. @@ -272,6 +272,10 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind if (checkValue!=undefined && checkValue!="undefined"){ if($scope.temp.policy.ruleData != null){ var checkValue = $scope.temp.policy.ruleData[selects[i].id]; + var option = document.createElement('option'); + option.setAttribute('value', checkValue); + option.appendChild(document.createTextNode(checkValue)); + document.getElementById(selects[i].id).appendChild(option); document.getElementById(selects[i].id).value = $scope.temp.policy.ruleData[selects[i].id]; plainAttributeKeys.push(selects[i].id); } @@ -1033,25 +1037,25 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind textField.setAttribute("class" , "form-control"); if(dataType){ - if(dataType == "double"){ - textField.setAttribute("type" , "number"); - textField.setAttribute("step" , "any"); - - }else if(dataType == "boolean"){ //gw1218 testing boolean - var booleanDiv = document.createElement("div"); - - booleanDiv.setAttribute("class" , "onoffswitch"); - - //var checkField = document.createElement("INPUT"); - textField.setAttribute("type" , "checkbox"); - textField.setAttribute("name" , "onoffswitch"); - textField.setAttribute("class" , "onoffswitch-checkbox"); - textField.setAttribute("id" , ''+labelValue +attibuteKey+''); - if(defaultValue && defaultValue == "true") { - textField.setAttribute("checked" , "true"); - }else{ - textField.setAttribute("checked" , "false"); - } + if(dataType == "double"){ + textField.setAttribute("type" , "number"); + textField.setAttribute("step" , "any"); + + }else if(dataType == "boolean"){ //gw1218 testing boolean + var booleanDiv = document.createElement("div"); + + booleanDiv.setAttribute("class" , "onoffswitch"); + + //var checkField = document.createElement("INPUT"); + textField.setAttribute("type" , "checkbox"); + textField.setAttribute("name" , "onoffswitch"); + textField.setAttribute("class" , "onoffswitch-checkbox"); + textField.setAttribute("id" , ''+labelValue +attibuteKey+''); + if(defaultValue.substring(0,defaultValue.indexOf(":")) == "true") { + textField.setAttribute("checked" , true); + }else{ + textField.removeAttribute("checked"); + } var booleanlabel = document.createElement("Label"); booleanlabel.setAttribute("class" , "onoffswitch-label"); @@ -1355,31 +1359,62 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind requiredNodeToolTip.textContent = "Conditional Required"; requiredNode.appendChild(requiredNodeToolTip); + } + + var listField = document.createElement("SELECT"); + listField.setAttribute("class" , "form-control"); + listField.setAttribute("style" , "width:300px;"); + listField.setAttribute("ng-disabled" , "temp.policy.readOnly"); + + if(description && description != "null"){ + listField.setAttribute("title", description); + } + + if(isRequired){ + if(document.getElementById(divID).hasAttribute('data-conditional')){ + listField.setAttribute("data-conditional", divID); + listField.setAttribute("ng-blur", "validContionalRequired('"+divID+"')"); + }else{ + listField.setAttribute("required", true); } - - var listField = document.createElement("SELECT"); - listField.setAttribute("class" , "form-control"); - listField.setAttribute("style" , "width:300px;"); - listField.setAttribute("ng-disabled" , "temp.policy.readOnly"); - - if(description && description != "null"){ - listField.setAttribute("title", description); - } - - if(isRequired){ - if(document.getElementById(divID).hasAttribute('data-conditional')){ - listField.setAttribute("data-conditional", divID); - listField.setAttribute("ng-blur", "validContionalRequired('"+divID+"')"); - }else{ - listField.setAttribute("required", true); - } - } - if( many != true || isRequired != true){ // add an empty option for not required or not multiple select element - var optionFirst = document.createElement('option'); - optionFirst.setAttribute('value', ""); - listField.appendChild(optionFirst); + } + if( many != true || isRequired != true){ // add an empty option for not required or not multiple select element + var optionFirst = document.createElement('option'); + var optionValue = ""; + if($scope.temp.policy.ruleData != null){ + if($scope.temp.policy.ruleData[labelLevel + attributeName] != undefined && $scope.temp.policy.ruleData[labelLevel + attributeName] != "undefined"){ + optionValue = $scope.temp.policy.ruleData[labelLevel + attributeName]; + } + } + optionFirst.setAttribute('value', optionValue); + optionFirst.appendChild(document.createTextNode(optionValue)); + listField.appendChild(optionFirst); + } + var ruleFormationCheck = false; + if(listemunerateValues.length !== 0 && typeof listemunerateValues[0] == "string" && listemunerateValues[0].includes("dictionary:")) { + var ruleCheck = listemunerateValues[0].split("&"); + var dictParams = ruleCheck[0].split(":"); + var dictParamsSplit = dictParams[1].split("@"); + if (ruleCheck[1] != undefined && ruleCheck[1] == 'Rule') { + ruleFormationCheck = true; } - + PolicyAppService.getData(dictParamsSplit[0]).then(function (data) { + var j = data; + $scope.data = JSON.parse(j.data); + console.log($scope.data); + $scope.listDictionarys = JSON.parse($scope.data[dictParamsSplit[1]]); + for (i=0; i < $scope.listDictionarys.length; i += 1) { + option = document.createElement('option'); + option.setAttribute('value', $scope.listDictionarys[i]); + option.appendChild(document.createTextNode($scope.listDictionarys[i])); + listField.appendChild(option); + } + }, function (error) { + console.log("failed"); + }); + + } + else{ for (i=0; i < listemunerateValues.length; i += 1) { if(typeof listemunerateValues[i] == "string" && listemunerateValues[i].includes("equal-sign")){ listemunerateValues[i] = listemunerateValues[i].replace('equal-sign','='); @@ -1391,95 +1426,130 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind option.setAttribute('value', listemunerateValues[i]); listField.appendChild(option); } - listField.setAttribute("id" , ''+ labelLevel + attributeName + ''); - - enumKeyList.push(attributeName); - - document.getElementById(divID).appendChild(label); - document.getElementById(divID).appendChild(br); - - if(many == true){ - document.getElementById(divID).appendChild(listField).multiple = true; - plainAttributeKeys.push(labelLevel + attributeName+'*'+true); - }else { - document.getElementById(divID).appendChild(listField).multiple = false; - plainAttributeKeys.push(labelLevel + attributeName+'*'+false); - - if (defaultValue){ - if(defaultValue.includes(':')){ - defaultValue = defaultValue.split(':')[0]; - } - var location = listemunerateValues.indexOf(defaultValue); - document.getElementById(labelLevel +attributeName).options[location+1].selected = true; + } + listField.setAttribute("id" , ''+ labelLevel + attributeName + ''); + + enumKeyList.push(attributeName); + + document.getElementById(divID).appendChild(label); + document.getElementById(divID).appendChild(br); + + if(many == true){ + document.getElementById(divID).appendChild(listField).multiple = true; + plainAttributeKeys.push(labelLevel + attributeName+'*'+true); + }else { + document.getElementById(divID).appendChild(listField).multiple = false; + plainAttributeKeys.push(labelLevel + attributeName+'*'+false); + + if (defaultValue){ + if(defaultValue.includes(':')){ + defaultValue = defaultValue.split(':')[0]; } + var location = listemunerateValues.indexOf(defaultValue); + document.getElementById(labelLevel +attributeName).options[location+1].selected = true; } - - if($scope.temp.policy.ruleData != null){ - if (many == true){ - document.getElementById(labelLevel +attributeName).options[0].selected = false; - for (i=0; i < listemunerateValues.length; i += 1) { - var testValue = $scope.temp.policy.ruleData[labelLevel +attributeName+'@' + i]; - if (testValue === undefined){ - testValue = $scope.temp.policy.ruleData[labelLevel +attributeName]; - } - var location = listemunerateValues.indexOf(testValue); - if (location!=-1){ - document.getElementById(labelLevel +attributeName).options[location].selected = true; - } - } - }else { - if($scope.temp.policy.ruleData[labelLevel + attributeName] != undefined && $scope.temp.policy.ruleData[labelLevel + attributeName] != "undefined"){ - document.getElementById(labelLevel + attributeName).value = $scope.temp.policy.ruleData[labelLevel + attributeName]; - } + } + + if (ruleFormationCheck) { + var optionInput = document.createElement("INPUT"); + optionInput.setAttribute("type" , "text"); + optionInput.setAttribute("id" , ''+ labelLevel + attributeName + '.input'); + optionInput.setAttribute("name" , "ruleName"); + optionInput.setAttribute("value" , " "); + optionInput.setAttribute("style" , "width:300px;"); + optionInput.setAttribute("ng-disabled" , "temp.policy.readOnly"); + optionInput.removeAttribute("required"); + + document.getElementById(divID).appendChild(optionInput); + + var optionButton = document.createElement("BUTTON"); + optionButton.setAttribute("ng-disabled" , "temp.policy.readOnly"); + var buttonLabel = document.createTextNode("+"); + optionButton.appendChild(buttonLabel); + optionButton.setAttribute("class", "btn btn-add-remove"); + optionButton.setAttribute("onclick" , 'addDynamicOptions("'+ labelLevel + attributeName + '");'); + optionButton.removeAttribute("required"); + + + document.getElementById(divID).appendChild(optionButton); + document.getElementById(divID).appendChild(br); + } + + if($scope.temp.policy.ruleData != null){ + if (many == true){ + document.getElementById(labelLevel +attributeName).options[0].selected = false; + for (i=0; i < listemunerateValues.length; i += 1) { + var testValue = $scope.temp.policy.ruleData[labelLevel +attributeName+'@' + i]; + if (testValue === undefined){ + testValue = $scope.temp.policy.ruleData[labelLevel +attributeName]; } + var location = listemunerateValues.indexOf(testValue); + if (location!=-1){ + document.getElementById(labelLevel +attributeName).options[location].selected = true; + } + } + }else { + if($scope.temp.policy.ruleData[labelLevel + attributeName] != undefined && $scope.temp.policy.ruleData[labelLevel + attributeName] != "undefined"){ + document.getElementById(labelLevel + attributeName).value = $scope.temp.policy.ruleData[labelLevel + attributeName]; } - }; - - function onlyUnique(value, index, self) { - return self.indexOf(value) === index; - }; - - - function checkDictionary(value){ - for (i = 0; i < $scope.microServiceAttributeDictionaryDatas.length; i++) { - if ($scope.microServiceAttributeDictionaryDatas[i].name.localeCompare(value)){ - return true; - } - } - - } - $scope.savePolicy = function(policy){ - if(policy.itemContent != undefined){ - $scope.refreshCheck = true; - $scope.policyNavigator = policy.itemContent; - policy.itemContent = ""; - } - $scope.savebutton = false; - var splitAt = '*'; - var dot ='.'; - var jsonPolicy = {}; - if(plainAttributeKeys != null){ - for(a = 0; a < plainAttributeKeys.length; a++){ - var splitPlainAttributeKey = plainAttributeKeys[a].split(splitAt); - console.log("splitPlainAttributeKey: " + splitPlainAttributeKey); - var searchElement = document.getElementById(splitPlainAttributeKey[0]); - var key = splitPlainAttributeKey[0]; - if(searchElement == null){ - searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0'); - key = splitPlainAttributeKey[0]+'@0'; - }else if (searchElement.nodeName == 'BUTTON'){ - searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0'); - key = splitPlainAttributeKey[0]+'@0'; - } - if(searchElement != null){ - var keySplit = key.split(dot); - var elumentLocation = keySplit.length; - var enumKey = key; - if (elumentLocation > 1){ - enumKey = keySplit[keySplit.length - 1]; - } - //check it is undefined or not - if (enumKeyList != undefined && enumKeyList.indexOf(enumKey) != -1){ + } + } + }; + + addDynamicOptions = function(id) { + var option = document.createElement("option"); + var value = document.getElementById(id+".input").value; + option.setAttribute('value', value); + option.appendChild(document.createTextNode(value)); + document.getElementById(id).options.add(option); + document.getElementById(id+".input").value = ""; + }; + + function onlyUnique(value, index, self) { + return self.indexOf(value) === index; + }; + + + function checkDictionary(value){ + for (i = 0; i < $scope.microServiceAttributeDictionaryDatas.length; i++) { + if ($scope.microServiceAttributeDictionaryDatas[i].name.localeCompare(value)){ + return true; + } + } + + } + $scope.savePolicy = function(policy){ + if(policy.itemContent != undefined){ + $scope.refreshCheck = true; + $scope.policyNavigator = policy.itemContent; + policy.itemContent = ""; + } + $scope.savebutton = false; + var splitAt = '*'; + var dot ='.'; + var jsonPolicy = {}; + if(plainAttributeKeys != null){ + for(a = 0; a < plainAttributeKeys.length; a++){ + var splitPlainAttributeKey = plainAttributeKeys[a].split(splitAt); + console.log("splitPlainAttributeKey: " + splitPlainAttributeKey); + var searchElement = document.getElementById(splitPlainAttributeKey[0]); + var key = splitPlainAttributeKey[0]; + if(searchElement == null){ + searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0'); + key = splitPlainAttributeKey[0]+'@0'; + }else if (searchElement.nodeName == 'BUTTON'){ + searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0'); + key = splitPlainAttributeKey[0]+'@0'; + } + if(searchElement != null){ + var keySplit = key.split(dot); + var elumentLocation = keySplit.length; + var enumKey = key; + if (elumentLocation > 1){ + enumKey = keySplit[keySplit.length - 1]; + } + //check it is undefined or not + if (enumKeyList != undefined && enumKeyList.indexOf(enumKey) != -1){ if (splitPlainAttributeKey[1]!= undefined && splitPlainAttributeKey[1].indexOf("true") !== -1){ var multiSlect = []; for ( var i = 0; i < searchElement.selectedOptions.length; i++) { @@ -1722,4 +1792,4 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind } }); -}]);
\ No newline at end of file +}]); diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/css/main.css b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/css/main.css index d7c98b98c..81d91d90b 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/css/main.css +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/css/main.css @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. @@ -550,4 +550,107 @@ table th > a:focus { border: 0px solid grey; border-left: none; cursor: pointer; -}
\ No newline at end of file +} + +.switch { + position: relative; + display: inline-block; + width: 60px; + height: 34px; +} + +.switch input {display:none;} + +.slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #ccc; + -webkit-transition: .4s; + transition: .4s; +} + +.slider:before { + position: absolute; + content: ""; + height: 26px; + width: 26px; + left: 4px; + bottom: 4px; + background-color: white; + -webkit-transition: .4s; + transition: .4s; +} + +input:checked + .slider { + background-color: blue; +} + +input:focus + .slider { + box-shadow: 0 0 1px blue; +} + +input:checked + .slider:before { + -webkit-transform: translateX(26px); + -ms-transform: translateX(26px); + transform: translateX(26px); +} + +/* Rounded sliders */ +.slider.round { + border-radius: 34px; +} + +.slider.round:before { + border-radius: 50%; +} + + +.onoffswitch { + position: relative; width: 90px; + -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none; +} +.onoffswitch-checkbox { + display: none; +} +.onoffswitch-label { + display: block; overflow: hidden; cursor: pointer; + border: 2px solid #999999; border-radius: 20px; +} +.onoffswitch-inner { + display: block; width: 200%; margin-left: -100%; + transition: margin 0.3s ease-in 0s; +} +.onoffswitch-inner:before, .onoffswitch-inner:after { + display: block; float: left; width: 50%; height: 25px; padding: 0; line-height: 25px; + font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold; + box-sizing: border-box; +} +.onoffswitch-inner:before { + content: "ON"; + padding-left: 10px; + background-color: #337ab7; color: #FFFFFF; +} +.onoffswitch-inner:after { + content: "OFF"; + padding-right: 10px; + background-color: #EEEEEE; color: #999999; + text-align: right; +} +.onoffswitch-switch { + display: block; width: 18px; margin: 6px; + background: #FFFFFF; + position: absolute; top: 0; bottom: 0; + right: 56px; + border: 2px solid #999999; border-radius: 20px; + transition: all 0.3s ease-in 0s; +} +.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner { + margin-left: 0; +} +.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch { + right: 0px; +} diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/policy_Dictionary.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/policy_Dictionary.html index 690f43b36..acf5e1827 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/policy_Dictionary.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/policy_Dictionary.html @@ -2,7 +2,7 @@ ============LICENSE_START======================================================= ONAP Policy Engine ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 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. @@ -105,6 +105,7 @@ <div ng-if="option2 == 'MicroService Location'" ng-include = "'app/policyApp/policy-models/Dictionary/MSLocationDictionary.html'"></div> <div ng-if="option2 == 'MicroService Models'" ng-include = "'app/policyApp/policy-models/Dictionary/MSModelDictionary.html'"></div> <div ng-if="option2 == 'MicroService Dictionary'" ng-include = "'app/policyApp/policy-models/Dictionary/ModelAttributeDictionary.html'"></div> + <div ng-if="option2 == 'MicroService Dictionary Input'" ng-include = "'app/policyApp/policy-models/Dictionary/MSModelDictionaryData.html'"></div> <!--Optimization Policy Dictionary's--> <div ng-if="option2 == 'ONAP Optimization Models'" ng-include = "'app/policyApp/policy-models/Dictionary/OptimizationModelDictionary.html'"></div> <!-- Policy Scope Dictionary's --> @@ -137,4 +138,4 @@ </div> </div> </div> -</script>
\ No newline at end of file +</script> |