// dashboard improvements
This commit is contained in:
@@ -76,7 +76,15 @@ class Dashactivity extends Module
|
||||
|
||||
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(
|
||||
'gapi_mode' => $gapi_mode,
|
||||
'dashactivity_config_form' => $this->renderConfigForm(),
|
||||
'date_subtitle' => $this->l('from %s to %s'),
|
||||
'date_format' => $this->context->language->date_format_lite
|
||||
@@ -265,17 +273,15 @@ class Dashactivity extends Module
|
||||
else
|
||||
{
|
||||
$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);
|
||||
|
||||
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']))
|
||||
++$websites[$directLink];
|
||||
@@ -299,17 +305,16 @@ class Dashactivity extends Module
|
||||
'form' => array(
|
||||
'id_form' => 'step_carrier_general',
|
||||
'input' => array(),
|
||||
'submit' =>
|
||||
array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'btn btn-default submit_dash_config',
|
||||
'reset' => array(
|
||||
'title' => $this->l('Cancel'),
|
||||
'class' => 'btn btn-default cancel_dash_config',
|
||||
)
|
||||
'submit' => array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'btn btn-default submit_dash_config',
|
||||
'reset' => array(
|
||||
'title' => $this->l('Cancel'),
|
||||
'class' => 'btn btn-default cancel_dash_config',
|
||||
)
|
||||
),
|
||||
);
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
$sub_widget = array(
|
||||
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 Newsletters'), 'config_name' => 'DASHACTIVITY_SHOW_NEWSLETTER'),
|
||||
array('label' => $this->l('Show Traffic'), 'config_name' => 'DASHACTIVITY_SHOW_TRAFFIC'),
|
||||
);
|
||||
);
|
||||
|
||||
foreach($sub_widget as $widget)
|
||||
$fields_form['form']['input'][] = array(
|
||||
@@ -326,18 +331,18 @@ class Dashactivity extends Module
|
||||
'name' => $widget['config_name'],
|
||||
'is_bool' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'active_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'active_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
);
|
||||
array(
|
||||
'id' => 'active_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'active_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
$helper = new HelperForm();
|
||||
$helper->show_toolbar = false;
|
||||
|
||||
@@ -8,11 +8,14 @@ function pie_chart_trends(widget_name, chart_details)
|
||||
.donut(true)
|
||||
.showLabels(false)
|
||||
.showLegend(false);
|
||||
d3.select("#dash_traffic_chart2 svg")
|
||||
|
||||
d3.select("#dash_traffic_chart2 svg")
|
||||
.datum(chart_details.data)
|
||||
.transition().duration(1200)
|
||||
.call(chart);
|
||||
|
||||
nv.utils.windowResize(chart.update);
|
||||
|
||||
return chart;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -151,8 +151,17 @@
|
||||
{/if}
|
||||
{if $DASHACTIVITY_SHOW_TRAFFIC}
|
||||
<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">
|
||||
{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>
|
||||
<span class="data_label">{l s='Visits' mod='dashactivity'}</span>
|
||||
<span class="data_value size_md">
|
||||
|
||||
@@ -243,16 +243,17 @@ class Dashtrends extends Module
|
||||
if (!$count = count($this->dashboard_data[$chart_key]))
|
||||
continue;
|
||||
|
||||
// We calibrate 100% to the mean
|
||||
$calibration = array_sum($this->dashboard_data[$chart_key]) / $count;
|
||||
|
||||
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)
|
||||
{
|
||||
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(
|
||||
|
||||
@@ -5,18 +5,15 @@ function line_chart_trends(widget_name, chart_details)
|
||||
{
|
||||
nv.addGraph(function() {
|
||||
var chart = nv.models.lineChart()
|
||||
.useInteractiveGuideline(true)
|
||||
.x(function(d) { return d[0] })
|
||||
.y(function(d) { return d[1]/100 })
|
||||
.color(d3.scale.category10().range());
|
||||
.useInteractiveGuideline(true)
|
||||
.x(function(d) { return (d !== undefined ? d[0] : 0); })
|
||||
.y(function(d) { return (d !== undefined ? d[1] : 0); })
|
||||
|
||||
chart.xAxis
|
||||
.tickFormat(function(d) {
|
||||
return d3.time.format('%m/%d/%y')(new Date(d))
|
||||
});
|
||||
chart.xAxis.tickFormat(function(d) {
|
||||
return d3.time.format('%m/%d/%y')(new Date(d))
|
||||
});
|
||||
|
||||
chart.yAxis
|
||||
.tickFormat(d3.format(',.1%'));
|
||||
chart.yAxis.tickFormat(d3.format('%'));
|
||||
|
||||
dashtrends_data = chart_details.data;
|
||||
dashtrends_chart = chart;
|
||||
|
||||
Reference in New Issue
Block a user