diff --git a/src/sunstone/public/js/plugins/files-tab.js b/src/sunstone/public/js/plugins/files-tab.js index 6b9d4ce582..2d7b539861 100644 --- a/src/sunstone/public/js/plugins/files-tab.js +++ b/src/sunstone/public/js/plugins/files-tab.js @@ -14,133 +14,117 @@ /* limitations under the License. */ /* -------------------------------------------------------------------------- */ -var create_file_tmpl = - '
\ -

'+tr("Create File")+'

\ -
\ -
\ -
\ -
\ -
'+tr("Wizard")+'
\ -
'+tr("Advanced mode")+'
\ +var create_file_tmpl ='
\ +
\ +

'+tr("Create File")+'

'+ + '
'+ + '\ +
\ +
\ + \
\
\ -
\ -
\ -
\ -
\ - \ +
\ +
\ +
\ +
\ + \ + \ +
\
\ -
\ - \ +
\ +
\ + \ + \ +
\
\ -
'+tr("Name that the File will get. Every file must have a unique name.")+'
\
\ -
\ -
\ - \ +
\ +
\ +
\ + \ + \ +
\
\ -
\ - \ -
\ -
\ -
'+tr("Human readable description of the file for other users.")+'
\ +
\ +
\ + \ + \ +
\
\
\
\ -
\ -
\ -
\ - \ +
\ + '+tr("Image location")+':\ +
\ +
\ + \ + \
\ -
\ - \ +
\ +
\ +
\ +
\ + \ + \
\ -
\ -
'+tr("Type of the file, explained in detail in the following section. If omitted, the default value is the one defined in oned.conf (install default is OS).")+'
\ +
\ +
\ +
\
\ -
\ -
\ -
\ - \ -
\ -
\ - \ -
\ -
\ -
'+tr("Select the datastore for this file")+'
\ -
\ -
\ -
\ +
\ +
\ + \
\ -
\ -
\ - \ -
\ -
\ +
\ +
\ +
\ + \ \
\ - \ +
\ +
\ +
\ + \ +
\ +
\
\ \
\ -
\ - ×\ - \ -
'; + ×\ + \ +
'; var dataTable_files; var $create_file_dialog; @@ -469,26 +453,26 @@ function updateFilesView(request, files_list){ } // Callback to update the information panel tabs and pop it up -function updateFileInfo(request,img){ - var img_info = img.IMAGE; +function updateFileInfo(request,file){ + var file_info = file.IMAGE; var info_tab = { title : tr("Info"), icon: "fa-info-circle", content: '
\
\ - \ +
\ \ - \ + \ \ \ \ - \ + \ \ \ \ \ - \ + \ \ \ \ - \ + \ \ \ \ \ - \ + \ \ \ \ - \ + \ \ \ \ \ - \ + \ \ \ \ \ - \ + \ \ \ \ \ - \ + \ \ \ \ \ - \ + \ \ \
'+tr("File")+' - '+img_info.NAME+'
'+tr("File")+' - '+file_info.NAME+'
'+tr("ID")+''+img_info.ID+''+file_info.ID+'
'+tr("Name")+''+img_info.NAME+''+file_info.NAME+'
\ \
\ @@ -496,12 +480,12 @@ function updateFileInfo(request,img){
'+tr("Datastore")+''+img_info.DATASTORE+''+file_info.DATASTORE+'
'+tr("Type")+''+OpenNebula.Helper.image_type(img_info.TYPE)+''+OpenNebula.Helper.image_type(file_info.TYPE)+'
\ \
\ @@ -509,27 +493,27 @@ function updateFileInfo(request,img){
'+tr("Register time")+''+pretty_time(img_info.REGTIME)+''+pretty_time(file_info.REGTIME)+'
'+tr("Filesystem type")+''+(typeof img_info.FSTYPE === "string" ? img_info.FSTYPE : "--")+''+(typeof file_info.FSTYPE === "string" ? file_info.FSTYPE : "--")+'
'+tr("Size")+''+humanize_size_from_mb(img_info.SIZE)+''+humanize_size_from_mb(file_info.SIZE)+'
'+tr("State")+''+OpenNebula.Helper.resource_state("file",img_info.STATE)+''+OpenNebula.Helper.resource_state("file",file_info.STATE)+'
'+tr("Running VMS")+''+img_info.RUNNING_VMS+''+file_info.RUNNING_VMS+'
\ @@ -537,14 +521,14 @@ function updateFileInfo(request,img){
' + insert_permissions_table('files-tab', "File", - img_info.ID, - img_info.UNAME, - img_info.GNAME, - img_info.UID, - img_info.GID) + - insert_extended_template_table(img_info.TEMPLATE, + file_info.ID, + file_info.UNAME, + file_info.GNAME, + file_info.UID, + file_info.GID) + + insert_extended_template_table(file_info.TEMPLATE, "File", - img_info.ID, + file_info.ID, "Configuration & Tags") + '
\
' @@ -570,7 +554,7 @@ function updateFileInfo(request,img){ { // Let OpenNebula know var name_template = {"name": value_str}; - Sunstone.runAction("File.rename",img_info.ID,name_template); + Sunstone.runAction("File.rename",file_info.ID,name_template); } }); @@ -588,8 +572,8 @@ function updateFileInfo(request,img){ $("#chg_type_select_files").live("change", function() { var new_value=$("option:selected", this).text(); - Sunstone.runAction("File.chtype", img_info.ID, new_value); - Sunstone.runAction("File.showinfo", img_info.ID); + Sunstone.runAction("File.chtype", file_info.ID, new_value); + Sunstone.runAction("File.showinfo", file_info.ID); }); @@ -598,10 +582,10 @@ function updateFileInfo(request,img){ $("#file_info_panel_refresh", $("#file_info_panel")).click(function(){ $(this).html(spinner); - Sunstone.runAction('File.showinfo', img_info.ID); + Sunstone.runAction('File.showinfo', file_info.ID); }) - setPermissionsTable(img_info,''); + setPermissionsTable(file_info,''); } @@ -615,80 +599,33 @@ function enable_all_datastores() // Prepare the file creation dialog function setupCreateFileDialog(){ - dialogs_context.append('
'); + dialogs_context.append('
'); $create_file_dialog = $('#create_file_dialog',dialogs_context); var dialog = $create_file_dialog; dialog.html(create_file_tmpl); - var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window + dialog.addClass("reveal-modal medium max-height").attr("data-reveal", ""); - dialog.addClass("reveal-modal large max-height").attr("data-reveal", ""); - - $('select#img_type',dialog).change(function(){ - var value = $(this).val(); - var context = $create_file_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,#files_file-uploader',dialog).closest('.row').hide(); + $('#files_file-uploader',dialog).closest('.row').hide(); $("input[name='src_path']", dialog).change(function(){ var context = $create_file_dialog; var value = $(this).val(); switch (value){ case "path": - $('#img_fstype,#img_size,#files_file-uploader',context).closest('.row').hide(); - $('#img_path',context).closest('.row').show(); - break; - case "datablock": - $('#img_path,#files_file-uploader',context).closest('.row').hide(); - $('#img_fstype,#img_size',context).closest('.row').show(); + $('#files_file-uploader',context).closest('.row').hide(); + $('#file_path',context).closest('.row').show(); break; case "upload": - $('#img_path,#img_fstype,#img_size',context).closest('.row').hide(); + $('#file_path',context).closest('.row').hide(); $('#files_file-uploader',context).closest('.row').show(); break; }; }); - $('#path_img',dialog).click(); - - - $('#add_custom_var_file_button', dialog).click( - function(){ - var name = $('#custom_var_file_name',$create_file_dialog).val(); - var value = $('#custom_var_file_value',$create_file_dialog).val(); - if (!name.length || !value.length) { - notifyError(tr("Custom attribute name and value must be filled in")); - return false; - } - option= ''; - $('select#custom_var_file_box',$create_file_dialog).append(option); - return false; - } - ); - - $('#remove_custom_var_file_button', dialog).click( - function(){ - $('select#custom_var_file_box :selected',$create_file_dialog).remove(); - return false; - } - ); + $('#path_file',dialog).click(); $('#upload-progress',dialog).css({ border: "1px solid #AAAAAA", @@ -701,7 +638,7 @@ function setupCreateFileDialog(){ }); $('#upload-progress div',dialog).css("border","1px solid #AAAAAA"); - var img_obj; + var file_obj; // Upload is handled by FileUploader vendor plugin var uploader = new qq.FileUploaderBasic({ @@ -718,25 +655,12 @@ function setupCreateFileDialog(){ //since the body is the upload, we need the pass //the file info here uploader.setParams({ - img : JSON.stringify(img_obj), + img : JSON.stringify(file_obj), file: fileName }); //we pop up an upload progress dialog var pos_top = $(window).height() - 120; var pos_left = 220; - //var pb_dialog = $('
'+ - // '
'+ - // '
').dialog({ - // draggable:true, - // modal:false, - // resizable:false, - // buttons:{}, - // width: 460, - // minHeight: 50, - // position: [pos_left, pos_top] - // }); - $('#files_upload_progress_bars').append('
\
\ @@ -753,8 +677,6 @@ function setupCreateFileDialog(){ $('#files'+id+'cancel_upload').click(function(){ uploader.cancel(); }) - - //$('#upload-progress',pb_dialog).progressbar({value:0}); }, onProgress: function(id, fileName, loaded, total){ //update upload dialog with current progress @@ -773,7 +695,7 @@ function setupCreateFileDialog(){ $('#files'+id+'progressBar').remove(); } - //Inform complete upload, destroy upload dialog, refresh img list + //Inform complete upload, destroy upload dialog, refresh file list $('div#pb_dialog').foundation('reveal', 'close') return false; @@ -787,19 +709,8 @@ function setupCreateFileDialog(){ file_input = input; return false; }; - - $('#create_file_submit',dialog).click(function(){ - var exit = false; var upload = false; - $('.img_man',this).each(function(){ - if (!$('input',this).val().length){ - notifyError(tr("There are mandatory parameters missing")); - exit = true; - return false; - } - }); - if (exit) { return false; } var ds_id = $('#file_datastore',dialog).val(); if (!ds_id){ @@ -807,47 +718,39 @@ function setupCreateFileDialog(){ return false; }; - var img_json = {}; + var file_json = {}; - var name = $('#img_name',dialog).val(); - img_json["NAME"] = name; + var name = $('#file_name',dialog).val(); + file_json["NAME"] = name; - var desc = $('#img_desc',dialog).val(); + var desc = $('#file_desc',dialog).val(); if (desc.length){ - img_json["DESCRIPTION"] = desc; + file_json["DESCRIPTION"] = desc; } - var type = $('#img_type',dialog).val(); - img_json["TYPE"]= type; + var type = $('#file_type',dialog).val(); + file_json["TYPE"]= type; switch ($('#src_path_select input:checked',dialog).val()){ case "path": - path = $('#img_path',dialog).val(); - if (path) img_json["PATH"] = path; + path = $('#file_path',dialog).val(); + if (path) file_json["PATH"] = path; break; case "upload": upload=true; break; } - //Time to add custom attributes - $('#custom_var_file_box option',$create_file_dialog).each(function(){ - var attr_name = $(this).attr('name'); - var attr_value = $(this).val(); - img_json[attr_name] = attr_value; - }); - - img_obj = { "image" : img_json, + file_obj = { "image" : file_json, "ds_id" : ds_id}; - //we this is an file upload we trigger FileUploader //to start the upload if (upload){ uploader._onInputChange(file_input); } else { - Sunstone.runAction("File.create", img_obj); + Sunstone.runAction("File.create", file_obj); }; $create_file_dialog.foundation('reveal', 'close') @@ -863,13 +766,13 @@ function setupCreateFileDialog(){ return false; }; - var img_obj = { + var file_obj = { "image" : { "image_raw" : template }, "ds_id" : ds_id }; - Sunstone.runAction("File.create",img_obj); + Sunstone.runAction("File.create",file_obj); $create_file_dialog.foundation('reveal', 'close') return false; }); @@ -892,7 +795,7 @@ function popUpCreateFileDialog(){ $('#file_datastore_raw',$create_file_dialog).html(datastores_str); $create_file_dialog.foundation().foundation('reveal', 'open'); - $("input#img_name",$create_file_dialog).focus(); + $("input#file_name",$create_file_dialog).focus(); } // Set the autorefresh interval for the datatable diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js index e3d1e35a4a..4ccd286793 100644 --- a/src/sunstone/public/js/plugins/images-tab.js +++ b/src/sunstone/public/js/plugins/images-tab.js @@ -33,172 +33,172 @@ var create_image_tmpl ='
\
\
\
\ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ +
\ +
\ +
\ +
\ + \ + \
\
\ -
\ - '+tr("Image location")+':\ -
\ -
\ - \ - \ - \ -
\ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ - \ - \ -
\ +
\ +
\ + \ + \
\ -
\ -
\ -

'+tr("Advanced options")+'

\ +
\
\ -
\ +
\
\ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ +
\ + \ + \
\
\
\ -
\ - ' + tr("Custom attributes") + '\ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ -
\ -
\ - \ -
\ -
\ -
\ -
\ -
\ +
\ + \ + \ +
\
\ +
\ +
\ + \ + \ +
\ +
\ +
\
\ +
\ + '+tr("Image location")+':\ +
\ +
\ + \ + \ + \ +
\ +
\ +
\ +
\ +
\ + \ + \ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ + \ + \ +
\ +
\ + \ + \ +
\ +
\ +
\ +
\ +

'+tr("Advanced options")+'

\ +
\ +
\ +
\ +
\ +
\ +
\ + \ + \ +
\ +
\ +
\ +
\ + \ + \ +
\ +
\ +
\ +
\ +
\ +
\ + \ + \ +
\ +
\ +
\ +
\ +
\ +
\ + ' + tr("Custom attributes") + '\ +
\ +
\ +
\ +
\ + \ + \ +
\ +
\ +
\ +
\ + \ + \ +
\ +
\ +
\ +
\ + \ + \ +
\ +
\ +
\ +
\ +
\ +
\ + \ +
\ +
\ +
\ +
\ +
\ +
\ +
\