mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-21 04:12:37 +09:00
Feature #1664: Fix humanize for big numbers, and add an option to set the sufix (e.g. B/s)
This commit is contained in:
1 parent
8c383e372d
commit
6b5d3b8d70
2 files changed
+14
-8
No files matched your search
@@ -433,6 +433,7 @@ var vm_actions = {
|
||||
monitor_resources : "NET_TX",
|
||||
humanize_figures : true,
|
||||
convert_from_bytes : true,
|
||||
y_sufix : "B/s",
|
||||
derivative : true,
|
||||
div_graph : $("#dash_vm_net_tx_graph", $dashboard),
|
||||
div_legend : $("#dash_vm_net_tx_legend", $dashboard)
|
||||
@@ -441,6 +442,7 @@ var vm_actions = {
|
||||
monitor_resources : "NET_RX",
|
||||
humanize_figures : true,
|
||||
convert_from_bytes : true,
|
||||
y_sufix : "B/s",
|
||||
derivative : true,
|
||||
div_graph : $("#dash_vm_net_rx_graph", $dashboard),
|
||||
div_legend : $("#dash_vm_net_rx_legend", $dashboard)
|
||||
|
||||
@@ -83,14 +83,14 @@ function pretty_time_runtime(time){
|
||||
|
||||
//returns a human readable size in Kilo, Mega, Giga or Tera bytes
|
||||
//if no from_bytes, assumes value comes in Ks
|
||||
function humanize_size(value,from_bytes) {
|
||||
function humanize_size(value,from_bytes,sufix) {
|
||||
if (typeof(value) === "undefined") {
|
||||
value = 0;
|
||||
}
|
||||
var binarySufix = from_bytes ?
|
||||
["", "K", "M", "G", "T" ] : ["K", "M", "G", "T" ];
|
||||
var i=0;
|
||||
while (value > 1024 && i < 3){
|
||||
var binarySufix = ["", "K", "M", "G", "T" ];
|
||||
|
||||
var i = from_bytes ? 0 : 1;
|
||||
while (value >= 1024 && i < 4){
|
||||
value = value / 1024;
|
||||
i++;
|
||||
}
|
||||
@@ -100,7 +100,11 @@ function humanize_size(value,from_bytes) {
|
||||
value = Math.round(value);
|
||||
}
|
||||
|
||||
var st = value + binarySufix[i];
|
||||
if(sufix == undefined) {
|
||||
sufix = "B";
|
||||
}
|
||||
|
||||
var st = value + binarySufix[i] + sufix;
|
||||
return st;
|
||||
}
|
||||
|
||||
@@ -110,7 +114,7 @@ function humanize_size_from_mb(value) {
|
||||
}
|
||||
var binarySufix = ["MB", "GB", "TB" ];
|
||||
var i=0;
|
||||
while (value > 1024 && i < 3){
|
||||
while (value >= 1024 && i < 2){
|
||||
value = value / 1024;
|
||||
i++;
|
||||
}
|
||||
@@ -883,7 +887,7 @@ function plot_totals(response, info) {
|
||||
},
|
||||
yaxis : { labelWidth: 40,
|
||||
tickFormatter: function(val, axis) {
|
||||
return humanize(val, info.convert_from_bytes);
|
||||
return humanize(val, info.convert_from_bytes, info.y_sufix);
|
||||
},
|
||||
min: 0
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user