diff --git a/install.sh b/install.sh index 72745c18a0..60e7bfc776 100755 --- a/install.sh +++ b/install.sh @@ -1403,6 +1403,7 @@ SUNSTONE_PUBLIC_JS_PLUGINS_FILES="\ src/sunstone/public/js/plugins/infra-tab.js \ src/sunstone/public/js/plugins/groups-tab.js \ src/sunstone/public/js/plugins/images-tab.js \ + src/sunstone/public/js/plugins/files-tab.js \ src/sunstone/public/js/plugins/templates-tab.js \ src/sunstone/public/js/plugins/users-tab.js \ src/sunstone/public/js/plugins/vms-tab.js \ diff --git a/src/sunstone/etc/sunstone-plugins.yaml b/src/sunstone/etc/sunstone-plugins.yaml index 489f8c4b01..07e032a345 100644 --- a/src/sunstone/etc/sunstone-plugins.yaml +++ b/src/sunstone/etc/sunstone-plugins.yaml @@ -47,6 +47,10 @@ :ALL: true :user: :group: +- plugins/files-tab.js: + :ALL: true + :user: + :group: - plugins/infra-tab.js: :ALL: true :user: diff --git a/src/sunstone/public/js/plugins/files-tab.js b/src/sunstone/public/js/plugins/files-tab.js new file mode 100644 index 0000000000..c1aaa0bba2 --- /dev/null +++ b/src/sunstone/public/js/plugins/files-tab.js @@ -0,0 +1,1088 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +/*Files tab plugin*/ + +var files_tab_content = '\ +
\ +
\ +
\ +
\ +

\ + \ + '+tr("Files & Kernels")+'\ + \ + \ + '+tr("TOTAL")+' \ + '+tr("SIZE")+'\ + \ + \ +

\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ + \ +
\ +
\ +
\ +
\ +
\ +\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
'+tr("ID")+''+tr("Owner")+''+tr("Group")+''+tr("Name")+''+tr("Datastore")+''+tr("Size")+''+tr("Type")+''+tr("Registration time")+''+tr("Persistent")+''+tr("Status")+''+tr("#VMS")+''+tr("Target")+'
\ +
\ + ?\ +

\ +'+tr("Size and registration time are hidden colums. Note that persistent files can only be used by 1 VM. To change file datastore, please re-register the file.")+'\ +

\ +
\ +'; + +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("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("File location")+':\ +
\ +
\ + '+ tr("Provide a path")+'  \ + '+tr("Upload")+'  \ +
\ +
\ +
\ +
\ +
\ + \ +
\ +
\ + \ +
\ +
\ +
'+tr("Path to the original file that will be copied to the file repository. If not specified for a DATABLOCK type file, an empty file will be created.")+'
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +

'+tr("Advanced options")+'

\ +
\ +
\ +
\ +
\ +
\ +
\ + \ +
\ +
\ + \ +
\ +
\ +
'+tr("Select the datastore for this file")+'
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ + \ +
\ + \ + \ + \ +
\ + ×\ +
'; + +var dataTable_files; +var $create_file_dialog; + +var file_actions = { + + "File.create" : { + type: "create", + call: OpenNebula.Image.create, + callback: addFileElement, + error: onError, + notify:true + }, + + "File.create_dialog" : { + type: "custom", + call: popUpCreateFileDialog + }, + + "File.list" : { + type: "list", + call: OpenNebula.Image.list, + callback: updateFilesView, + error: onError + }, + + "File.show" : { + type : "single", + call: OpenNebula.Image.show, + callback: updateFileElement, + error: onError + }, + + "File.showinfo" : { + type: "single", + call: OpenNebula.Image.show, + callback: updateFileInfo, + error: onError + }, + + "File.refresh" : { + type: "custom", + call: function () { + waitingNodes(dataTable_files); + Sunstone.runAction("File.list"); + } + }, + + "File.autorefresh" : { + type: "custom", + call: function() { + OpenNebula.Image.list({timeout: true, success: updateFilesView, error: onError}); + } + }, + + "File.update_template" : { + type: "single", + call: OpenNebula.Image.update, + callback: function(request) { + notifyMessage("Template updated correctly"); + Sunstone.runAction('Image.showinfo',request.request.data[0]); + }, + error: onError + }, + + "File.enable" : { + type: "multiple", + call: OpenNebula.Image.enable, + callback: function (req) { + Sunstone.runAction("File.show",req.request.data[0]); + }, + elements: fileElements, + error: onError, + notify: true + }, + + "File.disable" : { + type: "multiple", + call: OpenNebula.Image.disable, + callback: function (req) { + Sunstone.runAction("File.show",req.request.data[0]); + }, + elements: fileElements, + error: onError, + notify: true + }, + + "File.delete" : { + type: "multiple", + call: OpenNebula.Image.del, + callback: deleteFileElement, + elements: fileElements, + error: onError, + notify: true + }, + + "File.chown" : { + type: "multiple", + call: OpenNebula.Image.chown, + callback: function (req) { + Sunstone.runAction("File.show",req.request.data[0][0]); + Sunstone.runAction('Image.showinfo',request.request.data[0]); + }, + elements: fileElements, + error: onError, + notify: true + }, + + "File.chgrp" : { + type: "multiple", + call: OpenNebula.Image.chgrp, + callback: function (req) { + Sunstone.runAction("File.show",req.request.data[0][0]); + Sunstone.runAction('Image.showinfo',request.request.data[0]); + }, + elements: fileElements, + error: onError, + notify: true + }, + + "File.chmod" : { + type: "single", + call: OpenNebula.Image.chmod, +// callback + error: onError, + notify: true + }, + + "File.chtype" : { + type: "single", + call: OpenNebula.Image.chtype, + callback: function (req) { + Sunstone.runAction("File.show",req.request.data[0][0]); + Sunstone.runAction("File.list"); + }, + elements: fileElements, + error: onError, + notify: true + }, + "File.clone_dialog" : { + type: "custom", + call: popUpFileCloneDialog + }, + "File.clone" : { + type: "single", + call: OpenNebula.Image.clone, + error: onError, + notify: true + }, + "File.help" : { + type: "custom", + call: function() { + hideDialog(); + $('div#files_tab div.legend_div').slideToggle(); + } + }, + "File.rename" : { + type: "single", + call: OpenNebula.Image.rename, + callback: function(request) { + notifyMessage("File renamed correctly"); + Sunstone.runAction('Image.showinfo',request.request.data[0]); + Sunstone.runAction('Image.list'); + }, + error: onError, + notify: true + }, +}; + + +var file_buttons = { + "File.refresh" : { + type: "action", + layout: "refresh", + alwaysActive: true + }, + "File.create_dialog" : { + type: "create_dialog", + layout: "create" + }, + "File.chown" : { + type: "confirm_with_select", + text: tr("Change owner"), + layout: "user_select", + select: users_sel, + tip: tr("Select the new owner")+":", + condition: mustBeAdmin + }, + "File.chgrp" : { + type: "confirm_with_select", + text: tr("Change group"), + layout: "user_select", + select: groups_sel, + tip: tr("Select the new group")+":", + condition: mustBeAdmin + }, + "File.enable" : { + type: "action", + layout: "more_select", + text: tr("Enable") + }, + "File.disable" : { + type: "action", + layout: "more_select", + text: tr("Disable") + }, + "File.clone_dialog" : { + type: "action", + layout: "main", + text: tr("Clone") + }, + "File.delete" : { + type: "confirm", + layout: "del", + text: tr("Delete") + }, + //"File.help" : { + // type: "action", + // text: '?', + // alwaysActive: true + //} +} + +var file_info_panel = { + "file_info_tab" : { + title: tr("Information"), + content: "" + } +} + +var files_tab = { + title: tr("Files & Kernels"), + content: files_tab_content, + buttons: file_buttons, + tabClass: 'subTab', + parentTab: 'vres_tab' +} + +Sunstone.addActions(file_actions); +Sunstone.addMainTab('files_tab',files_tab); +Sunstone.addInfoPanel('file_info_panel',file_info_panel); + + +function fileElements() { + return getSelectedNodes(dataTable_files); +} + +// Returns an array containing the values of the file_json and ready +// to be inserted in the dataTable +function fileElementArray(file_json){ + //Changing this? It may affect to the is_persistent() functions. + var file = file_json.IMAGE; + + // OS || CDROM || DATABLOCK + if (file.TYPE == "0" || file.TYPE == "1" || file.TYPE == "2") { + return false; + } + + + size_files = size_files + parseInt(file.SIZE); + + //add also persistent/non-persistent selects, type select. + return [ + '', + file.ID, + file.UNAME, + file.GNAME, + file.NAME, + file.DATASTORE, + file.SIZE, + OpenNebula.Helper.image_type(file.TYPE), + pretty_time(file.REGTIME), + parseInt(file.PERSISTENT) ? "yes" : "no", + OpenNebula.Helper.resource_state("image",file.STATE), + file.RUNNING_VMS, + file.TEMPLATE.TARGET ? file.TEMPLATE.TARGET : '--' + ]; +} + +// Callback to update an element in the dataTable +function updateFileElement(request, file_json){ + var id = file_json.IMAGE.ID; + var element = fileElementArray(file_json); + updateSingleElement(element,dataTable_files,'#file_'+id); +} + +// Callback to remove an element from the dataTable +function deleteFileElement(req){ + deleteElement(dataTable_files,'#file_'+req.request.data); +} + +// Callback to add an file element +function addFileElement(request, file_json){ + var element = fileElementArray(file_json); + addElement(element,dataTable_files); +} + +// Callback to refresh the list of files +function updateFilesView(request, files_list){ + var file_list_array = []; + + size_files = 0; + + $.each(files_list,function(){ + var file = fileElementArray(this); + if (file) + file_list_array.push(file); + }); + + updateView(file_list_array,dataTable_files); + updateVResDashboard("files",files_list); + + var size = humanize_size_from_mb(size_files) + + $("#total_files", $dashboard).text(files_list.length); + $("#size_files", $dashboard).text(size); + + var form = $("#file_form"); + + $("#total_files", form).text(files_list.length); + $("#size_files", form).text(size); +} + +// Callback to update the information panel tabs and pop it up +function updateFileInfo(request,img){ + var img_info = img.IMAGE; + var info_tab = { + title: tr("Information"), + content: + '
\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
'+tr("File")+' - '+img_info.NAME+'
'+tr("ID")+''+img_info.ID+'
'+tr("Name")+''+img_info.NAME+'
\ + \ +
\ +
'+tr("Datastore")+''+img_info.DATASTORE+'
'+tr("Type")+''+OpenNebula.Helper.image_type(img_info.TYPE)+'
\ + \ +
\ +
'+tr("Register time")+''+pretty_time(img_info.REGTIME)+'
'+tr("Persistent")+''+(parseInt(img_info.PERSISTENT) ? tr("yes") : tr("no"))+'
\ + \ +
\ +
'+tr("Filesystem type")+''+(typeof img_info.FSTYPE === "string" ? img_info.FSTYPE : "--")+'
'+tr("Size (MB)")+''+img_info.SIZE+'
'+tr("State")+''+OpenNebula.Helper.resource_state("file",img_info.STATE)+'
'+tr("Running VMS")+''+img_info.RUNNING_VMS+'
\ +
\ +
' + + insert_permissions_table("File", + img_info.ID, + img_info.UNAME, + img_info.GNAME, + img_info.UID, + img_info.GID) + + insert_extended_template_table(img_info.TEMPLATE, + "File", + img_info.ID, + "Configuration & Tags") + + '
\ +
' + } + + $("#div_edit_rename_link").die(); + $(".input_edit_value_rename").die(); + $("#div_edit_chg_type_link").die(); + $("#chg_type_select").die(); + $("#div_edit_persistency").die(); + $("#persistency_select").die(); + + + // Listener for edit link for rename + $("#div_edit_rename_link").live("click", function() { + var value_str = $(".value_td_rename").text(); + $(".value_td_rename").html(''); + }); + + $(".input_edit_value_rename").live("change", function() { + var value_str = $(".input_edit_value_rename").val(); + if(value_str!="") + { + // Let OpenNebula know + var name_template = {"name": value_str}; + Sunstone.runAction("File.rename",img_info.ID,name_template); + } + }); + + // Listener for edit link for type change + $("#div_edit_chg_type_link").live("click", function() { + var value_str = $(".value_td_type").text(); + $(".value_td_type").html( + ''); + $('option[value="'+value_str+'"]').replaceWith(''); + }); + + $("#chg_type_select").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); + }); + + // Listener for edit link for persistency change + $("#div_edit_persistency").live("click", function() { + var value_str = $(".value_td_persistency").text(); + $(".value_td_persistency").html( + ''); + $('option[value="'+value_str+'"]').replaceWith(''); + }); + + $("#persistency_select").live("change", function() { + var new_value=$("option:selected", this).text(); + + if (new_value=="yes") + Sunstone.runAction("File.persistent",[img_info.ID]); + else + Sunstone.runAction("File.nonpersistent",[img_info.ID]); + + }); + + Sunstone.updateInfoPanelTab("file_info_panel","file_info_tab",info_tab); + Sunstone.popUpInfoPanel("file_info_panel"); + + setPermissionsTable(img_info,''); + +} + +function enable_all_datastores() +{ + + $('select#disk_type').children('option').each(function() { + $(this).removeAttr('disabled'); + }); +} + +// Prepare the file creation dialog +function setupCreateFileDialog(){ + 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 + + //Prepare jquery dialog + //dialog.dialog({ + // autoOpen: false, + // modal:true, + // width: 520, + // height: height + //}); + dialog.addClass("reveal-modal large"); + + $('.advanced',dialog).hide(); + + $('#advanced_file_create',dialog).click(function(){ + $('.advanced',dialog).toggle(); + 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_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,#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,#file-uploader',context).closest('.row').hide(); + $('#img_path',context).closest('.row').show(); + break; + case "datablock": + $('#img_path,#file-uploader',context).closest('.row').hide(); + $('#img_fstype,#img_size',context).closest('.row').show(); + break; + case "upload": + $('#img_path,#img_fstype,#img_size',context).closest('.row').hide(); + $('#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; + } + ); + + $('#upload-progress',dialog).css({ + border: "1px solid #AAAAAA", + position: "relative", +// bottom: "29px", + width: "258px", +// left: "133px", + height: "15px", + display: "inline-block" + }); + $('#upload-progress div',dialog).css("border","1px solid #AAAAAA"); + + var img_obj; + + // Upload is handled by FileUploader vendor plugin + var uploader = new qq.FileUploaderBasic({ + button: $('#file-uploader',$create_file_dialog)[0], + action: 'upload', + multiple: false, + params: {}, + sizeLimit: 0, + showMessage: function(message){ + //notifyMessage(message); + }, + onSubmit: function(id, fileName){ + //set url params + //since the body is the upload, we need the pass + //the file 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 = $('
'+ + // '
'+ + // '
').dialog({ + // draggable:true, + // modal:false, + // resizable:false, + // buttons:{}, + // width: 460, + // minHeight: 50, + // position: [pos_left, pos_top] + // }); + + var pb_dialog = $('
'+ + '
'+ + '
').addClass("reveal-modal"); + + //$('#upload-progress',pb_dialog).progressbar({value:0}); + }, + 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)); + }, + onComplete: function(id, fileName, responseJSON){ + //Inform complete upload, destroy upload dialog, refresh img list + notifyMessage("File uploaded correctly"); + //$('div#pb_dialog').dialog('destroy'); + $('div#pb_dialog').trigger("reveal:close") + Sunstone.runAction("File.list"); + return false; + }, + onCancel: function(id, fileName){ + } + }); + + var file_input = false; + uploader._button._options.onChange = function(input) { + 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){ + notifyError(tr("Please select a datastore for this file")); + return false; + }; + + var img_json = {}; + + var name = $('#img_name',dialog).val(); + img_json["NAME"] = name; + + var desc = $('#img_desc',dialog).val(); + if (desc.length){ + img_json["DESCRIPTION"] = desc; + } + + var type = $('#img_type',dialog).val(); + img_json["TYPE"]= type; + + + switch ($('#src_path_select input:checked',dialog).val()){ + case "path": + path = $('#img_path',dialog).val(); + if (path) img_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, + "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); + }; + + $create_file_dialog.trigger("reveal:close") + return false; + }); + +} + +function popUpCreateFileDialog(){ + $('#file-uploader input',$create_file_dialog).removeAttr("style"); + $('#file-uploader input',$create_file_dialog).attr('style','margin:0;width:256px!important'); + + var datastores_str = datastores_sel(); + // Get rid of default datastore (51 characters in string) + datastores_str = datastores_str.substring(51,datastores_str.length); + + $('#file_datastore',$create_file_dialog).html(datastores_str); + $('#file_datastore_raw',$create_file_dialog).html(datastores_str); + + $create_file_dialog.reveal(); + + $('select#file_datastore').children('option').each(function() { + if ($(this).val() != "2") + { + $(this).attr('disabled', 'disabled'); + } + }); +} + +// Set the autorefresh interval for the datatable +function setFileAutorefresh() { + setInterval(function(){ + var checked = $('input.check_item:checked',dataTable_files); + var filter = $("#file_search").attr('value'); + if (!checked.length && !filter.length){ + Sunstone.runAction("File.autorefresh"); + } + },INTERVAL+someTime()); +}; + +function is_persistent_file(id){ + var data = getElementData(id,"#file",dataTable_files)[8]; + return $(data).is(':checked'); +}; + +function setupFileCloneDialog(){ + //Append to DOM + dialogs_context.append('
'); + var dialog = $('#file_clone_dialog',dialogs_context); + + //Put HTML in place + + var html = '
\ +

\ + '+tr("Clone File")+'\ +

\ +
\ +
\ +
\ +
\ +
'+tr("Several file are selected, please choose prefix to name the new copies")+':
\ +
\ +
\ +
\ +
\ + \ + \ +
\ +
\ + \ +
\ +
\ +
\ +
\ + \ + \ +
\ +×\ +
\ +'; + + dialog.html(html); + + //Convert into jQuery + //dialog.dialog({ + // autoOpen:false, + // width:375, + // modal:true, + // resizable:false + //}); + dialog.addClass("reveal-modal"); + + //$('button',dialog).button(); + + $('form',dialog).submit(function(){ + var name = $('input', this).val(); + var sel_elems = fileElements(); + if (!name || !sel_elems.length) + notifyError('A name or prefix is needed!'); + if (sel_elems.length > 1){ + for (var i=0; i< sel_elems.length; i++) + //If we are cloning several files we + //use the name as prefix + Sunstone.runAction('Image.clone', + sel_elems[i], + name+getFileName(sel_elems[i])); + } else { + Sunstone.runAction('Image.clone',sel_elems[0],name) + }; + dialog.trigger("reveal:close") + setTimeout(function(){ + Sunstone.runAction('Image.refresh'); + }, 1500); + return false; + }); +} + +function popUpFileCloneDialog(){ + var dialog = $('#file_clone_dialog'); + var sel_elems = fileElements(); + //show different text depending on how many elements are selected + if (sel_elems.length > 1){ + $('.clone_one',dialog).hide(); + $('.clone_several',dialog).show(); + $('input',dialog).val('Copy of '); + } + else { + $('.clone_one',dialog).show(); + $('.clone_several',dialog).hide(); + $('input',dialog).val('Copy of '+getFileName(sel_elems[0])); + }; + + $(dialog).reveal(); +} + +//The DOM is ready at this point +$(document).ready(function(){ + + dataTable_files = $("#datatable_files",main_tabs_context).dataTable({ + "sDom" : "<'H'>t<'row'<'six columns'i><'six columns'p>>", + "oColVis": { + "aiExclude": [ 0 ] + }, + "aoColumnDefs": [ + { "bSortable": false, "aTargets": ["check"] }, + { "sWidth": "60px", "aTargets": [0,2,3,9,10] }, + { "sWidth": "35px", "aTargets": [1,6,11,12] }, + { "sWidth": "100px", "aTargets": [5,7] }, + { "sWidth": "150px", "aTargets": [8] }, + { "bVisible": false, "aTargets": [6,8,9,11,12]} + ], + "oLanguage": (datatable_lang != "") ? + { + sUrl: "locale/"+lang+"/"+datatable_lang + } : "" + }); + + $('#file_search').keyup(function(){ + dataTable_files.fnFilter( $(this).val() ); + }) + + //addElement([ + // spinner, + // '','','','','','','','','','','',''],dataTable_files); + Sunstone.runAction("File.list"); + + setupCreateFileDialog(); + setupTips($create_file_dialog); + setupFileCloneDialog(); + setFileAutorefresh(); + + initCheckAllBoxes(dataTable_files); + tableCheckboxesListener(dataTable_files); + infoListener(dataTable_files,'Image.showinfo'); + + $('div#files_tab div.legend_div').hide(); +}); diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js index d0fde0a922..f368b52e17 100644 --- a/src/sunstone/public/js/plugins/images-tab.js +++ b/src/sunstone/public/js/plugins/images-tab.js @@ -579,6 +579,11 @@ function imageElementArray(image_json){ //Changing this? It may affect to the is_persistent() functions. var image = image_json.IMAGE; + // KERNEL || RAMDISK || CONTEXT + if (image.TYPE == "3" || image.TYPE == "4" || image.TYPE == "5") { + return false; + } + size_images = size_images + parseInt(image.SIZE); //add also persistent/non-persistent selects, type select. @@ -624,7 +629,9 @@ function updateImagesView(request, images_list){ size_images = 0; $.each(images_list,function(){ - image_list_array.push(imageElementArray(this)); + var image = imageElementArray(this); + if (image) + image_list_array.push(image); }); updateView(image_list_array,dataTable_images); diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index a9e9836043..ad439921e6 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -1043,11 +1043,12 @@ function setup_disk_tab_content(disk_section, str_disk_tab_id, str_datatable_id) var image_list_array = []; $.each(images_list,function(){ - image_list_array.push(imageElementArray(this)); + var image = imageElementArray(this); + if (image) + image_list_array.push(image); }); updateView(image_list_array, dataTable_template_images); - dataTable_template_images.fnFilter("OS|DATABLOCK|CDROM", 7, true) }, error: onError }); @@ -2029,7 +2030,9 @@ function setupCreateTemplateDialog(){ var image_list_array = []; $.each(images_list,function(){ - image_list_array.push(imageElementArray(this)); + var file = fileElementArray(this); + if (file) + image_list_array.push(file); }); updateView(image_list_array, dataTable_template_kernel); @@ -2097,7 +2100,9 @@ function setupCreateTemplateDialog(){ var image_list_array = []; $.each(images_list,function(){ - image_list_array.push(imageElementArray(this)); + var file = fileElementArray(this); + if (file) + image_list_array.push(file); }); updateView(image_list_array, datTable_template_initrd); @@ -2491,7 +2496,9 @@ function setupCreateTemplateDialog(){ success: function (request, images_list){ var image_list_array = []; $.each(images_list,function(){ - image_list_array.push(imageElementArray(this)); + var image = fileElementArray(this); + if (image) + image_list_array.push(image); }); updateView(image_list_array, datTable_template_context);