mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Feature #696: Sunstone client side update to support new graphic data format
This commit is contained in:
parent
f6493e1f2b
commit
1d4df9ef55
@ -298,7 +298,8 @@ class SunstoneServer
|
||||
watch_client.host_total(columns)
|
||||
end
|
||||
else
|
||||
return [200, nil]
|
||||
error = Error.new("Monitoring not supported for this resource: #{resource}")
|
||||
return [200, error.to_json]
|
||||
end
|
||||
|
||||
if rc.nil?
|
||||
|
@ -168,30 +168,33 @@ Sunstone.addMainTab('dashboard_tab',dashboard_tab);
|
||||
|
||||
function plot_global_graph(data,info){
|
||||
var id = info.title;
|
||||
var labels_arr = info.monitor_resources.split(',');
|
||||
var monitoring = data.monitoring;
|
||||
var serie;
|
||||
var series = [];
|
||||
var width = ($(window).width()-129)*45/100;
|
||||
var mon_count = 0;
|
||||
|
||||
$('#'+id).html('<div id="'+id+'_graph" style="height:70px;width:'+width+'px"><div>');
|
||||
|
||||
for (var i = 0; i< labels_arr.length; i++) {
|
||||
for (var label in monitoring) {
|
||||
serie = {
|
||||
label: labels_arr[i],
|
||||
data: data[i]
|
||||
label: label,
|
||||
data: monitoring[label]
|
||||
};
|
||||
series.push(serie);
|
||||
mon_count++;
|
||||
};
|
||||
|
||||
var options = {
|
||||
legend : {
|
||||
show : true,
|
||||
noColumns: labels_arr.length,
|
||||
noColumns: mon_count,
|
||||
container: $('#'+id+'_legend')
|
||||
},
|
||||
xaxis : {
|
||||
mode: "time",
|
||||
timeformat: "%h:%M"
|
||||
tickFormatter: function(val,axis){
|
||||
return pretty_time_axis(val);
|
||||
},
|
||||
},
|
||||
yaxis : { labelWidth: 40 }
|
||||
}
|
||||
|
@ -46,6 +46,20 @@ function pretty_time(time_seconds)
|
||||
return hour + ":" + mins +":" + secs + " " + month + "/" + day + "/" + year;
|
||||
}
|
||||
|
||||
function pretty_time_axis(time){
|
||||
var d = new Date();
|
||||
d.setTime(time*1000);
|
||||
|
||||
var secs = pad(d.getSeconds(),2);
|
||||
var hour = pad(d.getHours(),2);
|
||||
var mins = pad(d.getMinutes(),2);
|
||||
var day = pad(d.getDate(),2);
|
||||
var month = pad(d.getMonth()+1,2); //getMonths returns 0-11
|
||||
var year = d.getFullYear();
|
||||
|
||||
return hour + ":" + mins + ":" + secs;// + " " + month + "/" + day;
|
||||
}
|
||||
|
||||
//returns a human readable size in Kilo, Mega, Giga or Tera bytes
|
||||
function humanize_size(value) {
|
||||
if (typeof(value) === "undefined") {
|
||||
@ -512,27 +526,31 @@ 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 labels_arr = labels.split(',');
|
||||
var id_suffix = labels.replace(/,/g,'_');
|
||||
var monitoring = data.monitoring
|
||||
var series = [];
|
||||
var serie = null;
|
||||
var serie;
|
||||
var mon_count = 0;
|
||||
|
||||
for (var i = 0; i< labels_arr.length; i++) {
|
||||
for (var label in monitoring) {
|
||||
serie = {
|
||||
label: labels_arr[i],
|
||||
data: data[i]
|
||||
label: label,
|
||||
data: monitoring[label]
|
||||
};
|
||||
series.push(serie);
|
||||
mon_count++;
|
||||
};
|
||||
|
||||
var options = {
|
||||
legend : { show : true,
|
||||
noColumns: labels_arr.length,
|
||||
noColumns: mon_count++,
|
||||
container: $('#legend_'+id_suffix)
|
||||
},
|
||||
xaxis : { mode: "time",
|
||||
timeformat: "%h:%M"
|
||||
},
|
||||
xaxis : {
|
||||
tickFormatter: function(val,axis){
|
||||
return pretty_time_axis(val);
|
||||
},
|
||||
},
|
||||
yaxis : { labelWidth: 40,
|
||||
tickFormatter: function(val, axis) {
|
||||
return humanize(val);
|
||||
|
Loading…
x
Reference in New Issue
Block a user