From f05935790845220ee71bf54b9b706969c394e39b Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 31 Aug 2012 14:42:57 +0200 Subject: [PATCH] Feature #1098: Add net_tx y net_rx accouting plots to sunstone and selfservice. When the requested dates is 1 day, set interval in 1 hour. Otherwise set interval in 1 day (cherry picked from commit 834ae97bb4727086a7d8d2f338f31cedad1085f2) --- .../occi/lib/ui/public/js/plugins/dashboard.js | 13 +++++++++++++ src/sunstone/public/js/plugins/groups-tab.js | 8 ++++++++ src/sunstone/public/js/plugins/users-tab.js | 8 ++++++++ src/sunstone/public/js/sunstone-util.js | 11 +++++++++-- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/cloud/occi/lib/ui/public/js/plugins/dashboard.js b/src/cloud/occi/lib/ui/public/js/plugins/dashboard.js index 179382e163..7e76357169 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/dashboard.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/dashboard.js @@ -22,6 +22,10 @@ var user_acct_graphs = [ { title : tr("Memory"), monitor_resources : "MEMORY", humanize_figures : true + }, + { title : tr("Net transfer rates"), + monitor_resources : "NETTX,NETRX", + humanize_figures : true } ]; @@ -93,6 +97,15 @@ var dashboard_tab_content = \ \ \ + \ + \ + \ + \ +
\ +
'+ + spinner+ + '
\ +
\ \ \ \ diff --git a/src/sunstone/public/js/plugins/groups-tab.js b/src/sunstone/public/js/plugins/groups-tab.js index 72559cdcd3..9e6cd7508f 100644 --- a/src/sunstone/public/js/plugins/groups-tab.js +++ b/src/sunstone/public/js/plugins/groups-tab.js @@ -27,6 +27,14 @@ var group_acct_graphs = [ { title : tr("Memory"), monitor_resources : "MEMORY", humanize_figures : true + }, + { title : tr("Net TX"), + monitor_resources : "NETTX", + humanize_figures : true + }, + { title : tr("Net RX"), + monitor_resources : "NETRX", + humanize_figures : true } ]; diff --git a/src/sunstone/public/js/plugins/users-tab.js b/src/sunstone/public/js/plugins/users-tab.js index e93c46ca33..3ce03bb3ef 100644 --- a/src/sunstone/public/js/plugins/users-tab.js +++ b/src/sunstone/public/js/plugins/users-tab.js @@ -29,6 +29,14 @@ var user_acct_graphs = [ { title : tr("Memory"), monitor_resources : "MEMORY", humanize_figures : true + }, + { title : tr("Net TX"), + monitor_resources : "NETTX", + humanize_figures : true + }, + { title : tr("Net RX"), + monitor_resources : "NETRX", + humanize_figures : true } ]; diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js index c06bb30452..849ac710d1 100644 --- a/src/sunstone/public/js/sunstone-util.js +++ b/src/sunstone/public/js/sunstone-util.js @@ -1231,10 +1231,17 @@ function progressBar(value, opts){ } function loadAccounting(resource, id, graphs, options){ + var secs_in_day = 3600 * 24; var now = Math.floor(new Date().getTime() / 1000) - var start = options && options.start ? options.start : now - (3600 * 24); + var start = options && options.start ? options.start : now - secs_in_day; var end = options && options.end ? options.end : now; - var interval = options && options.interval ? options.interval : 60 * 60; + var interval; + if (options && options.interval){ + interval = options.interval; + } else { + //If we are asking more than one interval is one day, otherwise 1 hour + interval = (end - start) > secs_in_day ? secs_in_day : 3600; + } for (var i = 0; i < graphs.length; i++){ var graph_cfg = graphs[i];