1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-25 02:50:08 +03:00

Fix marketplace import dialog

This commit is contained in:
Daniel Molina 2014-03-20 15:29:14 +01:00
parent 6ca4487dc8
commit 36d1695af6
4 changed files with 47 additions and 24 deletions

View File

@ -244,13 +244,15 @@ var image_actions = {
type: "create",
call: OpenNebula.Image.create,
callback: function(request, response){
// Reset the create wizard
addImageElement(request, response);
if ($appmarket_import_dialog || $marketplace_import_dialog) {
$create_image_dialog.trigger('close');
} else {
$create_image_dialog.foundation('reveal', 'close');
$create_image_dialog.empty();
setupCreateImageDialog();
addImageElement(request, response);
notifyCustom(tr("Image created"), " ID: " + response.IMAGE.ID, false);
}
notifyCustom(tr("Image created"), " ID: " + response.IMAGE.ID, false)
},
error: onError
},
@ -1020,6 +1022,8 @@ function initialize_create_image_dialog(dialog) {
});
$('#create_image_submit',dialog).click(function(){
$create_image_dialog = dialog;
var exit = false;
var upload = false;
$('.img_man',this).each(function(){

View File

@ -60,7 +60,6 @@ var market_actions = {
dialogs_context.append(marketplace_import_dialog);
$marketplace_import_dialog = $('#marketplace_import_dialog',dialogs_context);
$marketplace_import_dialog.addClass("reveal-modal large max-height").attr("data-reveal", "");
$marketplace_import_dialog.foundation().foundation('reveal', 'open');
var tab_id = 1;
@ -110,8 +109,8 @@ var market_actions = {
})
image_dialog.on("close", function(){
a_image_dialog.html("");
image_dialog.html("");
a_image_dialog.remove();
image_dialog.remove();
if ($('a', $("dl#marketplace_import_dialog_tabs")).size > 0) {
$('a', $("dl#marketplace_import_dialog_tabs")).first().click();
} else {
@ -125,7 +124,19 @@ var market_actions = {
})
if (response['opennebula_template'] && response['opennebula_template'] !== "CPU=1") {
$create_template_dialog.html("");
var opennebula_template;
try {
opennebula_template = JSON.parse(response['opennebula_template']);
} catch (error) {
notifyError("Error parsing OpenNebula template: " + error.message);
return;
}
if ($create_template_dialog) {
$create_template_dialog.html("");
}
// Template
// Append the new div containing the tab and add the tab to the list
var template_dialog = $('<div id="'+tab_id+'Tab" class="content disk wizard_internal_tab">'+
@ -137,17 +148,15 @@ var market_actions = {
</dd>").appendTo($("dl#marketplace_import_dialog_tabs"));
initialize_create_template_dialog(template_dialog);
fillTemplatePopUp(
JSON.parse(response['opennebula_template']),
template_dialog);
fillTemplatePopUp(opennebula_template, template_dialog);
a_template_dialog.on('click', function(){
$create_template_dialog = template_dialog;
})
template_dialog.on("close", function(){
a_template_dialog.html("");
template_dialog.html("");
a_template_dialog.remove();
template_dialog.remove();
if ($('a', $("dl#marketplace_import_dialog_tabs")).size > 0) {
$('a', $("dl#marketplace_import_dialog_tabs")).first().click();
} else {
@ -159,7 +168,13 @@ var market_actions = {
$("a[href='#manual']", template_dialog).closest('dl').remove();
}
$marketplace_import_dialog.foundation().foundation('reveal', 'open');
$('a', $("dl#marketplace_import_dialog_tabs")).first().click();
$marketplace_import_dialog.on('closed', function(){
$marketplace_import_dialog.remove();
$marketplace_import_dialog = undefined;
})
},
error: onError
},
@ -325,10 +340,9 @@ function updateMarketInfo(request,app){
function infoListenerMarket(dataTable){
$('tbody tr',dataTable).live("click",function(e){
if ($(e.target).is('input') ||
$(e.target).is('select') ||
$(e.target).is('option')) return true;
if ($(e.target).is('input') ||
$(e.target).is('select') ||
$(e.target).is('option')) return true;
var aData = dataTable.fnGetData(this);
var id =aData["_id"]["$oid"];

View File

@ -15,7 +15,7 @@
/* -------------------------------------------------------------------------- */
var create_template_tmpl = '\
<div class="row">'+
<div class="row" id="create_template_header_row">'+
'<div class="large-5 columns">'+
'<h3 class="subheader" id="create_template_header">'+tr("Create VM Template")+'</h3><h3 class="subheader" id="update_template_header" class="hidden">'+tr("Update VM Template")+'</h3>'+
'</div>'+
@ -226,8 +226,11 @@ var template_actions = {
type: "create",
call: OpenNebula.Template.create,
callback: function(request, response){
$create_template_dialog.foundation('reveal', 'close')
$create_template_dialog.empty();
if ($appmarket_import_dialog || $marketplace_import_dialog) {
$create_template_dialog.trigger('close');
} else {
$create_template_dialog.foundation('reveal', 'close');
}
addTemplateElement(request, response);
notifyCustom(tr("Template created"), " ID: " + response.VMTEMPLATE.ID, false)
},
@ -3250,16 +3253,16 @@ function setup_context_tab_content(context_section) {
$("td", this).removeClass('markrowchecked');
$('div#selected_files_spans span#tag_file_'+file_id, context_section).remove();
}
if ($.isEmptyObject(selected_files)) {
$('#files_selected', context_section).hide();
$('#select_files', context_section).show();
}
$('.alert-box', $('#contextTab')).hide();
generate_context_files();
return true;
});
@ -3772,6 +3775,7 @@ function initialize_create_template_dialog(dialog) {
//Process form
$('button#create_template_form_easy',dialog).click(function(){
$create_template_dialog = dialog;
//wrap it in the "vmtemplate" object
var vm_json = build_template();
vm_json = {vmtemplate: vm_json};

View File

@ -1242,6 +1242,7 @@ function updateView(item_list,dataTable){
//replaces an element with id 'tag' in a dataTable with a new one
function updateSingleElement(element,dataTable,tag){
// fnGetData should be used instead, otherwise it depends on the visible columns
var nodes = dataTable.fnGetNodes();
var tr = $(tag,nodes).parents('tr')[0];
var checked_val = $('input.check_item',tr).attr('checked');