From f60ce604a84c462a08bb4bae89048003ca0adf68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 2 Jul 2014 13:27:28 +0200 Subject: [PATCH] Feature #2971: Refactor and minor fix --- src/sunstone/etc/sunstone-views/admin.yaml | 1 + src/sunstone/etc/sunstone-views/cloud.yaml | 2 + src/sunstone/etc/sunstone-views/vdcadmin.yaml | 2 + .../etc/sunstone-views/vdcadmin46.yaml | 1 + .../public/js/plugins/dashboard-tab.js | 34 +- src/sunstone/public/js/sunstone.js | 358 ++++++------------ 6 files changed, 142 insertions(+), 256 deletions(-) diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index c4bd59e27d..72789b8836 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 41e9887f90..b499b74d9d 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/vdcadmin.yaml b/src/sunstone/etc/sunstone-views/vdcadmin.yaml index 6175facd39..a14c1a2403 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 c095c08ca3..ac49cc7d6f 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 b769c2e32b..292f5e029c 100644 --- a/src/sunstone/public/js/plugins/dashboard-tab.js +++ b/src/sunstone/public/js/plugins/dashboard-tab.js @@ -14,16 +14,6 @@ /* limitations under the License. */ /* -------------------------------------------------------------------------- */ -var empty_graph_placeholder = - ''+ - ''+ - //''+ - ''+ - '
'+ - ''+ - tr("There is no information available")+ - ''; - var dashboard_tab_content = '
\
\
\ @@ -212,7 +202,7 @@ var widgets = {
\ ', "accounting" : '
\ - '+tr("Accounting")+'\ + '+tr("Accounting")+'\
\
'+ '
'+ @@ -237,17 +227,7 @@ 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" }); - }); - }, + "accounting" : function(){}, "user_quotas" : refreshDashboardUserQuotas, "group_quotas" : refreshDashboardGroupQuotas } @@ -440,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 e505b2ed78..248488ca3f 100644 --- a/src/sunstone/public/js/sunstone.js +++ b/src/sunstone/public/js/sunstone.js @@ -3957,231 +3957,145 @@ function accountingGraphs(div, opt){ return false; } - if (opt['dashboard_user']) { - // HTML for User Dashboard tab - div.html( - '
\ -
\ - \ - \ -
\ -
\ - \ - \ -
\ -
\ - \ -
\ - \ - \ -
\ - \ +
\ +
\ + \ + \ +
\ +
\ + \ + \ +
\ +
\ + \ +
\ +
\ + \ -
\
\ -
\ -
\ -
\ -
\ - \ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ - \ - \ - \ - \ - \ -
\ -
\ -
\ -
\ - '); - } else { - // HTML for Provisioning tab - div.html( - '
\ -
\ - \ - \ -
\ -
\ - \ - \ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ - \ - \ - \ -
\ -
\ +
\
\
\
\ -
\ -
\ -
\ - \ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ - \ - \ - \ - \ - \ -
\ +
\ +
\ +
\ +
\ +
\ + \ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
\ + \ + \ + \ + \ + \
\
\ - \ + '); if (opt == undefined){ 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 //-------------------------------------------------------------------------- @@ -4197,33 +4111,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 { - // depending on the view, the acct_owner can be in either a select or a - // radio button - var acct_owner_selector; - if ($("select#acct_owner").length > 0) { - acct_owner_selector = "select#acct_owner"; - } else { - acct_owner_selector = "input[name='acct_owner']"; - } - - $(acct_owner_selector, div).change(function(){ + $("select#acct_owner", div).change(function(){ var value = $(this).val(); switch (value){ @@ -4306,7 +4196,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;