Skip to content

Commit

Permalink
convert sparkline api to one request - fixes archive (#18493)
Browse files Browse the repository at this point in the history
* update lock

update lock

* update sparkline

update sparkline

* Update getSparklines.twig

update title link

* Update Pages.php

add comments

* update loader

update loader

* update template

update template

* update to visualise

update to visualise

* Update Controller.php

update controller

* revert lock

revert lock

* update matrix

update matrix

* update config title

update config title

* Delete getSparklines.twig

remove template

* Update Pages.php

remove mutilple

* us getMetrics

us getMetrics

* update tests

update tests

* Update plugins/Goals/Controller.php

Co-authored-by: Ben Burgess <88810029+bx80@users.noreply.github.com>

* Update plugins/Goals/Pages.php

Co-authored-by: Ben Burgess <88810029+bx80@users.noreply.github.com>

* built vue files

* Update CoreHome.umd.min.js

update umd js

* update goal remove revenue sparklin

update goal remove revenue sparkline

* remove hide extra columns

remove hide extra columns

* update graphic

update graphic

* update remove goal in the settings

update remove goal in the settings

* Update GoalsPages_overview.png

update screenshot

* Update plugins/Goals/Controller.php

Co-authored-by: Stefan Giehl <stefan@matomo.org>

* Update plugins/Goals/Controller.php

Co-authored-by: Stefan Giehl <stefan@matomo.org>

* remove check actions and remove foreach loop on goals

remove check actions and remove foreach loop on goals

* Update plugins/Goals/Controller.php

Co-authored-by: Stefan Giehl <stefan@matomo.org>

Co-authored-by: Ben Burgess <88810029+bx80@users.noreply.github.com>
Co-authored-by: peterhashair <peterhashair@users.noreply.github.com>
Co-authored-by: sgiehl <stefan@matomo.org>
  • Loading branch information
4 people committed Dec 19, 2021
1 parent 946c3cd commit 36f83c1
Show file tree
Hide file tree
Showing 8 changed files with 769 additions and 879 deletions.
2 changes: 1 addition & 1 deletion plugins/Goals/API.php
Expand Up @@ -67,7 +67,7 @@ class API extends \Piwik\Plugin\API
public function getGoal($idSite, $idGoal)
{
Piwik::checkUserHasViewAccess($idSite);

$goal = $this->getModel()->getActiveGoal($idSite, $idGoal);

if (!empty($goal)) {
Expand Down
27 changes: 27 additions & 0 deletions plugins/Goals/Controller.php
Expand Up @@ -8,6 +8,7 @@
*/
namespace Piwik\Plugins\Goals;

use Piwik\API\Proxy;
use Piwik\API\Request;
use Piwik\Common;
use Piwik\DataTable;
Expand All @@ -16,10 +17,13 @@
use Piwik\FrontController;
use Piwik\Piwik;
use Piwik\Plugin\Manager;
use Piwik\Plugin\ViewDataTable;
use Piwik\Plugins\CoreVisualizations\Visualizations\Sparklines;
use Piwik\Plugins\Live\Live;
use Piwik\Plugins\Referrers\API as APIReferrers;
use Piwik\Translation\Translator;
use Piwik\View;
use Piwik\ViewDataTable\Factory as ViewDataTableFactory;

/**
*
Expand Down Expand Up @@ -219,6 +223,29 @@ public function getEvolutionGraph(array $columns = array(), $idGoal = false, arr
return $this->renderView($view);
}

public function getSparklines()
{
$content = "";
$goals = Request::processRequest('Goals.getGoals', ['idSite' => $this->idSite, 'filter_limit' => '-1'], []);

foreach ($goals as $goal) {
$params = [
'idGoal' => $goal['idgoal'],
'allow_multiple' => (int) $goal['allow_multiple'],
'only_summary' => 1,
];

\Piwik\Context::executeWithQueryParameters($params, function() use (&$content) {
//load Visualisations Sparkline
$view = ViewDataTableFactory::build(Sparklines::ID, 'Goals.getMetrics', 'Goals.' . __METHOD__, true);
$view->config->show_title = true;
$content .= $view->render();
});
}

return $content;
}

private function getColumnTranslation($nameToLabel, $columnName, $idGoal)
{
$columnTranslation = '';
Expand Down
23 changes: 9 additions & 14 deletions plugins/Goals/Pages.php
Expand Up @@ -54,23 +54,18 @@ public function createGoalsOverviewPage($goals)
$config->setSubcategoryId($subcategory);
$config->setName('');
$config->setOrder(15);
$config->setModule('Goals');
$config->setAction('getMetrics');
$config->setIsNotWidgetizable();
$widgets[] = $config;

foreach ($goals as $goal) {
$name = Common::sanitizeInputValue($goal['name']);
$goalTranslated = Piwik::translate('Goals_GoalX', array($name));

$config = $this->factory->createWidget();
$config->setName($goalTranslated);
$config->setSubcategoryId($subcategory);
$config->forceViewDataTable(Sparklines::ID);
$config->setParameters(array('idGoal' => $goal['idgoal']));
$config->setOrder(25);
$config->setIsNotWidgetizable();
$config->addParameters(array('allow_multiple' => (int) $goal['allow_multiple'], 'only_summary' => '1'));
$widgets[] = $config;
}
// load sparkline
$config = $this->factory->createCustomWidget('getSparklines');
$config->setSubcategoryId($subcategory);
$config->setName('');
$config->setOrder(25);
$config->setIsNotWidgetizable();
$widgets[] = $config;

$container = $this->createWidgetizableWidgetContainer('GoalsOverview', $subcategory, $widgets);

Expand Down
4 changes: 2 additions & 2 deletions plugins/Goals/Reports/Get.php
Expand Up @@ -66,7 +66,7 @@ public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $
if (empty($idSite)) {
return;
}

$goals = $this->getGoals();
$reports = Goals::getReportsWithGoalMetrics();

Expand Down Expand Up @@ -193,7 +193,7 @@ public function configureView(ViewDataTable $view)
} else {
$view->config->title = Piwik::translate('General_EvolutionOverPeriod');
}

if (empty($view->config->columns_to_display)) {
$view->config->columns_to_display = array('nb_conversions');
}
Expand Down
8 changes: 7 additions & 1 deletion plugins/Goals/Reports/GetMetrics.php
Expand Up @@ -10,8 +10,10 @@

use Piwik\Piwik;
use Piwik\Plugins\CoreHome\Columns\Metrics\ConversionRate;
use Piwik\Report\ReportWidgetFactory;
use Piwik\Widget\WidgetsList;

class GetMetrics extends Base
class GetMetrics extends Get
{
protected function init()
{
Expand All @@ -26,6 +28,10 @@ protected function init()
$this->parameters = null;
}

public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory)
{
}

public function configureReportMetadata(&$availableReports, $infos)
{
}
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 36f83c1

Please sign in to comment.