summaryrefslogtreecommitdiffstats
path: root/src/main/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/resources')
-rw-r--r--src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html104
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js156
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/propertyController.js17
3 files changed, 238 insertions, 39 deletions
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html
index cf9382bf8..a53ad73d5 100644
--- a/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html
+++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html
@@ -110,7 +110,9 @@ label {
<select type="text" id="trigger_policy" name="trigger_policy"
class="form-control" ng-model="null_dump"
ng-init="initPolicySelect()"
- ng-options="policy for policy in policy_ids track by policy"></select>
+ ng-options="policy for policy in policy_ids track by policy">
+ <option value="">-- choose an option --</option>
+ </select>
</div>
<label for="timeout" class="col-sm-3"
@@ -127,6 +129,13 @@ label {
checked="true" class="form-control">
</div>
</div>
+ <div class="form-group clearfix row">
+ <label class="col-sm-4 control-label" for="clname">ControlLoopName</label>
+ <div class="col-sm-8">
+ <input type="text" class="form-control" name="controlLoopName"
+ readonly="readonly" id="clname" ng-model="clname"/>
+ </div>
+ </div>
</div>
</form>
<div class="panel-heading" style="background-color: white;">
@@ -158,7 +167,8 @@ label {
<label class="col-sm-4 control-label" for="recipe">Recipe</label>
<div class="col-sm-8">
<select class="form-control" name="recipe" id="recipe"
- enableFilter="true" ng-click="updateGuardRecipe($event)">
+ enableFilter="true" ng-model="recipe" ng-click="updateGuardRecipe($event)">
+ <option value="">-- choose an option --</option>
<option value="Restart">Restart</option>
<option value="Rebuild">Rebuild</option>
<option value="Migrate">Migrate</option>
@@ -191,7 +201,8 @@ label {
<div class="form-group clearfix">
<label for="actor" class="col-sm-4 control-label"> Actor</label>
<div class="col-sm-8">
- <select class="form-control" id="actor" name="actor">
+ <select class="form-control" id="actor" name="actor" ng-click="updateGuardActor($event)" ng-model="actor">
+ <option value="">-- choose an option --</option>
<option value="APPC">APPC</option>
<option value="SO">SO</option>
<option value="VFC">VFC</option>
@@ -212,7 +223,9 @@ label {
<div class="col-sm-8">
<select class="form-control" id="success" name="success"
ng-model="null_dump"
- ng-options="policy for policy in policy_ids track by policy"></select>
+ ng-options="policy for policy in policy_ids track by policy">
+ <option value="">-- choose an option --</option>
+ </select>
</div>
</div>
<div class="form-group clearfix">
@@ -221,7 +234,9 @@ label {
<div class="col-sm-8">
<select class="form-control" id="failure" name="failure"
ng-model="null_dump"
- ng-options="policy for policy in policy_ids track by policy"></select>
+ ng-options="policy for policy in policy_ids track by policy">
+ <option value="">-- choose an option --</option>
+ </select>
</div>
</div>
<div class="form-group clearfix">
@@ -230,7 +245,9 @@ label {
<div class="col-sm-8">
<select class="form-control" id="failure_timeout"
name="failure_timeout" ng-model="null_dump"
- ng-options="policy for policy in policy_ids track by policy"></select>
+ ng-options="policy for policy in policy_ids track by policy">
+ <option value="">-- choose an option --</option>
+ </select>
</div>
</div>
<div class="form-group clearfix">
@@ -239,7 +256,9 @@ label {
<div class="col-sm-8">
<select class="form-control" id="failure_retries"
name="failure_retries" ng-model="null_dump"
- ng-options="policy for policy in policy_ids track by policy"></select>
+ ng-options="policy for policy in policy_ids track by policy">
+ <option value="">-- choose an option --</option>
+ </select>
</div>
</div>
<div class="form-group clearfix">
@@ -248,7 +267,9 @@ label {
<div class="col-sm-8">
<select class="form-control" id="failure_exception"
name="failure_exception" ng-model="null_dump"
- ng-options="policy for policy in policy_ids track by policy"></select>
+ ng-options="policy for policy in policy_ids track by policy">
+ <option value="">-- choose an option --</option>
+ </select>
</div>
</div>
<div class="form-group clearfix">
@@ -257,7 +278,9 @@ label {
<div class="col-sm-8">
<select class="form-control" id="failure_guard"
name="failure_guard" ng-model="null_dump"
- ng-options="policy for policy in policy_ids track by policy"></select>
+ ng-options="policy for policy in policy_ids track by policy">
+ <option value="">-- choose an option --</option>
+ </select>
</div>
</div>
</form>
@@ -267,7 +290,8 @@ label {
<label for="type" class="col-sm-4 control-label"> Target
Type</label>
<div class="col-sm-8">
- <select class="form-control" name="type" id="type">
+ <select class="form-control" name="type" id="type"
+ ng-click="initTargetResourceId()" ng-model="type">
<option value="VFC">VFC</option>
<option value="VM">VM</option>
<option value="VNF">VNF</option>
@@ -279,10 +303,55 @@ label {
Target ResourceId</label>
<div class="col-sm-8">
<select class="form-control" name="resourceId" id="resourceId"
- enableFilter="true">
+ enableFilter="true" ng-click="changeTargetResourceId()"
+ ng-model="resourceId">
+ <option value=""></option>
+ <option value="Other:">Other:</option>
</select>
</div>
</div>
+ <div id="metadata">
+ <div class="form-group clearfix">
+ <label for="modelInvariantId" class="col-sm-4 control-label">
+ Model Invariant Id</label>
+ <div class="col-sm-8">
+ <input class="form-control" name="modelInvariantId"
+ id="modelInvariantId" readonly />
+ </div>
+ </div>
+ <div class="form-group clearfix">
+ <label for="modelVersionId" class="col-sm-4 control-label">
+ Model Version Id</label>
+ <div class="col-sm-8">
+ <input class="form-control" name="modelVersionId"
+ id="modelVersionId" readonly />
+ </div>
+ </div>
+ <div class="form-group clearfix">
+ <label for="modelName" class="col-sm-4 control-label">
+ Model Name</label>
+ <div class="col-sm-8">
+ <input class="form-control" name="modelName" id="modelName"
+ readonly />
+ </div>
+ </div>
+ <div class="form-group clearfix">
+ <label for="modelVersion" class="col-sm-4 control-label">
+ Model Version</label>
+ <div class="col-sm-8">
+ <input class="form-control" name="modelVersion"
+ id="modelVersion" readonly />
+ </div>
+ </div>
+ <div class="form-group clearfix">
+ <label for="modelCustomizationId" class="col-sm-4 control-label">
+ Model Customization Id</label>
+ <div class="col-sm-8">
+ <input class="form-control" name="modelCustomizationId"
+ id="modelCustomizationId" readonly />
+ </div>
+ </div>
+ </div>
</form>
<div class="form-group clearfix">
<label for="enableGuardPolicy" class="col-sm-4 control-label">
@@ -306,7 +375,7 @@ label {
title="Guard policy associated" style="border: 2px dotted gray;">
<div class="form-group clearfix">
- <label class="col-sm-4 control-label" for="id">ID</label>
+ <label class="col-sm-4 control-label" for="id">Guard Policy ID</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="id" id="id" />
</div>
@@ -315,7 +384,7 @@ label {
<label class="col-sm-4 control-label" for="recipe">Recipe</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="recipe"
- readonly="readonly" id="recipe" />
+ readonly="readonly" id="recipe"/>
</div>
</div>
<div class="form-group clearfix">
@@ -325,8 +394,13 @@ label {
readonly="readonly" id="clname" ng-model="clname"/>
</div>
</div>
-
-
+ <div class="form-group clearfix">
+ <label for="actor" class="col-sm-4 control-label">Actor</label>
+ <div class="col-sm-8">
+ <input type="text" class="form-control" name="actor"
+ readonly="readonly" id="actor" />
+ </div>
+ </div>
<div class="form-group clearfix">
<label for="guardTargets" class="col-sm-4 control-label">Guard
diff --git a/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js
index 5a1ac538b..4e8855eb0 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js
@@ -37,7 +37,8 @@ app
var allPolicies = {};
$scope.guardType = "GUARD_MIN_MAX";
$scope.number = 0;
- $scope.clname="";
+ $scope.clname = "";
+ $scope.guard_ids = [];
function getAllFormId() {
return Array.from(document.getElementsByClassName("formId"));
@@ -54,17 +55,7 @@ app
}
console.log("No active formId found !");
}
- function initTargetResourceId() {
- if (vf_Services !== null && vf_Services !== undefined) {
- // 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 add_one_more() {
console.log("add one more");
@@ -102,6 +93,7 @@ app
$(".formId").not($("#formId" + count)).css("display", "none");
addCustListen(count);
$("#formId" + count + " #id").val("new");
+ $("#formId" + count + " #clname").val($scope.clname);
return count;
}
function addCustListen(count) {
@@ -150,10 +142,11 @@ app
}
function savePolicyLocally() {
- var polForm = {}
- polForm = serializeElement($("#operationalPolicyHeaderForm"));
+ var polForm = {};
+ var clPolForm = {};
+ clPolForm = serializeElement($("#operationalPolicyHeaderForm"));
+ allPolicies['guard_policies'] = {};
var policiesArray = []
- allPolicies['guard_policies'] = [];
$.each($(".formId"), function() {
var policyProperties = serializeElement($("#" + this.id + " .policyProperties"));
@@ -161,9 +154,15 @@ app
policiesArray.push(policyProperties);
// Now get the Guard
if ($("#" + this.id + " #enableGuardPolicy").is(':checked')) {
- allPolicies['guard_policies'].push(serializeElement($("#" + this.id + " .guardProperties")));
+ var guardPolicyBody = serializeElement($("#" + this.id + " .guardProperties"));
+ var guardPolicyId = guardPolicyBody['id'];
+ delete guardPolicyBody['id'];
+
+ allPolicies['guard_policies'][guardPolicyId] = guardPolicyBody;
+ $scope.guard_ids.push(guardPolicyId);
}
});
+ polForm['controlLoop'] = clPolForm;
polForm['policies'] = policiesArray;
allPolicies['operational_policy'] = polForm;
}
@@ -183,7 +182,7 @@ app
// Set the header
$.each($('#operationalPolicyHeaderForm').find('.form-control'), function() {
- $(this).val(allPolicies['operational_policy'][this.id]);
+ $(this).val(allPolicies['operational_policy']['controlLoop'][this.id]);
});
// Set the sub-policies
$.each(allPolicies['operational_policy']['policies'], function(opPolicyElemIndex, opPolicyElemValue) {
@@ -198,13 +197,14 @@ app
$("#go_properties_tab" + formNum).text(
allPolicies['operational_policy']['policies'][opPolicyElemIndex]['id']);
// Check if there is a guard set for it
- $.each(allPolicies['guard_policies'], function(guardElemIndex, guardElemValue) {
+ $.each(allPolicies['guard_policies'], function(guardElemId, guardElemValue) {
if (guardElemValue.recipe === $($("#formId" + formNum + " #recipe")[0]).val()) {
// Found one, set all guard prop
$.each($('.guardProperties').find('.form-control'), function(guardPropElemIndex,guardPropElemValue) {
+ guardElemValue['id'] = guardElemId;
$("#formId"+formNum+" .guardProperties").find("#"+guardPropElemValue.id).val(
- allPolicies['guard_policies'][guardElemIndex][guardPropElemValue.id]);
+ guardElemValue[guardPropElemValue.id]);
});
// And finally enable the flag
$("#formId" + formNum + " #enableGuardPolicy").prop("checked", true);
@@ -212,6 +212,107 @@ app
});
});
}
+
+ $scope.initTargetResourceId = function() {
+
+ var recipe = $(event.target).val();
+
+ var type = $(event.target).val();
+
+ $("#modelName").val("");
+ $("#modelInvariantId").val("");
+ $("#modelVersionId").val("");
+ $("#modelVersion").val("");
+ $("#modelCustomizationId").val("");
+ $('#resourceId').empty();
+ $("#resourceId")
+ .append(
+ $('<option></option>').val("")
+ .html(""));
+ $("#resourceId").append(
+ $('<option></option>').val("Other:")
+ .html("Other:"));
+ if (type == "VM" || type == "" || type == "VNF" ) {
+ $("#metadata *").prop('disabled',true);
+ }
+
+ var resourceVnf = getResourceDetailsProperty();
+ if (type == "VNF"
+ && (null !== resourceVnf || undefined !== resourceVnf)) {
+ for ( var prop in resourceVnf) {
+ var name = resourceVnf[prop]["name"];
+ $("#resourceId").append(
+ $('<option></option>')
+ .val(name).html(name));
+ }
+
+ }
+ var resourceVfc = getResourceDetailsVfcProperty();
+ if (type == "VFC"
+ && (null !== resourceVfc || undefined !== resourceVfc)) {
+ if (recipe == 'VF Module Create'
+ || recipe == 'VF Module Delete') {
+ for ( var prop in resourceVfc) {
+ if (resourceVfc[prop]["isBase"] == false) {
+ var name = resourceVfc[prop]["name"];
+ $("#resourceId").append(
+ $('<option></option>')
+ .val(name)
+ .html(name));
+ }
+ }
+ }
+ else
+ {
+ for ( var prop in resourceVfc) {
+ var name = resourceVfc[prop]["name"];
+ $("#resourceId").append(
+ $('<option></option>')
+ .val(name).html(name));
+ }
+ }
+ }
+ }
+
+ $scope.changeTargetResourceId = function() {
+ $("#modelName").val("");
+ $("#modelInvariantId").val("");
+ $("#modelVersionId").val("");
+ $("#modelVersion").val("");
+ $("#modelCustomizationId").val("");
+ var resourceVfc = getResourceDetailsVfcProperty();
+ var type = $("#type").val();
+ var recipe = $("#recipe").val();
+ vfBaseName = $(event.target).val();
+ if (type == "VFC"
+ && (null !== resourceVfc || undefined !== resourceVfc)
+ && (recipe == 'VF Module Create' || recipe == 'VF Module Delete')) {
+ for ( var prop in resourceVfc) {
+ var name = resourceVfc[prop]["name"];
+ if (name == vfBaseName) {
+ var vfModuleModelName = resourceVfc[prop]["name"];
+ $("#modelName").val(
+ vfModuleModelName);
+ var vfModuleModelInvariantUUID = resourceVfc[prop]["invariantUUID"];
+ $("#modelInvariantId").val(
+ vfModuleModelInvariantUUID);
+ var vfModuleModelUUID = resourceVfc[prop]["UUID"];
+ $("#modelVersionId").val(
+ vfModuleModelUUID);
+ var vfModuleModelVersion = resourceVfc[prop]["version"];
+ $("#modelVersion").val(
+ vfModuleModelVersion);
+ var vfModuleModelCustomizationUUID = resourceVfc[prop]["customizationUUID"];
+ $("#modelCustomizationId")
+ .val(
+ vfModuleModelCustomizationUUID);
+ }
+ }
+ }
+ else {
+ $("#metadata *").prop('disabled',true);
+ }
+ }
$scope.changeGuardPolicyType = function() {
@@ -258,13 +359,20 @@ app
add_new_policy();
}
$("#savePropsBtn").click(function(event) {
-
console.log("save properties triggered");
savePolicyLocally();
+ for(var i = 0; i <= $scope.guard_ids.length; i++) {
+ for(var j = i; j <= $scope.guard_ids.length; j++) {
+ if(i != j && $scope.guard_ids[i] == $scope.guard_ids[j]) {
+ // duplacated guard policy id exist
+ alert("The guard policy ID should be unique.");
+ return;
+ }
+ }
+ }
angular.element(document.getElementById('formSpan')).scope().submitForm(allPolicies);
$("#close_button").click();
});
- initTargetResourceId();
});
}
$scope.init();
@@ -274,6 +382,12 @@ app
// Get the second recipe (guard one) and update it
$($("#formId" + formNum + " #recipe")[1]).val($(event.target).val());
}
+ $scope.updateGuardActor = function(event) {
+
+ var formNum = $(event.target).closest('.formId').attr('id').substring(6);
+ // Get the second actor (guard one) and update it
+ $($("#formId" + formNum + " #actor")[1]).val($(event.target).val());
+ }
// When we change the name of a policy
$scope.updateTabLabel = function(event) {
@@ -302,4 +416,4 @@ app
});
};
- } ]); \ No newline at end of file
+ } ]);
diff --git a/src/main/resources/META-INF/resources/designer/scripts/propertyController.js b/src/main/resources/META-INF/resources/designer/scripts/propertyController.js
index 2b32f4d26..75c64f308 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/propertyController.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/propertyController.js
@@ -72,7 +72,9 @@ function getMsProperty(type) {
var msProperties = cl_props["microServicePolicies"];
for (p in msProperties) {
if (msProperties[p]["name"] == type) {
- return JSON.parse(JSON.stringify(msProperties[p]["properties"]));
+ if (msProperties[p]["properties"] !== null && msProperties[p]["properties"] !== undefined) {
+ return JSON.parse(JSON.stringify(msProperties[p]["properties"]));
+ }
}
}
return null;
@@ -82,7 +84,7 @@ function getMsUI(type) {
var msProperties = cl_props["microServicePolicies"];
for (p in msProperties) {
if (msProperties[p]["name"] == type) {
- return JSON.parse(JSON.stringify(msProperties[p]["jsonRepresentation"]));
+ return JSON.parse(JSON.stringify(msProperties[p]["jsonRepresentation"]));
}
}
return null;
@@ -111,4 +113,13 @@ function getDeploymentStatusURL() {
function setDeploymentStatusURL(deploymentStatusURL) {
cl_props["dcaeDeploymentStatusUrl"] = deploymentStatusURL;
}
-module.exports = { getOperationalPolicyProperty,getGlobalProperty,getMsProperty,getMsUI,getLastUpdatedStatus,getDeploymentID,getDeploymentStatusURL }; \ No newline at end of file
+
+function getResourceDetailsProperty() {
+ return cl_props["modelPropertiesJson"]["resourceDetails"]["VF"];
+}
+
+function getResourceDetailsVfcProperty() {
+ return cl_props["modelPropertiesJson"]["resourceDetails"]["VFC"];
+}
+
+module.exports = { getOperationalPolicyProperty,getGlobalProperty,getMsProperty,getMsUI,getLastUpdatedStatus,getDeploymentID,getDeploymentStatusURL,getResourceDetailsProperty,getResourceDetailsVfcProperty }; \ No newline at end of file