Allow static KPIs and make refresh button optional
This commit is contained in:
@@ -25,9 +25,9 @@
|
||||
|
||||
<{if isset($href) && $href}a style="display:block" href="{$href|escape:'html':'UTF-8'}"{else}div{/if} id="{$id|escape:'html':'UTF-8'}" data-toggle="tooltip" class="box-stats label-tooltip {$color|escape}" data-original-title="{$tooltip|escape}">
|
||||
<div class="kpi-content">
|
||||
{if isset($icon) && $icon}
|
||||
<i class="{$icon|escape}"></i>
|
||||
{/if}
|
||||
{if isset($icon) && $icon}
|
||||
<i class="{$icon|escape}"></i>
|
||||
{/if}
|
||||
<span class="title">{$title|escape}</span>
|
||||
<span cLass="subtitle">{$subtitle|escape}</span>
|
||||
{if isset($chart) && $chart}
|
||||
@@ -36,46 +36,47 @@
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<span class="value skeleton-loading-wave loading-container-bar loading"></span>
|
||||
{if isset($source) && $source}
|
||||
<span class="value skeleton-loading-wave loading-container-bar loading"></span>
|
||||
{elseif isset($value) && $value != ''}
|
||||
<span class="value">{$value|escape:'html':'UTF-8'}</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
</{if isset($href) && $href}a{else}div{/if}>
|
||||
|
||||
{if isset($source) && $source != '' && isset($refresh) && $refresh != ''}
|
||||
|
||||
{/if}
|
||||
<script>
|
||||
function refresh_{$id|replace:'-':'_'|addslashes}()
|
||||
{
|
||||
$.ajax({
|
||||
url: '{$source|addslashes}' + '&rand=' + new Date().getTime(),
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
cache: false,
|
||||
headers: { 'cache-control': 'no-cache' },
|
||||
beforeSend: function() {
|
||||
$('#{$id|addslashes}').find('.value').html('');
|
||||
$('#{$id|addslashes}').find('.value').addClass('skeleton-loading-wave loading-container-bar loading');
|
||||
},
|
||||
success: function(jsonData){
|
||||
if (!jsonData.has_errors)
|
||||
{
|
||||
if (jsonData.value != undefined)
|
||||
$('#{$id|addslashes} .value').html(jsonData.value);
|
||||
if (jsonData.data != undefined)
|
||||
{if isset($source) && $source}
|
||||
<script>
|
||||
function refresh_{$id|replace:'-':'_'|addslashes}()
|
||||
{
|
||||
$.ajax({
|
||||
url: '{$source|addslashes}' + '&rand=' + new Date().getTime(),
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
cache: false,
|
||||
headers: { 'cache-control': 'no-cache' },
|
||||
beforeSend: function() {
|
||||
$('#{$id|addslashes}').find('.value').html('');
|
||||
$('#{$id|addslashes}').find('.value').addClass('skeleton-loading-wave loading-container-bar loading');
|
||||
},
|
||||
success: function(jsonData){
|
||||
if (!jsonData.has_errors)
|
||||
{
|
||||
$("#{$id|addslashes} .boxchart svg").remove();
|
||||
set_d3_{$id|replace:'-':'_'|addslashes}(jsonData.data);
|
||||
if (jsonData.value != undefined)
|
||||
$('#{$id|addslashes} .value').html(jsonData.value);
|
||||
if (jsonData.data != undefined)
|
||||
{
|
||||
$("#{$id|addslashes} .boxchart svg").remove();
|
||||
set_d3_{$id|replace:'-':'_'|addslashes}(jsonData.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
$('#{$id|addslashes}').find('.value').removeClass('skeleton-loading-wave loading-container-bar loading');
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
},
|
||||
complete: function () {
|
||||
$('#{$id|addslashes}').find('.value').removeClass('skeleton-loading-wave loading-container-bar loading');
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{/if}
|
||||
|
||||
{if $chart}
|
||||
<script>
|
||||
|
||||
@@ -23,7 +23,9 @@
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<div class="panel kpi-container">
|
||||
<div class="kpi-refresh"><button class="close refresh" type="button" onclick="refresh_kpis();"><i class="process-icon-refresh" style="font-size:1em"></i></button></div>
|
||||
{if $refresh}
|
||||
<div class="kpi-refresh"><button class="close refresh" type="button" onclick="refresh_kpis();"><i class="process-icon-refresh" style="font-size:1em"></i></button></div>
|
||||
{/if}
|
||||
<div class="row">
|
||||
{assign var='col' value=(int)(12 / $kpis|count)}
|
||||
{foreach from=$kpis item=i name=kpi}
|
||||
|
||||
@@ -38,7 +38,6 @@ class HelperKpiCore extends Helper
|
||||
public $value;
|
||||
public $data;
|
||||
public $source;
|
||||
public $refresh = true;
|
||||
public $href;
|
||||
public $tooltip;
|
||||
|
||||
@@ -56,10 +55,10 @@ class HelperKpiCore extends Helper
|
||||
'value' => $this->value,
|
||||
'data' => $this->data,
|
||||
'source' => $this->source,
|
||||
'refresh' => $this->refresh,
|
||||
'href' => $this->href,
|
||||
'tooltip' => $this->tooltip
|
||||
));
|
||||
|
||||
return $this->tpl->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,12 +30,15 @@ class HelperKpiRowCore extends Helper
|
||||
public $base_tpl = 'row.tpl';
|
||||
|
||||
public $kpis = array();
|
||||
public $refresh = true;
|
||||
|
||||
public function generate()
|
||||
{
|
||||
$this->tpl = $this->createTemplate($this->base_tpl);
|
||||
|
||||
$this->tpl->assign('kpis', $this->kpis);
|
||||
$this->tpl->assign('refresh', $this->refresh);
|
||||
|
||||
return $this->tpl->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,9 +134,6 @@ class AdminCartsControllerCore extends AdminController
|
||||
$time = time();
|
||||
$kpis = array();
|
||||
|
||||
$statsController = new AdminStatsController();
|
||||
$this->context->controller = $this;
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-conversion-rate';
|
||||
$helper->icon = 'icon-sort-by-attributes-alt';
|
||||
|
||||
@@ -373,9 +373,6 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
$time = time();
|
||||
$kpis = array();
|
||||
|
||||
$statsController = new AdminStatsController();
|
||||
$this->context->controller = $this;
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-disabled-categories';
|
||||
$helper->icon = 'icon-off';
|
||||
|
||||
@@ -508,9 +508,6 @@ class AdminCustomerThreadsControllerCore extends AdminController
|
||||
$time = time();
|
||||
$kpis = array();
|
||||
|
||||
$statsController = new AdminStatsController();
|
||||
$this->context->controller = $this;
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-pending-messages';
|
||||
$helper->icon = 'icon-envelope';
|
||||
|
||||
@@ -642,9 +642,6 @@ class AdminCustomersControllerCore extends AdminController
|
||||
$time = time();
|
||||
$kpis = array();
|
||||
|
||||
$statsController = new AdminStatsController();
|
||||
$this->context->controller = $this;
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-gender';
|
||||
$helper->icon = 'icon-male';
|
||||
|
||||
@@ -1301,9 +1301,6 @@ class AdminModulesControllerCore extends AdminController
|
||||
$time = time();
|
||||
$kpis = array();
|
||||
|
||||
$statsController = new AdminStatsController();
|
||||
$this->context->controller = $this;
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-installed-modules';
|
||||
$helper->icon = 'icon-puzzle-piece';
|
||||
|
||||
@@ -1244,9 +1244,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$time = time();
|
||||
$kpis = array();
|
||||
|
||||
$statsController = new AdminStatsController();
|
||||
$this->context->controller = $this;
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-conversion-rate';
|
||||
$helper->icon = 'icon-sort-by-attributes-alt';
|
||||
|
||||
@@ -2705,9 +2705,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
$time = time();
|
||||
$kpis = array();
|
||||
|
||||
$statsController = new AdminStatsController();
|
||||
$this->context->controller = $this;
|
||||
|
||||
// if (Configuration::get('PS_STOCK_MANAGEMENT')) {
|
||||
// $helper = new HelperKpi();
|
||||
// $helper->id = 'box-products-stock';
|
||||
|
||||
@@ -1409,9 +1409,6 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$time = time();
|
||||
$kpis = array();
|
||||
|
||||
$statsController = new AdminStatsController();
|
||||
$this->context->controller = $this;
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-languages';
|
||||
$helper->icon = 'icon-microphone';
|
||||
|
||||
Reference in New Issue
Block a user