mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
Merge branch 'feature-2589'
This commit is contained in:
commit
84c6f4475b
@ -154,25 +154,18 @@ function gzip_file_size {
|
||||
function fs_size {
|
||||
|
||||
case $1 in
|
||||
http://*/download|https://*/download)
|
||||
BASE_URL=${1%%/download}
|
||||
HEADERS=`wget -S --spider --no-check-certificate $BASE_URL 2>&1`
|
||||
http://*)
|
||||
HEADERS=`curl -LIk $1 2>&1`
|
||||
|
||||
echo $HEADERS | grep "market" > /dev/null 2>&1
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
#URL is from market place
|
||||
SIZE=`wget -O - -S --no-check-certificate $BASE_URL 2>&1|grep -E "^ *\"size\": \"?[0-9]+\"?.$"|tr -dc 0-9`
|
||||
if echo "$HEADERS" | grep -q "OpenNebula-AppMarket-Size"; then
|
||||
# An AppMarket/Marketplace URL
|
||||
SIZE=$(echo "$HEADERS" | grep "^OpenNebula-AppMarket-Size:" | tail -n1 | cut -d: -f2)
|
||||
else
|
||||
#Not a marketplace URL
|
||||
SIZE=`wget -S --spider --no-check-certificate $1 2>&1 | grep Content-Length | cut -d':' -f2`
|
||||
# Not an AppMarket/Marketplace URL
|
||||
SIZE=$(echo "$HEADERS" | grep "^Content-Length:" | tail -n1 | cut -d: -f2)
|
||||
fi
|
||||
error=$?
|
||||
;;
|
||||
http://*|https://*)
|
||||
SIZE=`wget -S --spider --no-check-certificate $1 2>&1 | grep Content-Length | cut -d':' -f2`
|
||||
error=$?
|
||||
;;
|
||||
*)
|
||||
if [ -d "$1" ]; then
|
||||
SIZE=`du -sb "$1" | cut -f1`
|
||||
@ -195,6 +188,8 @@ function fs_size {
|
||||
;;
|
||||
esac
|
||||
|
||||
SIZE=$(echo $SIZE | tr -d "\r")
|
||||
|
||||
if [ $error -ne 0 ]; then
|
||||
SIZE=0
|
||||
else
|
||||
|
@ -344,9 +344,12 @@ var image_actions = {
|
||||
"Image.create" : {
|
||||
type: "create",
|
||||
call: OpenNebula.Image.create,
|
||||
callback: addImageElement,
|
||||
error: onError,
|
||||
notify:true
|
||||
callback: function(request, response){
|
||||
addImageElement(request, response);
|
||||
$create_image_dialog.trigger("reveal:close")
|
||||
notifyCustom(tr("Image created "), "ID: " + response.IMAGE.ID, false)
|
||||
},
|
||||
error: onError
|
||||
},
|
||||
|
||||
"Image.create_dialog" : {
|
||||
@ -866,26 +869,20 @@ function enable_all_datastores()
|
||||
}
|
||||
|
||||
// Prepare the image creation dialog
|
||||
function setupCreateImageDialog(){
|
||||
function setupCreateImageDialog(dialog){
|
||||
dialogs_context.append('<div id="create_image_dialog"></div>');
|
||||
$create_image_dialog = $('#create_image_dialog',dialogs_context);
|
||||
|
||||
var dialog = $create_image_dialog;
|
||||
dialog.html(create_image_tmpl);
|
||||
|
||||
setupTips($create_image_dialog);
|
||||
|
||||
var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window
|
||||
|
||||
//Prepare jquery dialog
|
||||
//dialog.dialog({
|
||||
// autoOpen: false,
|
||||
// modal:true,
|
||||
// width: 520,
|
||||
// height: height
|
||||
//});
|
||||
dialog.addClass("reveal-modal large max-height");
|
||||
|
||||
initialize_create_image_dialog(dialog);
|
||||
}
|
||||
|
||||
function initialize_create_image_dialog(dialog) {
|
||||
setupTips(dialog);
|
||||
$('.advanced',dialog).hide();
|
||||
|
||||
$('#advanced_image_create',dialog).click(function(){
|
||||
@ -893,32 +890,24 @@ function setupCreateImageDialog(){
|
||||
return false;
|
||||
});
|
||||
|
||||
//$('#img_tabs',dialog).tabs();
|
||||
//$('button',dialog).button();
|
||||
//$('#datablock_img',dialog).attr('disabled','disabled');
|
||||
|
||||
|
||||
$('select#img_type',dialog).change(function(){
|
||||
var value = $(this).val();
|
||||
var context = $create_image_dialog;
|
||||
var context = dialog;
|
||||
switch (value){
|
||||
case "DATABLOCK":
|
||||
$('#datablock_img',context).removeAttr("disabled");
|
||||
//$('#empty_datablock', context).show();
|
||||
break;
|
||||
default:
|
||||
$('#datablock_img',context).attr('disabled','disabled');
|
||||
//$('#empty_datablock', context).hide();
|
||||
$('#path_img',context).click();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('#img_path,#img_fstype,#img_size,#file-uploader',dialog).closest('.row').hide();
|
||||
|
||||
$("input[name='src_path']", dialog).change(function(){
|
||||
var context = $create_image_dialog;
|
||||
var context = dialog;
|
||||
var value = $(this).val();
|
||||
switch (value){
|
||||
case "path":
|
||||
@ -942,8 +931,8 @@ function setupCreateImageDialog(){
|
||||
|
||||
$('#add_custom_var_image_button', dialog).click(
|
||||
function(){
|
||||
var name = $('#custom_var_image_name',$create_image_dialog).val();
|
||||
var value = $('#custom_var_image_value',$create_image_dialog).val();
|
||||
var name = $('#custom_var_image_name',dialog).val();
|
||||
var value = $('#custom_var_image_value',dialog).val();
|
||||
if (!name.length || !value.length) {
|
||||
notifyError(tr("Custom attribute name and value must be filled in"));
|
||||
return false;
|
||||
@ -951,14 +940,14 @@ function setupCreateImageDialog(){
|
||||
option= '<option value=\''+value+'\' name=\''+name+'\'>'+
|
||||
name+'='+value+
|
||||
'</option>';
|
||||
$('select#custom_var_image_box',$create_image_dialog).append(option);
|
||||
$('select#custom_var_image_box',dialog).append(option);
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
$('#remove_custom_var_image_button', dialog).click(
|
||||
function(){
|
||||
$('select#custom_var_image_box :selected',$create_image_dialog).remove();
|
||||
$('select#custom_var_image_box :selected',dialog).remove();
|
||||
return false;
|
||||
}
|
||||
);
|
||||
@ -966,9 +955,7 @@ function setupCreateImageDialog(){
|
||||
$('#upload-progress',dialog).css({
|
||||
border: "1px solid #AAAAAA",
|
||||
position: "relative",
|
||||
// bottom: "29px",
|
||||
width: "258px",
|
||||
// left: "133px",
|
||||
height: "15px",
|
||||
display: "inline-block"
|
||||
});
|
||||
@ -978,7 +965,7 @@ function setupCreateImageDialog(){
|
||||
|
||||
// Upload is handled by FileUploader vendor plugin
|
||||
var uploader = new qq.FileUploaderBasic({
|
||||
button: $('#file-uploader',$create_image_dialog)[0],
|
||||
button: $('#file-uploader',dialog)[0],
|
||||
action: 'upload',
|
||||
multiple: false,
|
||||
params: {},
|
||||
@ -987,35 +974,11 @@ function setupCreateImageDialog(){
|
||||
//notifyMessage(message);
|
||||
},
|
||||
onSubmit: function(id, fileName){
|
||||
//set url params
|
||||
//since the body is the upload, we need the pass
|
||||
//the image info here
|
||||
uploader.setParams({
|
||||
img : JSON.stringify(img_obj),
|
||||
file: fileName
|
||||
});
|
||||
//we pop up an upload progress dialog
|
||||
//var pos_top = $(window).height() - 120;
|
||||
//var pos_left = 220;
|
||||
//var pb_dialog = $('<div id="pb_dialog" title="'+
|
||||
// tr("Uploading...")+'">'+
|
||||
// '<div id="upload-progress"></div>'+
|
||||
// '</div>').dialog({
|
||||
// draggable:true,
|
||||
// modal:false,
|
||||
// resizable:false,
|
||||
// buttons:{},
|
||||
// width: 460,
|
||||
// minHeight: 50,
|
||||
// position: [pos_left, pos_top]
|
||||
// });
|
||||
|
||||
//var pb_dialog = $('<div id="pb_dialog" title="'+
|
||||
// tr("Uploading...")+'">'+
|
||||
// '<div id="upload-progress"></div>'+
|
||||
// '</div>').addClass("reveal-modal");
|
||||
|
||||
//$('#upload-progress',pb_dialog).progressbar({value:0});
|
||||
$('#upload_progress_bars').append('<div id="'+id+'progressBar" class="row" style="margin-bottom:10px">\
|
||||
<div class="two columns dataTables_info">\
|
||||
'+tr("Uploading...")+'\
|
||||
@ -1029,8 +992,6 @@ function setupCreateImageDialog(){
|
||||
</div>');
|
||||
},
|
||||
onProgress: function(id, fileName, loaded, total){
|
||||
//update upload dialog with current progress
|
||||
//$('div#pb_dialog #upload-progress').progressbar("option","value",Math.floor(loaded*100/total));
|
||||
$('span.meter', $('#'+id+'progressBar')).css('width', Math.floor(loaded*100/total)+'%')
|
||||
},
|
||||
onComplete: function(id, fileName, responseJSON){
|
||||
@ -1152,7 +1113,7 @@ function setupCreateImageDialog(){
|
||||
}
|
||||
|
||||
//Time to add custom attributes
|
||||
$('#custom_var_image_box option',$create_image_dialog).each(function(){
|
||||
$('#custom_var_image_box option',dialog).each(function(){
|
||||
var attr_name = $(this).attr('name');
|
||||
var attr_value = $(this).val();
|
||||
img_json[attr_name] = attr_value;
|
||||
@ -1170,8 +1131,6 @@ function setupCreateImageDialog(){
|
||||
Sunstone.runAction("Image.create", img_obj);
|
||||
};
|
||||
|
||||
$create_image_dialog.trigger("reveal:close")
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
@ -1192,21 +1151,21 @@ function setupCreateImageDialog(){
|
||||
"ds_id" : ds_id
|
||||
};
|
||||
Sunstone.runAction("Image.create",img_obj);
|
||||
$create_image_dialog.trigger("reveal:close")
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#wizard_image_reset_button').click(function(){
|
||||
$create_image_dialog.trigger('reveal:close');
|
||||
$create_image_dialog.remove();
|
||||
dialog.trigger('reveal:close');
|
||||
dialog.remove();
|
||||
setupCreateImageDialog();
|
||||
|
||||
popUpCreateImageDialog();
|
||||
});
|
||||
|
||||
$('#advanced_image_reset_button').click(function(){
|
||||
$create_image_dialog.trigger('reveal:close');
|
||||
$create_image_dialog.remove();
|
||||
dialog.trigger('reveal:close');
|
||||
dialog.remove();
|
||||
setupCreateImageDialog();
|
||||
|
||||
popUpCreateImageDialog();
|
||||
@ -1214,10 +1173,7 @@ function setupCreateImageDialog(){
|
||||
});
|
||||
}
|
||||
|
||||
function popUpCreateImageDialog(){
|
||||
$('#file-uploader input',$create_image_dialog).removeAttr("style");
|
||||
$('#file-uploader input',$create_image_dialog).attr('style','margin:0;width:256px!important');
|
||||
|
||||
function initialize_datastore_info_create_image_dialog(dialog) {
|
||||
datastores_str = makeSelectOptions(dataTable_datastores,
|
||||
1,
|
||||
4,
|
||||
@ -1226,18 +1182,23 @@ function popUpCreateImageDialog(){
|
||||
true
|
||||
);
|
||||
|
||||
$('#img_datastore',$create_image_dialog).html(datastores_str);
|
||||
$('#img_datastore_raw',$create_image_dialog).html(datastores_str);
|
||||
$('#img_datastore',dialog).html(datastores_str);
|
||||
$('#img_datastore_raw',dialog).html(datastores_str);
|
||||
|
||||
$create_image_dialog.reveal();
|
||||
$("input#img_name",$create_image_dialog).focus();
|
||||
|
||||
$('select#img_datastore').children('option').each(function() {
|
||||
if ($(this).val() == "2")
|
||||
{
|
||||
$('select#img_datastore', dialog).children('option').each(function() {
|
||||
if ($(this).val() == "2") {
|
||||
$(this).attr('disabled', 'disabled');
|
||||
}
|
||||
});
|
||||
|
||||
$('#file-uploader input',dialog).removeAttr("style");
|
||||
$('#file-uploader input',dialog).attr('style','margin:0;width:256px!important');
|
||||
}
|
||||
|
||||
function popUpCreateImageDialog(){
|
||||
initialize_datastore_info_create_image_dialog($create_image_dialog);
|
||||
$create_image_dialog.reveal();
|
||||
$("input#img_name",$create_image_dialog).focus();
|
||||
}
|
||||
|
||||
// Set the autorefresh interval for the datatable
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
/* Marketpplace tab plugin */
|
||||
var dataTable_marketplace;
|
||||
var $marketplace_import_dialog;
|
||||
|
||||
var market_actions = {
|
||||
"Marketplace.list" : {
|
||||
@ -42,36 +43,115 @@ var market_actions = {
|
||||
elements: marketplaceElements,
|
||||
call: OpenNebula.Marketplace.show,
|
||||
callback: function(request,response){
|
||||
$('#img_name', $create_image_dialog).val(response['name']);
|
||||
$('#img_path', $create_image_dialog).val(response['links']['download']['href']);
|
||||
$('#src_path_select input[value="path"]', $create_image_dialog).trigger('click');
|
||||
$('select#img_type', $create_image_dialog).val('OS');
|
||||
$('select#img_type', $create_image_dialog).trigger('change');
|
||||
|
||||
if (response['files'][0]['hypervisor'] == "KVM") {
|
||||
$('#img_driver', $create_image_dialog).val(response['files'][0]['format'])
|
||||
if (response['status'] && response['status'] != 'ready') {
|
||||
notifyError(tr("The appliance is not ready"));
|
||||
return;
|
||||
}
|
||||
|
||||
//remove any options from the custom vars dialog box
|
||||
$("#custom_var_image_box",$create_image_dialog).empty();
|
||||
|
||||
var md5 = response['files'][0]['md5']
|
||||
if ( md5 ) {
|
||||
option = '<option value=\'' +
|
||||
md5 + '\' name="MD5">MD5=' +
|
||||
md5 + '</option>';
|
||||
$("#custom_var_image_box",$create_image_dialog).append(option);
|
||||
if ($marketplace_import_dialog != undefined) {
|
||||
$marketplace_import_dialog.remove();
|
||||
}
|
||||
|
||||
var sha1 = response['files'][0]['sha1']
|
||||
if ( sha1 ) {
|
||||
option = '<option value=\'' +
|
||||
sha1 + '\' name="SHA1">SHA1=' +
|
||||
sha1 + '</option>';
|
||||
$("#custom_var_image_box",$create_image_dialog).append(option);
|
||||
dialogs_context.append(marketplace_import_dialog);
|
||||
$marketplace_import_dialog = $('#marketplace_import_dialog',dialogs_context);
|
||||
$marketplace_import_dialog.addClass("reveal-modal xlarge max-height");
|
||||
$marketplace_import_dialog.reveal();
|
||||
|
||||
var tab_id = 1;
|
||||
|
||||
$.each(response['files'], function(index, value){
|
||||
// Append the new div containing the tab and add the tab to the list
|
||||
var image_dialog = $('<li id="'+tab_id+'Tab" class="disk wizard_internal_tab">'+
|
||||
create_image_tmpl +
|
||||
'</li>').appendTo($("ul#marketplace_import_dialog_tabs_content"));
|
||||
|
||||
var a_image_dialog = $("<dd>\
|
||||
<a id='disk_tab"+tab_id+"' href='#"+tab_id+"'>"+tr("Image")+"</a>\
|
||||
</dd>").appendTo($("dl#marketplace_import_dialog_tabs"));
|
||||
|
||||
initialize_create_image_dialog(image_dialog);
|
||||
initialize_datastore_info_create_image_dialog(image_dialog);
|
||||
|
||||
$('#img_name', image_dialog).val(value['name']||response['name']);
|
||||
$('#img_path', image_dialog).val(response['links']['download']['href']+'/'+index);
|
||||
$('#src_path_select input[value="path"]', image_dialog).trigger('click');
|
||||
$('select#img_type', image_dialog).val(value['type']);
|
||||
$('select#img_type', image_dialog).trigger('change');
|
||||
|
||||
//remove any options from the custom vars dialog box
|
||||
$("#custom_var_image_box",image_dialog).empty();
|
||||
|
||||
var md5 = value['md5']
|
||||
if ( md5 ) {
|
||||
option = '<option value=\'' +
|
||||
md5 + '\' name="MD5">MD5=' +
|
||||
md5 + '</option>';
|
||||
$("#custom_var_image_box",image_dialog).append(option);
|
||||
}
|
||||
|
||||
var sha1 = value['sha1']
|
||||
if ( sha1 ) {
|
||||
option = '<option value=\'' +
|
||||
sha1 + '\' name="SHA1">SHA1=' +
|
||||
sha1 + '</option>';
|
||||
$("#custom_var_image_box",image_dialog).append(option);
|
||||
}
|
||||
|
||||
a_image_dialog.on('click', function(){
|
||||
$create_image_dialog = image_dialog;
|
||||
})
|
||||
|
||||
image_dialog.on("reveal:close", function(){
|
||||
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 {
|
||||
$marketplace_import_dialog.trigger("reveal:close");
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$("a[href='#img_manual']", image_dialog).closest('dl').remove();
|
||||
tab_id++;
|
||||
})
|
||||
|
||||
if (response['opennebula_template'] && response['opennebula_template'] !== "CPU=1") {
|
||||
$create_template_dialog.remove();
|
||||
// Template
|
||||
// Append the new div containing the tab and add the tab to the list
|
||||
var template_dialog = $('<li id="'+tab_id+'Tab" class="disk wizard_internal_tab">'+
|
||||
create_template_tmpl +
|
||||
'</li>').appendTo($("ul#marketplace_import_dialog_tabs_content"));
|
||||
|
||||
var a_template_dialog = $("<dd>\
|
||||
<a id='disk_tab"+tab_id+"' href='#"+tab_id+"'>"+tr("Template")+"</a>\
|
||||
</dd>").appendTo($("dl#marketplace_import_dialog_tabs"));
|
||||
|
||||
initialize_create_template_dialog(template_dialog);
|
||||
fillTemplatePopUp(
|
||||
JSON.parse(response['opennebula_template']),
|
||||
template_dialog);
|
||||
|
||||
a_template_dialog.on('click', function(){
|
||||
$create_template_dialog = template_dialog;
|
||||
})
|
||||
|
||||
template_dialog.on("reveal:close", function(){
|
||||
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 {
|
||||
$marketplace_import_dialog.trigger("reveal:close");
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$("a[href='#manual']", template_dialog).closest('dl').remove();
|
||||
}
|
||||
|
||||
popUpCreateImageDialog();
|
||||
$('a', $("dl#marketplace_import_dialog_tabs")).first().click();
|
||||
},
|
||||
error: onError
|
||||
},
|
||||
@ -97,6 +177,20 @@ var market_buttons = {
|
||||
}
|
||||
};
|
||||
|
||||
var marketplace_import_dialog =
|
||||
'<div id="marketplace_import_dialog">'+
|
||||
'<div class="panel">'+
|
||||
'<h3><small>'+tr("Import Appliance")+'</small></h4>'+
|
||||
'</div>'+
|
||||
'<div class="reveal-body">'+
|
||||
'<dl class="tabs" id="marketplace_import_dialog_tabs">'+
|
||||
'</dl>'+
|
||||
'<ul class="tabs-content" id="marketplace_import_dialog_tabs_content">'+
|
||||
'</ul>'+
|
||||
'</div>'+
|
||||
'<a class="close-reveal-modal">×</a>'+
|
||||
'</div>';
|
||||
|
||||
var marketplace_tab_content = '\
|
||||
<form class="custom" id="marketplace_form" action="">\
|
||||
<div class="panel">\
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -336,6 +336,11 @@ function notifyMessage(msg){
|
||||
$.jGrowl(msg, {theme: "jGrowl-notify-submit", position: "bottom-right"});
|
||||
}
|
||||
|
||||
function notifyCustom(title, msg, sticky) {
|
||||
msg = "<h1>" + title + "</h1>" + msg;
|
||||
$.jGrowl(msg, {theme: "jGrowl-notify-submit", position: "bottom-right", sticky: sticky });
|
||||
}
|
||||
|
||||
// Returns an HTML string with the json keys and values
|
||||
// Attempts to css format output, giving different values to
|
||||
// margins etc. according to depth level etc.
|
||||
|
Loading…
Reference in New Issue
Block a user