// dashboard improvements
This commit is contained in:
1 parent
a9f75a02a7
commit
6a2e847970
5 files changed
+63
-48
No files matched your search
@@ -76,7 +76,15 @@ class Dashactivity extends Module
|
|||||||
|
|
||||||
public function hookDashboardZoneOne($params)
|
public function hookDashboardZoneOne($params)
|
||||||
{
|
{
|
||||||
|
if (!Module::isInstalled('gapi'))
|
||||||
|
$gapi_mode = 'install';
|
||||||
|
elseif (($gapi = Module::getInstanceByName('gapi')) && Validate::isLoadedObject($gapi) && $gapi->isConfigured())
|
||||||
|
$gapi_mode = false;
|
||||||
|
else
|
||||||
|
$gapi_mode = 'configure';
|
||||||
|
|
||||||
$this->context->smarty->assign(array_merge(array(
|
$this->context->smarty->assign(array_merge(array(
|
||||||
|
'gapi_mode' => $gapi_mode,
|
||||||
'dashactivity_config_form' => $this->renderConfigForm(),
|
'dashactivity_config_form' => $this->renderConfigForm(),
|
||||||
'date_subtitle' => $this->l('from %s to %s'),
|
'date_subtitle' => $this->l('from %s to %s'),
|
||||||
'date_format' => $this->context->language->date_format_lite
|
'date_format' => $this->context->language->date_format_lite
|
||||||
@@ -265,17 +273,15 @@ class Dashactivity extends Module
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$directLink = $this->l('Direct link');
|
$directLink = $this->l('Direct link');
|
||||||
$sql = 'SELECT http_referer
|
|
||||||
FROM '._DB_PREFIX_.'connections
|
|
||||||
WHERE 1
|
|
||||||
'.Shop::addSqlRestriction().'
|
|
||||||
AND date_add BETWEEN '.$date_from.' AND '.$date_to.'
|
|
||||||
LIMIT 0, '.(int)$limit;
|
|
||||||
|
|
||||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->query($sql);
|
|
||||||
$websites = array($directLink => 0);
|
$websites = array($directLink => 0);
|
||||||
|
|
||||||
while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($result))
|
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
||||||
|
SELECT http_referer
|
||||||
|
FROM '._DB_PREFIX_.'connections
|
||||||
|
WHERE date_add BETWEEN '.$date_from.' AND '.$date_to.'
|
||||||
|
'.Shop::addSqlRestriction().'
|
||||||
|
LIMIT '.(int)$limit);
|
||||||
|
foreach ($result as $row)
|
||||||
{
|
{
|
||||||
if (!isset($row['http_referer']) || empty($row['http_referer']))
|
if (!isset($row['http_referer']) || empty($row['http_referer']))
|
||||||
++$websites[$directLink];
|
++$websites[$directLink];
|
||||||
@@ -299,17 +305,16 @@ class Dashactivity extends Module
|
|||||||
'form' => array(
|
'form' => array(
|
||||||
'id_form' => 'step_carrier_general',
|
'id_form' => 'step_carrier_general',
|
||||||
'input' => array(),
|
'input' => array(),
|
||||||
'submit' =>
|
'submit' => array(
|
||||||
array(
|
'title' => $this->l(' Save '),
|
||||||
'title' => $this->l(' Save '),
|
'class' => 'btn btn-default submit_dash_config',
|
||||||
'class' => 'btn btn-default submit_dash_config',
|
'reset' => array(
|
||||||
'reset' => array(
|
'title' => $this->l('Cancel'),
|
||||||
'title' => $this->l('Cancel'),
|
'class' => 'btn btn-default cancel_dash_config',
|
||||||
'class' => 'btn btn-default cancel_dash_config',
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
),
|
)
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
|
||||||
$sub_widget = array(
|
$sub_widget = array(
|
||||||
array('label' => $this->l('Show Pending'), 'config_name' => 'DASHACTIVITY_SHOW_PENDING'),
|
array('label' => $this->l('Show Pending'), 'config_name' => 'DASHACTIVITY_SHOW_PENDING'),
|
||||||
@@ -317,7 +322,7 @@ class Dashactivity extends Module
|
|||||||
array('label' => $this->l('Show Clients'), 'config_name' => 'DASHACTIVITY_SHOW_CUSTOMERS'),
|
array('label' => $this->l('Show Clients'), 'config_name' => 'DASHACTIVITY_SHOW_CUSTOMERS'),
|
||||||
array('label' => $this->l('Show Newsletters'), 'config_name' => 'DASHACTIVITY_SHOW_NEWSLETTER'),
|
array('label' => $this->l('Show Newsletters'), 'config_name' => 'DASHACTIVITY_SHOW_NEWSLETTER'),
|
||||||
array('label' => $this->l('Show Traffic'), 'config_name' => 'DASHACTIVITY_SHOW_TRAFFIC'),
|
array('label' => $this->l('Show Traffic'), 'config_name' => 'DASHACTIVITY_SHOW_TRAFFIC'),
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($sub_widget as $widget)
|
foreach($sub_widget as $widget)
|
||||||
$fields_form['form']['input'][] = array(
|
$fields_form['form']['input'][] = array(
|
||||||
@@ -326,18 +331,18 @@ class Dashactivity extends Module
|
|||||||
'name' => $widget['config_name'],
|
'name' => $widget['config_name'],
|
||||||
'is_bool' => true,
|
'is_bool' => true,
|
||||||
'values' => array(
|
'values' => array(
|
||||||
array(
|
array(
|
||||||
'id' => 'active_on',
|
'id' => 'active_on',
|
||||||
'value' => 1,
|
'value' => 1,
|
||||||
'label' => $this->l('Enabled')
|
'label' => $this->l('Enabled')
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'id' => 'active_off',
|
'id' => 'active_off',
|
||||||
'value' => 0,
|
'value' => 0,
|
||||||
'label' => $this->l('Disabled')
|
'label' => $this->l('Disabled')
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
$helper = new HelperForm();
|
$helper = new HelperForm();
|
||||||
$helper->show_toolbar = false;
|
$helper->show_toolbar = false;
|
||||||
|
|||||||
@@ -8,11 +8,14 @@ function pie_chart_trends(widget_name, chart_details)
|
|||||||
.donut(true)
|
.donut(true)
|
||||||
.showLabels(false)
|
.showLabels(false)
|
||||||
.showLegend(false);
|
.showLegend(false);
|
||||||
d3.select("#dash_traffic_chart2 svg")
|
|
||||||
|
d3.select("#dash_traffic_chart2 svg")
|
||||||
.datum(chart_details.data)
|
.datum(chart_details.data)
|
||||||
.transition().duration(1200)
|
.transition().duration(1200)
|
||||||
.call(chart);
|
.call(chart);
|
||||||
|
|
||||||
nv.utils.windowResize(chart.update);
|
nv.utils.windowResize(chart.update);
|
||||||
|
|
||||||
return chart;
|
return chart;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,8 +151,17 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{if $DASHACTIVITY_SHOW_TRAFFIC}
|
{if $DASHACTIVITY_SHOW_TRAFFIC}
|
||||||
<section id="dash_traffic" class="loading">
|
<section id="dash_traffic" class="loading">
|
||||||
<header><i class="icon-globe"></i> {l s='Traffic' mod='dashactivity'} <span class="subtitle small" id="traffic-subtitle"><span></header>
|
<header>
|
||||||
|
<i class="icon-globe"></i> {l s='Traffic' mod='dashactivity'} <span class="subtitle small" id="traffic-subtitle"><span>
|
||||||
|
</header>
|
||||||
<ul class="data_list">
|
<ul class="data_list">
|
||||||
|
{if $gapi_mode}
|
||||||
|
<li>
|
||||||
|
<span class="data_label">
|
||||||
|
<a href="{$link->getAdminLink('AdminModules')}&{$gapi_mode}=gapi"><img src="../modules/gapi/logo.gif" width="16" height="16" /> {l s="Connect to Google Analytics API" mod="dashactivity"}</a>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
<li>
|
<li>
|
||||||
<span class="data_label">{l s='Visits' mod='dashactivity'}</span>
|
<span class="data_label">{l s='Visits' mod='dashactivity'}</span>
|
||||||
<span class="data_value size_md">
|
<span class="data_value size_md">
|
||||||
|
|||||||
@@ -243,16 +243,17 @@ class Dashtrends extends Module
|
|||||||
if (!$count = count($this->dashboard_data[$chart_key]))
|
if (!$count = count($this->dashboard_data[$chart_key]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// We calibrate 100% to the mean
|
||||||
$calibration = array_sum($this->dashboard_data[$chart_key]) / $count;
|
$calibration = array_sum($this->dashboard_data[$chart_key]) / $count;
|
||||||
|
|
||||||
foreach ($this->dashboard_data[$chart_key] as $key => $value)
|
foreach ($this->dashboard_data[$chart_key] as $key => $value)
|
||||||
$chart_data[$chart_key][] = array(1000 * $key, $calibration ? 100 * $value / $calibration : 0);
|
// min(10) is there to limit the growth to 1000%, beyond this limit it becomes unreadable
|
||||||
|
$chart_data[$chart_key][] = array(1000 * $key, $calibration ? min(10, $value / $calibration) : 0);
|
||||||
|
|
||||||
if ($this->dashboard_data_compare)
|
if ($this->dashboard_data_compare)
|
||||||
{
|
|
||||||
foreach ($this->dashboard_data_compare[$chart_key] as $key => $value)
|
foreach ($this->dashboard_data_compare[$chart_key] as $key => $value)
|
||||||
$chart_data_compare[$chart_key][] = array(1000 * $key, $calibration ? 100 * $value / $calibration : 0);
|
// min(10) is there to limit the growth to 1000%, beyond this limit it becomes unreadable
|
||||||
}
|
$chart_data_compare[$chart_key][] = array(1000 * $key, $calibration ? min(10, $value / $calibration) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$charts = array(
|
$charts = array(
|
||||||
|
|||||||
@@ -5,18 +5,15 @@ function line_chart_trends(widget_name, chart_details)
|
|||||||
{
|
{
|
||||||
nv.addGraph(function() {
|
nv.addGraph(function() {
|
||||||
var chart = nv.models.lineChart()
|
var chart = nv.models.lineChart()
|
||||||
.useInteractiveGuideline(true)
|
.useInteractiveGuideline(true)
|
||||||
.x(function(d) { return d[0] })
|
.x(function(d) { return (d !== undefined ? d[0] : 0); })
|
||||||
.y(function(d) { return d[1]/100 })
|
.y(function(d) { return (d !== undefined ? d[1] : 0); })
|
||||||
.color(d3.scale.category10().range());
|
|
||||||
|
|
||||||
chart.xAxis
|
chart.xAxis.tickFormat(function(d) {
|
||||||
.tickFormat(function(d) {
|
return d3.time.format('%m/%d/%y')(new Date(d))
|
||||||
return d3.time.format('%m/%d/%y')(new Date(d))
|
});
|
||||||
});
|
|
||||||
|
|
||||||
chart.yAxis
|
chart.yAxis.tickFormat(d3.format('%'));
|
||||||
.tickFormat(d3.format(',.1%'));
|
|
||||||
|
|
||||||
dashtrends_data = chart_details.data;
|
dashtrends_data = chart_details.data;
|
||||||
dashtrends_chart = chart;
|
dashtrends_chart = chart;
|
||||||
|
|||||||
Reference in new issue
Block a user