From 1c88bdd24e8bfb7756a3f87e7d65a776a42e4f7c Mon Sep 17 00:00:00 2001 From: Vincent Augagneur Date: Thu, 5 Sep 2013 11:52:18 +0200 Subject: [PATCH] //dashboard widget regardless refresh --- js/admin-dashboard.js | 79 +++++++++++-------- .../templates/hook/dashboard_zone_one.tpl | 2 +- modules/dashproducts/dashproducts.php | 2 - .../templates/hook/dashboard_zone_two.tpl | 5 +- .../templates/hook/dashboard_zone_two.tpl | 2 +- 5 files changed, 51 insertions(+), 39 deletions(-) diff --git a/js/admin-dashboard.js b/js/admin-dashboard.js index b22d553a1..4cc7b03e5 100644 --- a/js/admin-dashboard.js +++ b/js/admin-dashboard.js @@ -24,8 +24,10 @@ $(document).ready( function () { refreshDashbard(); - if (use_push) + /* +if (use_push) launchPush(); +*/ }); function launchPush() @@ -52,44 +54,57 @@ function launchPush() function refreshDashbard(module_name) { + module_list = new Array(); + if (typeof(module_name) == 'undefined') - module_name = 0; - else + { + $('.widget').each( function () { + module_list.push($(this).attr('id')); + $(this).addClass('loading'); + }); + } + else + { + module_list.push(module_name); $('#'+module_name+' section').each( function (){ $(this).addClass('loading'); }); - - $.ajax({ - url : dashboard_ajax_url, - data : { - ajax:true, - action:'refreshDashboard', - module:module_name - }, - dataType: 'json', - success : function(widgets){ - for (var name in widgets) - { - for (data_type in widgets[name]) - window[data_type](widgets[name][data_type]); - } - }, - error : function(data){ - //@TODO display errors - } - }); -} - -function data_value(data) -{ - for (var data_id in data) + } + + for (var module_id in module_list) { - $('#'+data_id).html(data[data_id]); - $('#'+data_id).closest('section').removeClass('loading'); + $.ajax({ + url : dashboard_ajax_url, + data : { + ajax:true, + action:'refreshDashboard', + module:module_list[module_id] + }, + dataType: 'json', + success : function(widgets){ + for (var widget_name in widgets) + { + for (data_type in widgets[widget_name]) + window[data_type](widget_name, widgets[widget_name][data_type]); + } + }, + error : function(data){ + //@TODO display errors + } + }); } } -function data_trends(data) +function data_value(widget_name, data) +{ + for (var data_id in data) + { + $('#'+data_id+' ').html(data[data_id]); + $('#'+data_id+', #'+widget_name).closest('section').removeClass('loading'); + } +} + +function data_trends(widget_name, data) { for (var data_id in data) { @@ -102,7 +117,7 @@ function data_trends(data) } } -function data_table(data) +function data_table(widget_name, data) { for (var data_id in data) { diff --git a/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl b/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl index f24e72649..78ee06016 100644 --- a/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl +++ b/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl @@ -23,7 +23,7 @@ * International Registered Trademark & Property of PrestaShop SA *} -
+
{l s='Recent Activity'} diff --git a/modules/dashproducts/dashproducts.php b/modules/dashproducts/dashproducts.php index 64112e410..11e62458c 100644 --- a/modules/dashproducts/dashproducts.php +++ b/modules/dashproducts/dashproducts.php @@ -318,7 +318,6 @@ class Dashproducts extends Module ); $terms = $this->getMostSearchTerms($date_from, $date_to); - $body = array(); if (is_array($terms) && count($terms)) foreach ($terms as $term) @@ -462,7 +461,6 @@ class Dashproducts extends Module GROUP BY ss.`keywords` ORDER BY `count_keywords` DESC LIMIT 0, '.(int)$limit; - return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); } } \ No newline at end of file diff --git a/modules/dashproducts/views/templates/hook/dashboard_zone_two.tpl b/modules/dashproducts/views/templates/hook/dashboard_zone_two.tpl index 15ad68a4f..a04adf9b3 100644 --- a/modules/dashproducts/views/templates/hook/dashboard_zone_two.tpl +++ b/modules/dashproducts/views/templates/hook/dashboard_zone_two.tpl @@ -23,11 +23,11 @@ * International Registered Trademark & Property of PrestaShop SA *} -
+
{l s='Product and Sales'} - + @@ -111,5 +111,4 @@
-
\ No newline at end of file diff --git a/modules/dashtrends/views/templates/hook/dashboard_zone_two.tpl b/modules/dashtrends/views/templates/hook/dashboard_zone_two.tpl index 39121a45f..e0cb0fc02 100644 --- a/modules/dashtrends/views/templates/hook/dashboard_zone_two.tpl +++ b/modules/dashtrends/views/templates/hook/dashboard_zone_two.tpl @@ -23,7 +23,7 @@ * International Registered Trademark & Property of PrestaShop SA *} -
+
{l s='Score Trends'}