From 8c03a253f6a06b2d8a418d74a750902a8260bd65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 6 May 2014 17:30:24 +0200 Subject: [PATCH] Feature #1607: Add accounting tables --- src/sunstone/public/js/sunstone.js | 127 ++++++++++++++++++++++++++++- 1 file changed, 126 insertions(+), 1 deletion(-) diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js index 1ee7926d6a..85a14cef1e 100644 --- a/src/sunstone/public/js/sunstone.js +++ b/src/sunstone/public/js/sunstone.js @@ -3986,6 +3986,34 @@ function accountingGraphs(div, opt){
\
\
\ +
\ +
\ +
\ +

'+tr("CPU hours")+'

\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ +
'+tr("Date")+'
\ +
\ +
\ +
\ +

'+tr("Memory GB hours")+'

\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ +
'+tr("Date")+'
\
'); if (opt == undefined){ @@ -4133,6 +4161,8 @@ Filter by: user, group, vm, [flow] Download csv */ + // TODO: Uniform time format (yy/mm/dd?) and define the time zone (utc, local?) + var options = req.request.data[0]; //-------------------------------------------------------------------------- @@ -4372,7 +4402,7 @@ Download csv }); }); - $.plot($("#acct_cpu_graph", div), plot_series, options); + var cpu_plot = $.plot($("#acct_cpu_graph", div), plot_series, options); // --- mem --- @@ -4485,4 +4515,99 @@ Download csv } $.plot($("#acct_activity_graph", div), plot_series, options); + + //-------------------------------------------------------------------------- + // Init dataTables + //-------------------------------------------------------------------------- + + $("#acct_cpu_datatable",div).dataTable().fnClearTable(); + $("#acct_cpu_datatable",div).dataTable().fnDestroy(); + + $("#acct_cpu_datatable thead",div).remove(); + + + $("#acct_mem_datatable",div).dataTable().fnClearTable(); + $("#acct_mem_datatable",div).dataTable().fnDestroy(); + + $("#acct_mem_datatable thead",div).remove(); + + + cpu_plot_data = cpu_plot.getData(); + mem_plot_data = mem_plot.getData(); + + var thead = ''+tr("Date")+''; + + $.each(series.CPU_HOURS, function(key, val){ + thead += ''+group_by_prefix+key+''; + }); + + thead += ''; + + $("#acct_cpu_datatable",div).append(thead); + + thead = ''+tr("Date")+''; + + $.each(series.MEM_HOURS, function(key, val){ + thead += ''+group_by_prefix+key+''; + }); + + thead += ''; + + $("#acct_mem_datatable",div).append(thead); + + + var cpu_dataTable_data = []; + var mem_dataTable_data = []; + + for (var i = 0; i