diff options
Diffstat (limited to 'src/main/resources/META-INF')
3 files changed, 61 insertions, 16 deletions
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html index 7dd2c4dd7..83fb337d9 100644 --- a/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html +++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html @@ -286,9 +286,13 @@ label { <label for="targetResourceId" class="col-sm-4 control-label"> Target ResourceId</label> <div class="col-sm-8"> - <input type="text" class="form-control" id="targetResourceId" - name="targetResourceId"> </input> + <select class="form-control" name="targetResourceId" id="targetResourceId" enableFilter="true" onchange="changeTargetResourceIdOther();" > + <option value=""></option> + <option value="Other:">Other:</option> + </select> </div> + <input type="text" style="display:none" class="form-control" id="targetResourceIdOther" + name="targetResourceIdOther" value=""></input> </div> </div> </form> @@ -304,6 +308,22 @@ label { </div> <script> + + function initTargetResourceId() { + // Set all the Resource Invariant UUID in the target resource ID list (+Empty and other) + Object.keys(vf_Services["shared"]["byVf"]).forEach(function(key){ + $('#targetResourceId').append($('<option></option>').val(key).html(key)); + }); + } + + function changeTargetResourceIdOther() { + if ($("#targetResourceId").val()==="Other:") { + $("#targetResourceIdOther").show(); + } else { + $("#targetResourceIdOther").hide(); + $("#targetResourceIdOther").val(""); + } + } //Basically this method will add a new form. All forms share the same class. When you want one form to show(active form) the other forms get the // css attribute display:none $("#add_one_more").click(function(event) { @@ -334,7 +354,8 @@ label { } } $("#pname").val(''); - + initTargetResourceId(); + //load recipes for a chosen policy function disperseConfig(policyObj, id){ parent_policy={}; @@ -360,7 +381,13 @@ label { parent_policy[num]=el[i][j].value if(el[i][j].name==='recipe' && el[i][j].value.toString()!==''){ $("#go_properties_tab"+num).text(el[i][j].value) - } + } + if(el[i][j].name==="targetResourceIdOther" && el[i][j].value.toString()!=='') { + // Add the entry and set it + $('#targetResourceId').append($('<option></option>').val($('#targetResourceIdOther').val()).html($('#targetResourceIdOther').val())); + $('#targetResourceId').val($('#targetResourceIdOther').val()); + } + } } } @@ -385,13 +412,14 @@ label { $("#formId"+k+" #parentPolicy").change(); } + // Now load all component with the right value defined in policyObj JSON for (headInd in policyObj[id]){ if (!(policyObj[id][headInd].hasOwnProperty("policyConfigurations"))){ $("#" + policyObj[id][headInd].name).val(policyObj[id][headInd].value); } } } - + setMultiSelect(); if (readMOnly){ @@ -454,6 +482,10 @@ label { } $("#savePropsBtn").click(function(event) { + if($("#targetResourceIdOther").is(":visible")) { + $('#targetResourceId').append($('<option></option>').val($("#targetResourceIdOther").val()).html($("#targetResourceIdOther").val())) + $("#targetResourceId").val($("#targetResourceIdOther").val()); + } $(".idError").hide(); if ($("#policyTable .highlight td").html() !== $("#pname").val()){ //repeated name @@ -483,7 +515,7 @@ label { finalSaveList[tableVal] = allPolicies[tableVal]; } }); - + saveProperties(finalSaveList); $("#close_button").click(); }) diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/deploy_parameters.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/deploy_parameters.html index 5693a875b..3fc1b0301 100644 --- a/src/main/resources/META-INF/resources/designer/partials/portfolios/deploy_parameters.html +++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/deploy_parameters.html @@ -26,11 +26,11 @@ <button type="button" class="close" ng-click="close()" aria-hidden="true" style="margin-top: -3px">×</button> <h4>Deployment parameters</h4> </div> - <div class="modal-body" style="height: 150px"> - <div style="height: 30px"> - Deployment parameters as JSON. + <div class="modal-body" style="display:block"> + <div style="height: 100%;clear: both;" id="deployPropertiesDiv" name="deployPropertiesDiv" ng-init="load_deploy_parameters()" > + Deployment parameters. </div> - <textarea class="form-control" focus="true" name="deployProperties" id="deployProperties" ng-init="load_deploy_parameters()"/> + </div> <div class="modal-footer"> <button ng-click="deploy()" class="btn btn-primary">Deploy</button> diff --git a/src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js index 950e59ca1..935091240 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js +++ b/src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js @@ -26,10 +26,18 @@ app.controller('DeploymentCtrl', function( $scope, $rootScope, $modalInstance, data, dialogs, cldsModelService) { function validate_and_set_deploy_parameters () { - var parameters = $("#deployProperties").val(); + var inputList = document.getElementsByClassName("deployFormId"); + var jsonParameters="{"; + $.each(inputList, function(key) { + if (jsonParameters !== "{") { + jsonParameters = jsonParameters+","; + } + jsonParameters = jsonParameters+'"'+inputList[key].id+'":'+'"'+inputList[key].value+'"' + }); + jsonParameters = jsonParameters+"}"; try { - parameters = JSON.parse(parameters); - set_deploy_parameters(parameters); + //Try to validate the json + set_deploy_parameters(JSON.parse(jsonParameters)); } catch (e) { console.error("Couldn't parse deploy parameters json"); } @@ -39,7 +47,6 @@ app.controller('DeploymentCtrl', if (!'global' in elementMap) { elementMap["global"] = []; } - var index = elementMap["global"].findIndex(function (e) { return (typeof e == "object" && !(e instanceof Array)) && "deployParameters" == e["name"]; }); if (index == -1) { elementMap["global"].push({"name": "deployParameters", "value": parameters}); @@ -50,8 +57,14 @@ app.controller('DeploymentCtrl', $scope.load_deploy_parameters = function () { var index = elementMap["global"].findIndex(function (e) { return (typeof e == "object" && !(e instanceof Array)) && "deployParameters" == e["name"]; }); - if (index != -1) { - $('#deployProperties').val(JSON.stringify(elementMap["global"][index]["value"])) + if (index != -1) { + $('#deployPropertiesDiv').append($('<br/>')); + $.each(elementMap["global"][index].value, function(key) { + var propertyValue=elementMap["global"][index].value[key]; + $('#deployPropertiesDiv').append($('<label class="control-label">'+key+' </label>')); + $('#deployPropertiesDiv').append($('<input style="width: 100%; clear: both;" class="deployFormId" id="'+key+'"></input>').val(propertyValue).html(propertyValue)); + $('#deployPropertiesDiv').append($('<br/>')); + }); } } |