mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Feature #3748: Oneflow template update wizard
This commit is contained in:
parent
572bb3f692
commit
30675702c3
@ -9,6 +9,7 @@ define(function(require) {
|
||||
var Locale = require('utils/locale');
|
||||
var Tips = require('utils/tips');
|
||||
var RoleTab = require('tabs/oneflow-templates-tab/utils/role-tab');
|
||||
var TemplateUtils = require('utils/template-utils');
|
||||
|
||||
/*
|
||||
TEMPLATES
|
||||
@ -266,7 +267,99 @@ define(function(require) {
|
||||
}
|
||||
|
||||
function _fill(context, element) {
|
||||
// TODO
|
||||
var that = this;
|
||||
|
||||
if (this.action != "update") {return;}
|
||||
this.resourceId = element.ID;
|
||||
|
||||
// Populates the Avanced mode Tab
|
||||
$('#template', context).val(TemplateUtils.htmlDecode(
|
||||
JSON.stringify(element.TEMPLATE.BODY, null, " ")));
|
||||
|
||||
|
||||
$("#service_name", context).attr("disabled", "disabled");
|
||||
$("#service_name", context).val(TemplateUtils.htmlDecode(element.NAME));
|
||||
|
||||
$("#description", context).val(TemplateUtils.htmlDecode(element.TEMPLATE.BODY.description));
|
||||
|
||||
$('select[name="deployment"]', context).val(element.TEMPLATE.BODY.deployment);
|
||||
$("select[name='shutdown_action_service']", context).val(element.TEMPLATE.BODY.shutdown_action);
|
||||
$("input[name='ready_status_gate']", context).prop("checked",element.TEMPLATE.BODY.ready_status_gate || false);
|
||||
|
||||
|
||||
$(".service_networks i.remove-tab", context).trigger("click");
|
||||
|
||||
if ( ! $.isEmptyObject( element.TEMPLATE.BODY['custom_attrs'] ) ) {
|
||||
$("div#network_configuration a.accordion_advanced_toggle", context).trigger("click");
|
||||
|
||||
$.each(element.TEMPLATE.BODY['custom_attrs'], function(key, attr){
|
||||
var parts = attr.split("|");
|
||||
// 0 mandatory; 1 type; 2 desc;
|
||||
var attrs = {
|
||||
"name": key,
|
||||
"mandatory": parts[0],
|
||||
"type": parts[1],
|
||||
"description": parts[2],
|
||||
};
|
||||
|
||||
switch (parts[1]) {
|
||||
case "vnet_id":
|
||||
$(".add_service_network", context).trigger("click");
|
||||
|
||||
var tr = $(".service_networks tbody tr", context).last();
|
||||
$(".service_network_name", tr).val(TemplateUtils.htmlDecode(attrs.name)).change();
|
||||
$(".service_network_description", tr).val(TemplateUtils.htmlDecode(attrs.description));
|
||||
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$("#roles_tabs i.remove-tab", context).trigger("click");
|
||||
|
||||
var network_names = [];
|
||||
|
||||
$(".service_networks .service_network_name", context).each(function(){
|
||||
if ($(this).val()) {
|
||||
network_names.push($(this).val());
|
||||
}
|
||||
});
|
||||
|
||||
var roles_names = [];
|
||||
$.each(element.TEMPLATE.BODY.roles, function(index, value){
|
||||
roles_names.push(value.name);
|
||||
|
||||
$("#tf_btn_roles", context).click();
|
||||
|
||||
var role_context = $('.role_content', context).last();
|
||||
var role_id = $(role_context).attr("role_id");
|
||||
|
||||
that.roleTabObjects[role_id].fill(role_context, value, network_names);
|
||||
});
|
||||
|
||||
$.each(element.TEMPLATE.BODY.roles, function(index, value){
|
||||
var role_context = $('.role_content', context)[index];
|
||||
var str = "";
|
||||
|
||||
$.each(roles_names, function(){
|
||||
if (this != value.name) {
|
||||
str += "<tr>\
|
||||
<td style='width:10%'>\
|
||||
<input class='check_item' type='checkbox' value='"+this+"' id='"+this+"'/>\
|
||||
</td>\
|
||||
<td>"+this+"</td>\
|
||||
</tr>";
|
||||
}
|
||||
});
|
||||
|
||||
$(".parent_roles_body", role_context).html(str);
|
||||
|
||||
if (value.parents) {
|
||||
$.each(value.parents, function(index, value){
|
||||
$(".parent_roles_body #"+this, role_context).attr('checked', true);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -20,30 +20,32 @@
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
{{#advancedSection (tr "Network Configuration") }}
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<table class="service_networks policies_table dataTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:30%">{{tr "Name"}}</th>
|
||||
<th style="width:70%">{{tr "Description"}}</th>
|
||||
<th style="width:3%"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<a type="button" class="add_service_network button small large-12 secondary radius"><i class="fa fa-plus"></i>{{tr "Add another Network"}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<div id="network_configuration">
|
||||
{{#advancedSection (tr "Network Configuration") }}
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<table class="service_networks policies_table dataTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:30%">{{tr "Name"}}</th>
|
||||
<th style="width:70%">{{tr "Description"}}</th>
|
||||
<th style="width:3%"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<a type="button" class="add_service_network button small large-12 secondary radius"><i class="fa fa-plus"></i>{{tr "Add another Network"}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{{/advancedSection}}
|
||||
</div>
|
||||
{{/advancedSection}}
|
||||
<br>
|
||||
{{#advancedSection (tr "Advanced Service Parameters") }}
|
||||
<div class="row">
|
||||
|
@ -3,6 +3,7 @@ define(function(require) {
|
||||
var Locale = require('utils/locale');
|
||||
var Tips = require('utils/tips');
|
||||
var TemplatesTable = require('tabs/templates-tab/datatable');
|
||||
var TemplateUtils = require('utils/template-utils');
|
||||
|
||||
var TemplateHTML = require('hbs!./role-tab/html');
|
||||
var TemplateElasticityRowHTML = require('hbs!./role-tab/elasticity-row');
|
||||
@ -19,8 +20,7 @@ define(function(require) {
|
||||
'setup': _setup_role_tab_content,
|
||||
'onShow': _onShow,
|
||||
'retrieve': _retrieve,
|
||||
//'fill': _fill
|
||||
|
||||
'fill': _fill
|
||||
};
|
||||
RoleTab.prototype.constructor = RoleTab;
|
||||
|
||||
@ -165,6 +165,75 @@ define(function(require) {
|
||||
return role;
|
||||
}
|
||||
|
||||
function _fill(context, value, network_names) {
|
||||
$("#role_name", context).val(TemplateUtils.htmlDecode(value.name));
|
||||
$("#role_name", context).change();
|
||||
|
||||
$("#cardinality", context).val(TemplateUtils.htmlDecode(value.cardinality));
|
||||
|
||||
this.templatesTable.selectResourceTableSelect({ids : value.vm_template});
|
||||
|
||||
if (value.vm_template_contents){
|
||||
$(network_names).each(function(){
|
||||
var reg = new RegExp("\\$"+this+"\\b");
|
||||
|
||||
if(reg.exec(value.vm_template_contents) != null){
|
||||
$(".service_network_checkbox[value='"+this+"']", context).attr('checked', true).change();
|
||||
}
|
||||
});
|
||||
|
||||
$(".vm_template_contents", context).val(TemplateUtils.htmlDecode(value.vm_template_contents));
|
||||
}
|
||||
|
||||
$("select[name='shutdown_action_role']", context).val(value.shutdown_action);
|
||||
|
||||
$("#min_vms", context).val(TemplateUtils.htmlDecode(value.min_vms));
|
||||
$("#max_vms", context).val(TemplateUtils.htmlDecode(value.max_vms));
|
||||
$("#cooldown", context).val(TemplateUtils.htmlDecode(value.cooldown));
|
||||
|
||||
if (value['elasticity_policies'].length > 0 ||
|
||||
value['scheduled_policies'].length > 0) {
|
||||
$("div.elasticity_accordion a.accordion_advanced_toggle", context).trigger("click");
|
||||
}
|
||||
|
||||
$("#elasticity_policies_table i.remove-tab", context).trigger("click");
|
||||
$("#scheduled_policies_table i.remove-tab", context).trigger("click");
|
||||
|
||||
if (value['elasticity_policies']) {
|
||||
$.each(value['elasticity_policies'], function(){
|
||||
$("#tf_btn_elas_policies", context).click();
|
||||
var td = $("#elasticity_policies_tbody tr", context).last();
|
||||
$("#type" ,td).val(TemplateUtils.htmlDecode(this['type']));
|
||||
$("#type" ,td).change();
|
||||
$("#adjust" ,td).val(TemplateUtils.htmlDecode(this['adjust'] ));
|
||||
$("#min_adjust_step" ,td).val(TemplateUtils.htmlDecode(this['min_adjust_step'] || ""));
|
||||
$("#expression" ,td).val(TemplateUtils.htmlDecode(this.expression));
|
||||
$("#period_number" ,td).val(TemplateUtils.htmlDecode(this['period_number'] || ""));
|
||||
$("#period" ,td).val(TemplateUtils.htmlDecode(this['period'] || "" ));
|
||||
$("#cooldown" ,td).val(TemplateUtils.htmlDecode(this['cooldown'] || "" ));
|
||||
});
|
||||
}
|
||||
|
||||
if (value['scheduled_policies']) {
|
||||
$.each(value['scheduled_policies'], function(){
|
||||
$("#tf_btn_sche_policies", context).click();
|
||||
var td = $("#scheduled_policies_tbody tr", context).last();
|
||||
$("#type", td).val(TemplateUtils.htmlDecode(this['type']));
|
||||
$("#type" ,td).change();
|
||||
$("#adjust", td).val(TemplateUtils.htmlDecode(this['adjust'] ));
|
||||
$("#min_adjust_step", td).val(TemplateUtils.htmlDecode(this['min_adjust_step'] || ""));
|
||||
|
||||
if (this['start_time']) {
|
||||
$("#time_format", td).val('start_time');
|
||||
$("#time", td).val(TemplateUtils.htmlDecode(this['start_time']));
|
||||
} else if (this['recurrence']) {
|
||||
$("#time_format", td).val('recurrence');
|
||||
$("#time", td).val(TemplateUtils.htmlDecode(this['recurrence']));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function _removeEmptyObjects(obj){
|
||||
|
@ -10,7 +10,7 @@ define(function(require) {
|
||||
|
||||
return new Handlebars.SafeString(
|
||||
'<div class="accordion_advanced">'+
|
||||
'<a href="#'+html_id+'">'+
|
||||
'<a href="#'+html_id+'" class="accordion_advanced_toggle">'+
|
||||
'<i class="fa fa-fw fa-chevron-down"/>'+
|
||||
'<i class="fa fa-fw fa-chevron-up"/>'+
|
||||
title+
|
||||
|
Loading…
x
Reference in New Issue
Block a user