mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-28 17:57:22 +03:00
Feature template (#296)
* removed merge templates function * saved disk template into disk-tab
This commit is contained in:
parent
83a2d0e7c1
commit
163b91d522
src/sunstone/public/app
tabs
oneflow-templates-tab/form-panels
templates-tab/form-panels
utils
@ -230,27 +230,22 @@ define(function(require) {
|
||||
|
||||
json_template['ready_status_gate'] = ready_status_gate;
|
||||
|
||||
var templateStr = $('textarea#template', $("form#createServiceTemplateFormAdvanced")).val();
|
||||
var template_final = TemplateUtils.mergeTemplates(json_template, templateStr);
|
||||
if (this.action == "create") {
|
||||
Sunstone.runAction("ServiceTemplate.create", template_final );
|
||||
Sunstone.runAction("ServiceTemplate.create", json_template );
|
||||
return false;
|
||||
} else if (this.action == "update") {
|
||||
Sunstone.runAction("ServiceTemplate.update",this.resourceId, JSON.stringify(template_final));
|
||||
Sunstone.runAction("ServiceTemplate.update",this.resourceId, JSON.stringify(json_template));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function _submitAdvanced(context) {
|
||||
var templateStr = $('textarea#template', context).val();
|
||||
var templateJSON = this.retrieve($("form#createServiceTemplateFormWizard"));
|
||||
var template_final = TemplateUtils.mergeTemplates(templateStr, templateJSON, true);
|
||||
template_final = TemplateUtils.templateToString(template_final);
|
||||
if (this.action == "create") {
|
||||
Sunstone.runAction("ServiceTemplate.create", JSON.parse(template_final) );
|
||||
Sunstone.runAction("ServiceTemplate.create", JSON.parse(templateStr) );
|
||||
return false;
|
||||
} else if (this.action == "update") {
|
||||
Sunstone.runAction("ServiceTemplate.update", this.resourceId, template_final);
|
||||
Sunstone.runAction("ServiceTemplate.update", this.resourceId, templateStr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -188,32 +188,25 @@ define(function(require) {
|
||||
|
||||
function _submitWizard(context) {
|
||||
var templateJSON = this.retrieve(context);
|
||||
var contextAdv = context[0].id.replace("Wizard", "Advanced")
|
||||
var templateStr = $('textarea#template', $("form#"+contextAdv)).val();
|
||||
var template_final = TemplateUtils.mergeTemplates(templateJSON, templateStr);
|
||||
|
||||
if (this.action == "create") {
|
||||
Sunstone.runAction(this.resource+".create", {'vmtemplate': template_final});
|
||||
Sunstone.runAction(this.resource+".create", {'vmtemplate': templateJSON});
|
||||
return false;
|
||||
} else if (this.action == "update") {
|
||||
Sunstone.runAction(this.resource+".update", this.resourceId, TemplateUtils.templateToString(template_final));
|
||||
Sunstone.runAction(this.resource+".update", this.resourceId, TemplateUtils.templateToString(templateJSON));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function _submitAdvanced(context) {
|
||||
var templateStr = $('textarea#template', context).val();
|
||||
var contextWiz = context[0].id.replace("Advanced", "Wizard");
|
||||
var templateJSON = this.retrieve($("form#"+contextWiz));
|
||||
var template_final = TemplateUtils.mergeTemplates(templateStr, templateJSON, true);
|
||||
template_final = TemplateUtils.templateToString(template_final);
|
||||
|
||||
if (this.action == "create") {
|
||||
Sunstone.runAction(this.resource+".create", {"vmtemplate": {"template_raw": template_final}});
|
||||
Sunstone.runAction(this.resource+".create", {"vmtemplate": {"template_raw": templateStr}});
|
||||
return false;
|
||||
|
||||
} else if (this.action == "update") {
|
||||
Sunstone.runAction(this.resource+".update", this.resourceId, template_final);
|
||||
Sunstone.runAction(this.resource+".update", this.resourceId, templateStr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ define(function(require) {
|
||||
var ImageTable = require('tabs/images-tab/datatable')
|
||||
var WizardFields = require('utils/wizard-fields');
|
||||
var UniqueId = require('utils/unique-id');
|
||||
var TemplateUtils = require('utils/template-utils');
|
||||
|
||||
/*
|
||||
TEMPLATES
|
||||
@ -159,7 +160,7 @@ define(function(require) {
|
||||
}
|
||||
tmpl["DEV_PREFIX"] = dev_prefix;
|
||||
}
|
||||
|
||||
$.extend(tmpl, TemplateUtils.stringToTemplate($('#templateStr',context).val()));
|
||||
return tmpl;
|
||||
}
|
||||
|
||||
@ -198,6 +199,7 @@ define(function(require) {
|
||||
}
|
||||
|
||||
WizardFields.fill(selectedContext, templateJSON);
|
||||
$('#templateStr',context).val(TemplateUtils.templateToString(templateJSON));
|
||||
|
||||
var dev_prefix = templateJSON["DEV_PREFIX"];
|
||||
if (dev_prefix != undefined && dev_prefix.length) {
|
||||
|
2
src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/storage/disk-tab/html.hbs
2
src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/storage/disk-tab/html.hbs
@ -13,7 +13,7 @@
|
||||
{{! See the License for the specific language governing permissions and }}
|
||||
{{! limitations under the License. }}
|
||||
{{! -------------------------------------------------------------------------- }}
|
||||
|
||||
<textarea id="templateStr" hidden></textarea>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<input id="{{diskTabId}}radioImage" type="radio" name="{{diskTabId}}" value="image" checked>
|
||||
|
@ -93,24 +93,6 @@ define(function(require) {
|
||||
return template_str;
|
||||
}
|
||||
|
||||
function _merge_templates(template_master, template_slave, advanced){
|
||||
if(!advanced){
|
||||
template_slave = _convert_string_to_template(template_slave);
|
||||
} else {
|
||||
template_master = _convert_string_to_template(template_master);
|
||||
}
|
||||
if(template_slave.USER_INPUTS){
|
||||
delete template_slave.USER_INPUTS;
|
||||
}
|
||||
if((advanced && template_master) || (!advanced && template_slave)){
|
||||
var template_final = {};
|
||||
$.extend(template_final, template_slave, template_master);
|
||||
return template_final;
|
||||
} else {
|
||||
Notifier.notifyError(Locale.tr("Advanced template malformed"));
|
||||
}
|
||||
return template_master;
|
||||
}
|
||||
// Transforms an object to an opennebula template string
|
||||
function _convert_string_to_template(string_json, unshown_values) {
|
||||
var i = 0;
|
||||
@ -190,7 +172,6 @@ define(function(require) {
|
||||
}
|
||||
|
||||
return {
|
||||
'mergeTemplates' : _merge_templates,
|
||||
'stringToTemplate': _convert_string_to_template,
|
||||
'templateToString': _convert_template_to_string,
|
||||
'htmlDecode': _htmlDecode,
|
||||
|
Loading…
x
Reference in New Issue
Block a user