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

feature #1678: Add datastore capacity bars in host extended info

This commit is contained in:
Daniel Molina 2013-10-23 17:18:38 +02:00
parent d13624bf5a
commit 1f5e70031b
2 changed files with 63 additions and 20 deletions

View File

@ -610,6 +610,25 @@ Sunstone.addMainTab('datastores-tab',datastores_tab);
Sunstone.addInfoPanel('datastore_info_panel',datastore_info_panel);
function generate_datastore_capacity_bar(ds, ds_type) {
var total = parseInt(ds.TOTAL_MB);
var used = total - parseInt(ds.FREE_MB);
if (total > 0) {
var ratio = Math.round((used / total) * 100);
info_str = humanize_size_from_mb(used) + ' / ' + humanize_size_from_mb(total) + ' (' + ratio + '%)';
} else {
if(ds_type == 1) {
info_str = '- / -';
} else {
info_str = humanize_size(used) + ' / -';
}
}
return quotaBarHtml(used, total, info_str);
}
function datastoreElements() {
return getSelectedNodes(dataTable_datastores);
}
@ -617,29 +636,14 @@ function datastoreElements() {
function datastoreElementArray(element_json){
var element = element_json.DATASTORE;
var type = "IMAGE_DS";
var ds_type_str = "IMAGE_DS";
if (typeof element.TEMPLATE.TYPE != "undefined")
{
type = element.TEMPLATE.TYPE;
ds_type_str = element.TEMPLATE.TYPE;
}
var total = parseInt(element.TOTAL_MB);
var used = total - parseInt(element.FREE_MB);
if (total > 0) {
var ratio = Math.round((used / total) * 100);
info_str = humanize_size_from_mb(used) + ' / ' + humanize_size_from_mb(total) + ' (' + ratio + '%)';
} else {
if(element.TYPE == 1) {
info_str = '- / -';
} else {
info_str = humanize_size(used) + ' / -';
}
}
var pb_capacity = quotaBarHtml(used, total, info_str);
var pb_capacity = generate_datastore_capacity_bar(element, element.TYPE);
return [
'<input class="check_item" type="checkbox" id="datastore_'+
@ -654,7 +658,7 @@ function datastoreElementArray(element_json){
element.BASE_PATH,
element.TM_MAD,
element.DS_MAD,
type.toLowerCase().split('_')[0]
ds_type_str.toLowerCase().split('_')[0]
];
}
@ -1014,7 +1018,7 @@ function setupCreateDatastoreDialog(){
ds_obj.datastore.base_iqn = base_iqn;
if (vg_name)
ds_obj.datastore.vg_name = vg_name;
ds_obj.datastore.vg_name = vg_name;
Sunstone.runAction("Datastore.create",ds_obj);

View File

@ -722,6 +722,42 @@ function updateHostsView (request,host_list){
}
}
function insert_datastores_capacity_table(host_share) {
var datastores = []
if ($.isArray(host_share.DATASTORES.DS))
datastores = host_share.DATASTORES.DS
else if (!$.isEmptyObject(host_share.DATASTORES.DS))
datastores = [host_share.DATASTORES.DS]
var str = "";
if (datastores.length) {
str += '<table id="info_host_datastore_table" class="twelve datatable extended_table">\
<thead>\
<tr>\
<th>' + tr("Datastore ID") + '</th>\
<th style="width:70%">' + tr("Capacity") + '</th>\
</tr>\
</thead>\
<tbody>';
$.each(datastores, function(index, value){
var pbar = generate_datastore_capacity_bar(value, 1);
str += '<tr>\
<td class="key_td">' + value.ID + '</td>\
<td class="value_td" colspan="2">'+ pbar +'</td>\
</tr>'
})
str += '</tbody>\
</table>'
}
return str;
}
//Updates the host info panel tab content and pops it up
function updateHostInfo(request,host){
var host_info = host.HOST;
@ -800,6 +836,9 @@ function updateHostInfo(request,host){
</table>\
</div>\
<div class="six columns">'
+ insert_datastores_capacity_table(host_info.HOST_SHARE) +
'</div>\
<div class="six columns">'
+ insert_extended_template_table(host_info.TEMPLATE,
"Host",
host_info.ID,