From c1a1cc58130df19f17ee94a054a95ee4c84a08ef Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 3 Jul 2012 18:46:10 +0200 Subject: [PATCH] Bug #1314: Small sunstone fixes * Remove hosts view for non-admin users. * Update users main dashboard with user quota information. * Enable users and group plugin for normal users, disabling the administrator operations. * Fix non-working quota edit buttons in Chrome/Safari. Minor dialog improvements. * Add group extended information tab when clicking on a group. * Small fixes regarding disk hotplugging and added labels. * Fix net units in VM monitoring * Fix UNAME not being set correctly when adding images or vnets to templates * Format marketplace images size and add url link to website. * Small corrections here and there.. (cherry picked from commit 2b3019a2e9aa7cfd033c20c67f85bf196c2127c9) --- src/sunstone/etc/sunstone-plugins.yaml | 9 +- src/sunstone/public/css/application.css | 8 ++ src/sunstone/public/js/layout.js | 2 +- .../public/js/plugins/clusters-tab.js | 7 +- src/sunstone/public/js/plugins/config-tab.js | 5 +- .../public/js/plugins/dashboard-tab.js | 2 + .../public/js/plugins/dashboard-users-tab.js | 134 ++++++++++++------ src/sunstone/public/js/plugins/groups-tab.js | 113 +++++++++++++-- .../public/js/plugins/marketplace-tab.js | 6 +- .../public/js/plugins/templates-tab.js | 8 +- src/sunstone/public/js/plugins/users-tab.js | 45 ++++-- src/sunstone/public/js/plugins/vms-tab.js | 47 +++--- src/sunstone/public/js/sunstone-util.js | 76 +++++++--- src/sunstone/sunstone-server.rb | 6 +- 14 files changed, 345 insertions(+), 123 deletions(-) diff --git a/src/sunstone/etc/sunstone-plugins.yaml b/src/sunstone/etc/sunstone-plugins.yaml index ddf4924f6a..489f8c4b01 100644 --- a/src/sunstone/etc/sunstone-plugins.yaml +++ b/src/sunstone/etc/sunstone-plugins.yaml @@ -19,15 +19,13 @@ :group: oneadmin: true - plugins/users-tab.js: - :ALL: false + :ALL: true :user: :group: - oneadmin: true - plugins/groups-tab.js: - :ALL: false + :ALL: true :user: :group: - oneadmin: true - plugins/acls-tab.js: :ALL: false :user: @@ -59,9 +57,10 @@ :group: oneadmin: true - plugins/hosts-tab.js: - :ALL: true + :ALL: false :user: :group: + oneadmin: true - plugins/datastores-tab.js: :ALL: true :user: diff --git a/src/sunstone/public/css/application.css b/src/sunstone/public/css/application.css index 914980f256..12d2eed4ac 100644 --- a/src/sunstone/public/css/application.css +++ b/src/sunstone/public/css/application.css @@ -684,4 +684,12 @@ ul.action_list li a:hover{ div.current_quotas ul{ list-style: none; +} + +.padding1 { + padding-left: 30px!important; +} + +.padding2 { + padding-left: 55px!important; } \ No newline at end of file diff --git a/src/sunstone/public/js/layout.js b/src/sunstone/public/js/layout.js index c655a50b10..7ebae4c5ad 100644 --- a/src/sunstone/public/js/layout.js +++ b/src/sunstone/public/js/layout.js @@ -128,7 +128,7 @@ $(document).ready(function () { applyDefaultStyles: false , center__paneSelector: ".outer-center" , west__paneSelector: ".outer-west" - , west__size: 181 + , west__size: 200 , north__size: 26 , south__size: 26 , spacing_open: 0 // ALL panes diff --git a/src/sunstone/public/js/plugins/clusters-tab.js b/src/sunstone/public/js/plugins/clusters-tab.js index 4806e58132..f1424522c4 100644 --- a/src/sunstone/public/js/plugins/clusters-tab.js +++ b/src/sunstone/public/js/plugins/clusters-tab.js @@ -61,7 +61,10 @@ var cluster_actions = { "Cluster.create" : { type: "create", call : OpenNebula.Cluster.create, - callback : addClusterElement, + callback : function(){ + //addClusterElement, + Sunstone.runAction('Cluster.list'); + }, error : onError, notify: true }, @@ -911,7 +914,7 @@ function setupCreateClusterDialog(){ } }; - //Create the OpenNebula.Host. + //Create the OpenNebula.Cluster. //If it is successfull we refresh the list. Sunstone.runAction("Cluster.create",cluster_json); $create_cluster_dialog.dialog('close'); diff --git a/src/sunstone/public/js/plugins/config-tab.js b/src/sunstone/public/js/plugins/config-tab.js index 32b14d16f8..2d4cdd7321 100644 --- a/src/sunstone/public/js/plugins/config-tab.js +++ b/src/sunstone/public/js/plugins/config-tab.js @@ -14,6 +14,7 @@ /* limitations under the License. */ /* -------------------------------------------------------------------------- */ +var config_response; var config_tab_content = '
\ \ @@ -81,10 +82,10 @@ Sunstone.addMainTab('config_tab',config_tab); // Callback when configuration list is received function updateConfig(request,response){ - var config = response['user_config']; + config_response = response //Set wss checkbox to correct value - if (config["wss"] == "yes"){ + if (config_response['user_config']["wss"] == "yes"){ $('table#config_table input#wss_checkbox').attr('checked','checked'); }; }; diff --git a/src/sunstone/public/js/plugins/dashboard-tab.js b/src/sunstone/public/js/plugins/dashboard-tab.js index 0c83095251..5993d5b06a 100644 --- a/src/sunstone/public/js/plugins/dashboard-tab.js +++ b/src/sunstone/public/js/plugins/dashboard-tab.js @@ -190,6 +190,8 @@ var $dashboard; // All monitoring calls and config are called from the Sunstone plugins. +function dashboardQuotasHTML(){} + $(document).ready(function(){ $dashboard = $('#dashboard_tab', main_tabs_context); }); \ No newline at end of file diff --git a/src/sunstone/public/js/plugins/dashboard-users-tab.js b/src/sunstone/public/js/plugins/dashboard-users-tab.js index d3ad15a86f..c92f673d1a 100644 --- a/src/sunstone/public/js/plugins/dashboard-users-tab.js +++ b/src/sunstone/public/js/plugins/dashboard-users-tab.js @@ -22,46 +22,10 @@ var dashboard_tab_content = \ '; + row += ''; + row += ''; + row += ''; + row += ''; + row += ''; + break; + case "DATASTORE": + row += ''; + + row += ''; + row += ''; + + row += ''; + row += ''; + break; + case "IMAGE": + row += ''; + + row += ''; + row += ''; + break; + case "NETWORK": + row += ''; + + row += ''; + row += ''; + break; + } + return row +} + +function dashboardQuotasHTML(user){ + var html = '\ + \ + \ + \ + \ + \ + '; + + var results = parseQuotas(user, dashboardQuotaRow); + + html += '\ + ' + + html += results.VM; + + html += '\ + \ + '; + + html += '\ + ' + + html += results.DATASTORE; + + html += '\ + \ + '; + + html += '\ + ' + + html += results.IMAGE; + + html += '\ + \ + '; + + html += '\ + ' + + html += results.NETWORK; + + html += '\ + \ + '; + + $('#dashboard_user_info', $dashboard).html(html); +} $(document).ready(function(){ - $dashboard = $('#dashboard_tab', main_tabs_context); + $dashboard = $('#dashboard_tab', main_tabs_context); }); \ No newline at end of file diff --git a/src/sunstone/public/js/plugins/groups-tab.js b/src/sunstone/public/js/plugins/groups-tab.js index 2daae71f36..d156644c36 100644 --- a/src/sunstone/public/js/plugins/groups-tab.js +++ b/src/sunstone/public/js/plugins/groups-tab.js @@ -32,8 +32,8 @@ var groups_tab_content = '\ \ \ \ - \ - \ + \ + \ \ \ \ @@ -142,10 +142,19 @@ var group_actions = { error: onError, }, - // "Group.showinfo" : { - // type: "custom", - // call: updateGroupInfo - // }, + "Group.show" : { + type: "single", + call: OpenNebula.Group.show, + callback: updateGroupElement, + error: onError + }, + + "Group.showinfo" : { + type: "single", + call: OpenNebula.Group.show, + callback: updateGroupInfo, + error: onError + }, "Group.autorefresh" : { type: "custom", @@ -185,7 +194,7 @@ var group_actions = { type: "single", call: OpenNebula.Group.show, callback: function (request,response) { - var parsed = parseQuotas(response.GROUP); + var parsed = parseQuotas(response.GROUP,quotaListItem); $('.current_quotas table tbody',$group_quotas_dialog).append(parsed.VM); $('.current_quotas table tbody',$group_quotas_dialog).append(parsed.DATASTORE); $('.current_quotas table tbody',$group_quotas_dialog).append(parsed.IMAGE); @@ -225,7 +234,8 @@ var group_buttons = { }, "Group.create_dialog" : { type: "create_dialog", - text: tr("+ New Group") + text: tr("+ New Group"), + condition: mustBeAdmin }, // "Group.chown" : { // type: "confirm_with_select", @@ -236,11 +246,13 @@ var group_buttons = { // }, "Group.quotas_dialog" : { type : "action", - text : tr("Update quotas") + text : tr("Update quotas"), + condition: mustBeAdmin, }, "Group.delete" : { type: "confirm", - text: tr("Delete") + text: tr("Delete"), + condition: mustBeAdmin }, "Group.help" : { type: "action", @@ -249,17 +261,35 @@ var group_buttons = { } }; +var group_info_panel = { + "group_info_tab" : { + title: tr("Group information"), + content:"" + }, +}; + var groups_tab = { title: tr("Groups"), content: groups_tab_content, buttons: group_buttons, tabClass: 'subTab', - parentTab: 'system_tab' + parentTab: 'system_tab', + condition: mustBeAdmin }; +var groups_tab_non_admin = { + title: tr("Group info"), + content: groups_tab_content, + buttons: group_buttons, + tabClass: 'subTab', + parentTab: 'dashboard_tab', + condition: mustNotBeAdmin +} + SunstoneMonitoringConfig['GROUP'] = { plot: function(monitoring){ + if (!mustBeAdmin()) return; $('#totalGroups', $dashboard).text(monitoring['totalGroups']) }, monitor: { @@ -271,6 +301,8 @@ SunstoneMonitoringConfig['GROUP'] = { Sunstone.addActions(group_actions); Sunstone.addMainTab('groups_tab',groups_tab); +Sunstone.addMainTab('groups_tab_non_admin',groups_tab_non_admin); +Sunstone.addInfoPanel("group_info_panel",group_info_panel); function groupElements(){ return getSelectedNodes(dataTable_groups); @@ -350,9 +382,63 @@ function updateGroupsView(request, group_list){ updateView(group_list_array,dataTable_groups); updateGroupSelect(group_list); SunstoneMonitoring.monitor('GROUP', group_list) - updateSystemDashboard("groups",group_list); + if (mustBeAdmin()) + updateSystemDashboard("groups",group_list); } +function updateGroupInfo(request,group){ + var info = group.GROUP; + + var info_tab_html = '\ +
\
\ -

' + tr("Hosts") + '

\ +

' + tr("User information") + '

\
\ - \ +
\ \ - \ - \ - \ - \ - \ - \ - \ -\ - \ - \ - \ - \ - \ - \ - \ -\ - \ - \ - \ - \ - \ - \ - \ -\ - \ - \ - \ - \ - \ - \ - \ \
' + tr("Total Hosts") + '' + tr("State") + '
\ -
' + tr("Global CPU Usage") + '
' + tr("Used vs. Max CPU") + '
\ -
\ -
' + tr("Used vs. Max Memory") + '
\ -
\ -
\ \ @@ -128,8 +92,98 @@ Sunstone.addMainTab('dashboard_tab',dashboard_tab); var $dashboard; -// Monitoring calls and config in Sunstone plugins + +function dashboardQuotaRow(quota_json){ + var row = ''; + + switch (quota_json.TYPE){ + case "VM": + row += '
'+tr("VMS")+''+quota_json.VMS_USED+' / '+quota_json.VMS+'
'+tr("Memory")+''+quota_json.MEMORY_USED+' / '+quota_json.MEMORY+'
'+tr("CPU")+''+quota_json.CPU_USED+' / '+quota_json.CPU+'
'+tr("Datastore")+' id '+quota_json.ID+':
'+tr("Size")+''+quota_json.SIZE_USED+' / '+quota_json.SIZE+'
'+tr("Images")+''+quota_json.IMAGES_USED+' / '+quota_json.IMAGES+'
'+tr("Image")+' id '+quota_json.ID+':
'+tr("RVMs")+''+quota_json.RVMS_USED+' / '+quota_json.RVMS+'
'+tr("Network")+' id '+quota_json.ID+':
'+tr("Leases")+''+quota_json.RVMS_USED+' / '+quota_json.RVMS+'
' + tr("Resource quotas") + '' + tr("Used / Allowed") + '
'+tr("VM quota")+':'+ + (results.VM.length ? "" : tr("None"))+'
'+tr("Datastore quotas")+':'+ + (results.DATASTORE.length ? "" : tr("None"))+'
'+tr("Image quotas")+':'+ + (results.IMAGE.length ? "" : tr("None"))+'
'+tr("Network quotas")+':'+ + (results.NETWORK.length ? "" : tr("None"))+'
'+tr("Name")+''+tr("Users")+''+tr("VMs")+''+tr("Memory used")+''+tr("CPU used")+''+tr("Used memory")+''+tr("Used CPU")+'
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
' + tr("Group information") + ' - '+info.NAME+'
' + tr("ID") + ''+info.ID+'
\ + \ + \ + \ + \ + \ +
' + tr("Quota information") +'
'; + + if (!$.isEmptyObject(info.VM_QUOTA)) + info_tab_html += '\ + '+prettyPrintJSON(info.VM_QUOTA)+'\ +
' + + if (!$.isEmptyObject(info.DATASTORE_QUOTA)) + info_tab_html += '\ + '+prettyPrintJSON(info.DATASTORE_QUOTA)+'\ +
' + + if (!$.isEmptyObject(info.IMAGE_QUOTA)) + info_tab_html += '\ + '+prettyPrintJSON(info.IMAGE_QUOTA)+'\ +
'; + + if (!$.isEmptyObject(info.NETWORK_QUOTA)) + info_tab_html += '\ + '+prettyPrintJSON(info.NETWORK_QUOTA)+'\ +
'; + + var info_tab = { + title : tr("Group information"), + content : info_tab_html + }; + + Sunstone.updateInfoPanelTab("group_info_panel","group_info_tab",info_tab); + Sunstone.popUpInfoPanel("group_info_panel"); +} + + + //Prepares the dialog to create function setupCreateGroupDialog(){ dialogs_context.append('
'); @@ -437,7 +523,8 @@ $(document).ready(function(){ initCheckAllBoxes(dataTable_groups); tableCheckboxesListener(dataTable_groups); - infoListener(dataTable_groups); + infoListener(dataTable_groups, 'Group.showinfo'); $('div#groups_tab div.legend_div').hide(); + $('div#groups_tab_non_admin div.legend_div').hide(); }) diff --git a/src/sunstone/public/js/plugins/marketplace-tab.js b/src/sunstone/public/js/plugins/marketplace-tab.js index 5223e9837b..3ffb249040 100644 --- a/src/sunstone/public/js/plugins/marketplace-tab.js +++ b/src/sunstone/public/js/plugins/marketplace-tab.js @@ -152,6 +152,10 @@ function updateMarketInfo(request,app){ ' + tr("ID") + '\ '+app['_id']["$oid"]+'\ \ + \ + ' + tr("URL") + '\ + '+config_response.system_config.marketplace_url+'/'+app['_id']["$oid"]+'\ + \ \ ' + tr("Publisher") + '\ '+app['publisher']+'\ @@ -170,7 +174,7 @@ function updateMarketInfo(request,app){ \ \ ' + tr("Size") + '\ - '+app['files'][0]['size']+'\ + '+humanize_size(app['files'][0]['size'],true)+'\ \ \ ' + tr("Hypervisor") + '\ diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index 0b879c0cf3..295ffe0762 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -1391,9 +1391,10 @@ function setupCreateTemplateDialog(){ //Auto-set IMAGE_UNAME hidden field value $('#IMAGE', section_disks).change(function(){ - var uname = getValue($(this).val(),4,2,dataTable_images); + var option = $('option:selected',this); + var uname = getValue(option.attr('elem_id'),1,2,dataTable_images); $('input#IMAGE_UNAME',section_disks).val(uname); - var target = getValue($(this).val(),4,12,dataTable_images); + var target = getValue(option.attr('elem_id'),1,12,dataTable_images); if (target && target != "--") $('input#TARGET',section_disks).val(target); else @@ -1555,7 +1556,8 @@ function setupCreateTemplateDialog(){ //Auto-set IMAGE_UNAME hidden field value $('#NETWORK', section_networks).change(function(){ - var uname = getValue($(this).val(),4,2,dataTable_vNetworks); + var option = $('option:selected',this); + var uname = getValue(option.attr('elem_id'),1,2,dataTable_vNetworks); $('input#NETWORK_UNAME',section_networks).val(uname); }); diff --git a/src/sunstone/public/js/plugins/users-tab.js b/src/sunstone/public/js/plugins/users-tab.js index d894c98f48..7288a1628f 100644 --- a/src/sunstone/public/js/plugins/users-tab.js +++ b/src/sunstone/public/js/plugins/users-tab.js @@ -35,8 +35,8 @@ var users_tab_content = '\ '+tr("Group")+'\ '+tr("Authentication driver")+'\ '+tr("VMs")+'\ - '+tr("Memory used")+'\ - '+tr("CPU used")+'\ + '+tr("Used memory")+'\ + '+tr("Used CPU")+'\ '+tr("Group ID")+'\ \ \ @@ -323,7 +323,7 @@ var user_actions = { // when we receive quotas we parse them and create an // quota objects with html code (
  • ) that can be inserted // in the dialog - var parsed = parseQuotas(response.USER); + var parsed = parseQuotas(response.USER,quotaListItem); $('.current_quotas table tbody',$user_quotas_dialog).append(parsed.VM); $('.current_quotas table tbody',$user_quotas_dialog).append(parsed.DATASTORE); $('.current_quotas table tbody',$user_quotas_dialog).append(parsed.IMAGE); @@ -365,7 +365,8 @@ var user_buttons = { }, "User.create_dialog" : { type: "create_dialog", - text: tr("+ New") + text: tr("+ New"), + condition: mustBeAdmin }, "User.update_dialog" : { type: "action", @@ -378,13 +379,15 @@ var user_buttons = { }, "User.quotas_dialog" : { type : "action", - text : tr("Update quotas") + text : tr("Update quotas"), + condition: mustBeAdmin }, "User.chgrp" : { type: "confirm_with_select", text: tr("Change group"), select: groups_sel, - tip: tr("This will change the main group of the selected users. Select the new group")+":" + tip: tr("This will change the main group of the selected users. Select the new group")+":", + condition: mustBeAdmin }, "User.chauth" : { type: "confirm_with_select", @@ -396,7 +399,8 @@ var user_buttons = { \ ' }, - tip: tr("Please choose the new type of authentication for the selected users")+":" + tip: tr("Please choose the new type of authentication for the selected users")+":", + condition: mustBeAdmin }, // "User.addgroup" : { // type: "confirm_with_select", @@ -414,7 +418,8 @@ var user_buttons = { // }, "User.delete" : { type: "confirm", - text: tr("Delete") + text: tr("Delete"), + condition: mustBeAdmin }, "User.help" : { type: "action", @@ -440,12 +445,25 @@ var users_tab = { content: users_tab_content, buttons: user_buttons, tabClass: 'subTab', - parentTab: 'system_tab' + parentTab: 'system_tab', + condition: mustBeAdmin, }; +var users_tab_non_admin = { + title: tr("User info"), + content: users_tab_content, + buttons: user_buttons, + tabClass: 'subTab', + parentTab: 'dashboard_tab', + condition: mustNotBeAdmin, +} + SunstoneMonitoringConfig['USER'] = { plot: function(monitoring){ + //plot only when i am admin + if (!mustBeAdmin()) return; + //plot the number of total users $('#totalUsers', $dashboard).text(monitoring['totalUsers']) @@ -484,6 +502,7 @@ SunstoneMonitoringConfig['USER'] = { Sunstone.addActions(user_actions); Sunstone.addMainTab('users_tab',users_tab); +Sunstone.addMainTab('users_tab_non_admin',users_tab_non_admin); Sunstone.addInfoPanel("user_info_panel",user_info_panel); function userElements(){ @@ -553,11 +572,14 @@ function updateUsersView(request,users_list){ var user_list_array = []; $.each(users_list,function(){ + if (this.USER.ID == uid) + dashboardQuotasHTML(this.USER); user_list_array.push(userElementArray(this)); }); updateView(user_list_array,dataTable_users); SunstoneMonitoring.monitor('USER', users_list) - updateSystemDashboard("users",users_list); + if (mustBeAdmin()) + updateSystemDashboard("users",users_list); updateUserSelect(); }; @@ -573,7 +595,7 @@ function updateUserInfo(request,user){ \ \ \ - ' + tr("id") + '\ + ' + tr("ID") + '\ '+user_info.ID+'\ \ \ @@ -786,4 +808,5 @@ $(document).ready(function(){ infoListener(dataTable_users,'User.showinfo'); $('div#users_tab div.legend_div').hide(); + $('div#users_tab_non_admin div.legend_div').hide(); }); diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index 1e52062d3f..b187dd7da1 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -38,11 +38,13 @@ var vm_graphs = [ { title : tr("Network transmission"), monitor_resources : "NET_TX", humanize_figures : true, + convert_from_bytes : true, history_length : VM_HISTORY_LENGTH }, { title : tr("Network reception"), monitor_resources : "NET_RX", humanize_figures : true, + convert_from_bytes : true, history_length : VM_HISTORY_LENGTH } ]; @@ -668,10 +670,10 @@ SunstoneMonitoringConfig['VM'] = { var t = ((new Date().getTime()) - netUsage.time) / 1000 //in secs var bandwidth_up = monitoring['netUsageBar'][1].data[0][0] - netUsage.up bandwidth_up /= t - var bandwidth_up_str = humanize_size(bandwidth_up) + "b/s" //bytes /sec + var bandwidth_up_str = humanize_size(bandwidth_up,true) + "B/s" //bytes /sec var bandwidth_down = monitoring['netUsageBar'][0].data[0][0] - netUsage.down bandwidth_down /= t - var bandwidth_down_str = humanize_size(bandwidth_down) + "b/s" //bytes /sec + var bandwidth_down_str = humanize_size(bandwidth_down,true) + "B/s" //bytes /sec if (bandwidth_up >= 0) $('#bandwidth_up', $dashboard).text(bandwidth_up_str) @@ -742,14 +744,14 @@ SunstoneMonitoringConfig['VM'] = { xaxis: { min: 0, tickFormatter : function(val,axis) { - return humanize_size(val); + return humanize_size(val,true); }, }, legend: { noColumns: 3, container: '#netUsageBar_legend', labelFormatter: function(label, series){ - return label + " - " + humanize_size(series.data[0][0]) + return label + " - " + humanize_size(series.data[0][0],true) } } } @@ -1114,27 +1116,28 @@ function printDisks(vm_info){ html += '\ '+tr("No disks to show")+'\ '; - html += '
  • '; - return html; } + else { - for (var i = 0; i < disks.length; i++){ - var disk = disks[i]; - html += ''; - html += disk.DISK_ID + ' - ' + - (disk.IMAGE ? disk.IMAGE : "Volatile") + ''; - html += '\ + for (var i = 0; i < disks.length; i++){ + var disk = disks[i]; + html += ''; + html += disk.DISK_ID + ' - ' + + (disk.IMAGE ? disk.IMAGE : "Volatile") + ''; + html += '\ '+(vm_info.STATE == "3" ? '\ - \ + \ ' : '')+'\ - \ - ' -+'\ - '; + \ + \ + ' + +'\ +'; + } } html += '\ - '; + '; // If VM is not RUNNING, then we forget about the attach disk form. if (vm_info.STATE != "3"){ @@ -1163,7 +1166,7 @@ function printDisks(vm_info){ \ \ \ - \ + \ \ \ \ @@ -1186,6 +1189,7 @@ function printDisks(vm_info){ \ \ \ +\ \ \ \ @@ -1282,8 +1287,8 @@ function hotpluggingOps(){ disk_obj.FORMAT = $('input[name="FORMAT"]',this).val(); disk_obj.TYPE = $('select[name="TYPE"]',this).val(); disk_obj.DEV_PREFIX = $('input[name="DEV_PREFIX"]',this).val(); - disk_obj.READONLY = $('select[name="READONLY"]',this).val(); - disk_obj.SAVE = $('save[name="SAVE"]',this).val(); +// disk_obj.READONLY = $('select[name="READONLY"]',this).val(); +// disk_obj.SAVE = $('save[name="SAVE"]',this).val(); break; } diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js index a000052cf1..7c8b060f2d 100644 --- a/src/sunstone/public/js/sunstone-util.js +++ b/src/sunstone/public/js/sunstone-util.js @@ -76,11 +76,13 @@ function pretty_time_runtime(time){ } //returns a human readable size in Kilo, Mega, Giga or Tera bytes -function humanize_size(value) { +//if no from_bytes, assumes value comes in Ks +function humanize_size(value,from_bytes) { if (typeof(value) === "undefined") { value = 0; } - var binarySufix = ["K", "M", "G", "T" ]; + var binarySufix = from_bytes ? + ["", "K", "M", "G", "T" ] : ["K", "M", "G", "T" ]; var i=0; while (value > 1024 && i < 3){ value = value / 1024; @@ -561,12 +563,18 @@ function getSelectedNodes(dataTable){ return selected_nodes; } -//returns a HTML string with a select input code generated from -//a dataTable. Allows filtering elements. +//returns a HTML string with options for +//a select input code generated from a dataTable. +//Allows filtering elements specifing status columns +//and bad status (if the values of the columns match the bad status) +//then this elem is skipped. +//no_empty_obj allows to skip adding a Please Select option function makeSelectOptions(dataTable, - id_col,name_col, + option_value_col, + option_name_col, status_cols, - bad_status_values,no_empty_opt){ + bad_status_values, + no_empty_opt){ var nodes = dataTable.fnGetData(); var select = ""; if (!no_empty_opt) @@ -574,8 +582,12 @@ function makeSelectOptions(dataTable, var array; for (var j=0; j'+name+''; + select +=''; }; }; return select; @@ -607,9 +619,9 @@ function escapeDoubleQuotes(string){ //of plotting comes, we can put the data in the right place. function generateMonitoringDivs(graphs, id_prefix){ var str = ""; - //43% of the width of the screen minus + //40% of the width of the screen minus //181px (left menu size) - var width = ($(window).width()-181)*40/100; + var width = ($(window).width()-200)*39/100; var id_suffix=""; var label=""; var id=""; @@ -640,6 +652,7 @@ function plot_graph(data,context,id_prefix,info){ var labels = info.monitor_resources; var humanize = info.humanize_figures ? humanize_size : function(val){ return val }; + var convert_from_bytes = info.convert_from_bytes; var id_suffix = labels.replace(/,/g,'_'); id_suffix = id_suffix.replace(/\//g,'_'); var labels_array = labels.split(','); @@ -652,7 +665,8 @@ function plot_graph(data,context,id_prefix,info){ //labels array. for (var i=0; i'+ + var str = '
    ';
         switch(quota_json.TYPE){
         case "VM":
             str +=  'VMs: ' + quota_json.VMS + (quota_json.VMS_USED ? ' (' + quota_json.VMS_USED + '). ' : ". ") +
    -               'Memory: ' + quota_json.MEMORY + (quota_json.MEMORY_USED ? ' (' + quota_json.MEMORY_USED + '). ' : ". ") +
    +               'Memory: ' + quota_json.MEMORY + (quota_json.MEMORY_USED ? 'MB (' + quota_json.MEMORY_USED + 'MB). ' : ". ") +
                    'CPU: ' + quota_json.CPU +  (quota_json.CPU_USED ? ' (' + quota_json.CPU_USED + '). ' : ". ");
             break;
         case "DATASTORE":
    -        str +=  'ID: ' + getDatastoreName(quota_json.ID) + '. ' +
    -               'Size: ' + quota_json.SIZE +  (quota_json.SIZE_USED ? ' (' + quota_json.SIZE_USED + '). ' : ". ") +
    +        str +=  'ID/Name: ' + getDatastoreName(quota_json.ID) + '. ' +
    +               'Size: ' + quota_json.SIZE +  (quota_json.SIZE_USED ? 'MB (' + quota_json.SIZE_USED + 'MB). ' : ". ") +
                    'Images: ' + quota_json.IMAGES +  (quota_json.IMAGES_USED ? ' (' + quota_json.IMAGES_USED + '). ' : ".");
             break;
         case "IMAGE":
    -        str +=  'ID: ' + getImageName(quota_json.ID) + '. ' +
    +        str +=  'ID/Name: ' + getImageName(quota_json.ID) + '. ' +
                    'RVMs: ' + quota_json.RVMS +  (quota_json.RVMS_USED ? ' (' + quota_json.RVMS_USED + '). ' : ". ");
             break;
         case "NETWORK":
    -        str +=  'ID: ' + getVNetName(quota_json.ID) + '. ' +
    +        str +=  'ID/Name: ' + getVNetName(quota_json.ID) + '. ' +
                    'Leases: ' + quota_json.LEASES +  (quota_json.LEASES_USED ? ' (' + quota_json.LEASES_USED + '). ': ". ");
             break;
         }
    -    str += '
    '; + str += ''; return str; } \ No newline at end of file diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index e55cef7a9c..845d028382 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -255,7 +255,11 @@ get '/config' do uconf = { :user_config => { :lang => session[:lang], - :wss => session[:wss] + :wss => session[:wss], + :marketplace_url => settings.config[:marketplace_url] + }, + :system_config => { + :marketplace_url => settings.config[:marketplace_url] } }