diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index f49b957b42..649ec5733b 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -38,6 +38,7 @@ tabs: - vms - hosts widgets_one_footer: +# - accounting system-tab: panel_tabs: actions: diff --git a/src/sunstone/etc/sunstone-views/cloud.yaml b/src/sunstone/etc/sunstone-views/cloud.yaml index 814d26ffc7..0ea88cb303 100644 --- a/src/sunstone/etc/sunstone-views/cloud.yaml +++ b/src/sunstone/etc/sunstone-views/cloud.yaml @@ -36,6 +36,8 @@ tabs: #- vms widgets_one_per_row: # - vms + widgets_one_footer: +# - accounting system-tab: panel_tabs: actions: diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index 86fc6b1325..16a1e96a7d 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -38,6 +38,7 @@ tabs: widgets_one_per_row: - vms widgets_one_footer: + - accounting system-tab: panel_tabs: actions: diff --git a/src/sunstone/etc/sunstone-views/vdcadmin.yaml b/src/sunstone/etc/sunstone-views/vdcadmin.yaml index f799139d2b..0f51d94d16 100644 --- a/src/sunstone/etc/sunstone-views/vdcadmin.yaml +++ b/src/sunstone/etc/sunstone-views/vdcadmin.yaml @@ -36,6 +36,8 @@ tabs: #- vms widgets_one_per_row: # - vms + widgets_one_footer: +# - accounting system-tab: panel_tabs: actions: diff --git a/src/sunstone/etc/sunstone-views/vdcadmin46.yaml b/src/sunstone/etc/sunstone-views/vdcadmin46.yaml index 2436dbd004..ce6e62aedf 100644 --- a/src/sunstone/etc/sunstone-views/vdcadmin46.yaml +++ b/src/sunstone/etc/sunstone-views/vdcadmin46.yaml @@ -38,6 +38,7 @@ tabs: widgets_one_per_row: - vms widgets_one_footer: +# - accounting system-tab: panel_tabs: actions: diff --git a/src/sunstone/public/js/plugins/dashboard-tab.js b/src/sunstone/public/js/plugins/dashboard-tab.js index c6584fbba4..292f5e029c 100644 --- a/src/sunstone/public/js/plugins/dashboard-tab.js +++ b/src/sunstone/public/js/plugins/dashboard-tab.js @@ -200,6 +200,14 @@ var widgets = { \ \ \ + ', + "accounting" : '
\ + '+tr("Accounting")+'\ +
\ +
'+ + '
'+ + '
\ +
\
' } @@ -219,6 +227,7 @@ var widget_refresh = { "vms" : function(){ Sunstone.runAction("VM.list"); }, + "accounting" : function(){}, "user_quotas" : refreshDashboardUserQuotas, "group_quotas" : refreshDashboardGroupQuotas } @@ -411,6 +420,16 @@ $(document).ready(function(){ } }); + if($("#user_dashboard_info_acct_div", $dashboard).length != 0){ + accountingGraphs( + $("#user_dashboard_info_acct_div", $dashboard), + { no_table: true, + // fixed_user: config["user_id"], + fixed_group_by: "vm" + } + ); + } + $(document).foundation(); } }); diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js index 3ee5b9ec70..9a25a37584 100644 --- a/src/sunstone/public/js/sunstone.js +++ b/src/sunstone/public/js/sunstone.js @@ -3976,26 +3976,16 @@ function accountingGraphs(div, opt){ } div.html( - '
\ -
\ - \ - \ - \ -
\ -
\ -
\ -
\ -
\ -
\ -
\ + '
\ +
\ \ \
\ -
\ +
\ \ \
\ -
\ +
\ \ \
\ +
\ + \ +
\ +
\ + \ +
\ +
\ +
\ +
\ +
\ +
\
\ \
\ @@ -4045,7 +4050,7 @@ function accountingGraphs(div, opt){
\
\
\ -
\ +
\
\

'+tr("CPU hours")+'

\
\ @@ -4061,7 +4066,7 @@ function accountingGraphs(div, opt){ \
\
\ -
\ +
\
\

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

\
\ @@ -4083,6 +4088,27 @@ function accountingGraphs(div, opt){ opt = {}; } + //-------------------------------------------------------------------------- + // Set column width + //-------------------------------------------------------------------------- + + var n_columns = 2; // start, end time + + if (opt.fixed_user == undefined && opt.fixed_group == undefined){ + n_columns += 1; //acct_owner_container + } + + if(opt.fixed_group_by == undefined){ + n_columns += 1; //acct_group_by_container + } + + var width = parseInt(12 / n_columns); + + $("#acct_start_time_container", div).addClass("large-"+width); + $("#acct_end_time_container", div).addClass("large-"+width); + $("#acct_group_by_container", div).addClass("large-"+width); + $("#acct_owner_container", div).addClass("large-"+width); + //-------------------------------------------------------------------------- // Init start time to 1st of last month //-------------------------------------------------------------------------- @@ -4098,24 +4124,9 @@ function accountingGraphs(div, opt){ //-------------------------------------------------------------------------- if (opt.fixed_user != undefined || opt.fixed_group != undefined){ - $("#acct_owner", div).hide(); -/* - $("input[name='acct_owner']", div).attr("disabled", "disabled"); - - $("#acct_owner_select", div).show(); - - if(opt.fixed_user != undefined){ - var text = tr("User") +" " + opt.fixed_user; - $("input[value='acct_owner_user']", div).attr("checked", "checked"); - } else { - var text = tr("Group") + " " + opt.fixed_group; - $("input[value='acct_owner_group']", div).attr("checked", "checked"); - } - - $("#acct_owner_select", div).text(text); -*/ + $("#acct_owner_container", div).hide(); } else { - $("input[name='acct_owner']", div).change(function(){ + $("select#acct_owner", div).change(function(){ var value = $(this).val(); switch (value){ @@ -4198,7 +4209,7 @@ function accountingGraphs(div, opt){ } else { var select_val = $("#acct_owner_select .resource_list_select", div).val(); - switch ($("input[name='acct_owner']:checked", div).val()){ + switch ($("select#acct_owner", div).val()){ case "acct_owner_all": break; @@ -4216,10 +4227,15 @@ function accountingGraphs(div, opt){ } } + var no_table = false; + if (opt["no_table"] == true) { + no_table = true; + } + OpenNebula.VM.accounting({ // timeout: true, success: function(req, response){ - fillAccounting(div, req, response); + fillAccounting(div, req, response, no_table); }, error: onError, data: options @@ -4491,7 +4507,9 @@ function fillAccounting(div, req, response, no_table) { // Init dataTables //-------------------------------------------------------------------------- - if (!no_table){ + if (no_table) { + $(".acct_table").hide(); + } else { $("#acct_cpu_datatable",div).dataTable().fnClearTable(); $("#acct_cpu_datatable",div).dataTable().fnDestroy(); @@ -5364,4 +5382,4 @@ function generateInstantiateUserInputs(div, user_inputs, opts) { } return (network_attrs.length > 0 || text_attrs.length > 0); -} \ No newline at end of file +}