From 4a0baa67524a6fa0170cb6561af369a538f76cbe Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Thu, 12 Jun 2014 18:31:38 +0200 Subject: [PATCH 1/2] Feature #2971: Add an accounting widget to the User's Dashboard --- src/sunstone/etc/sunstone-views/user.yaml | 1 + .../public/js/plugins/dashboard-tab.js | 29 ++ src/sunstone/public/js/sunstone.js | 330 ++++++++++++------ 3 files changed, 259 insertions(+), 101 deletions(-) diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index 727b203022..89df3e2c1a 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/public/js/plugins/dashboard-tab.js b/src/sunstone/public/js/plugins/dashboard-tab.js index c6584fbba4..b769c2e32b 100644 --- a/src/sunstone/public/js/plugins/dashboard-tab.js +++ b/src/sunstone/public/js/plugins/dashboard-tab.js @@ -14,6 +14,16 @@ /* limitations under the License. */ /* -------------------------------------------------------------------------- */ +var empty_graph_placeholder = + ''+ + ''+ + //''+ + ''+ + '
'+ + ''+ + tr("There is no information available")+ + ''; + var dashboard_tab_content = '
\
\
\ @@ -200,6 +210,14 @@ var widgets = { \
\ \ + ', + "accounting" : '
\ + '+tr("Accounting")+'\ +
\ +
'+ + '
'+ + '
\ +
\
' } @@ -219,6 +237,17 @@ var widget_refresh = { "vms" : function(){ Sunstone.runAction("VM.list"); }, + "accounting" : function(){ + $(document).ready(function(){ + insertSelectOptions('div#user_dashboard_accounting_group_sel', $dashboard, "Group", gid, false); + accountingGraphs( + $("#user_dashboard_info_acct_div"), + { dashboard_user: true, + no_table: true, + // fixed_user: config["user_id"], + fixed_group_by: "vm" }); + }); + }, "user_quotas" : refreshDashboardUserQuotas, "group_quotas" : refreshDashboardGroupQuotas } diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js index 828e26b93a..e505b2ed78 100644 --- a/src/sunstone/public/js/sunstone.js +++ b/src/sunstone/public/js/sunstone.js @@ -3957,114 +3957,226 @@ function accountingGraphs(div, opt){ return false; } - div.html( - '
\ -
\ - \ - \ -
\ -
\ - \ - \ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ - \ - \ - \ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ - \ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ - \ - \ - \ - \ - \ -