Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zhang <peter@innocraft.com>2021-12-19 15:39:39 +0300
committerGitHub <noreply@github.com>2021-12-19 15:39:39 +0300
commit36f83c1468d3ba7bb74a1a755c804f4df21ad78e (patch)
tree6e2c099110acadf17f34c80027eb67c1c82ec6c1 /plugins/Goals
parent946c3cd2e4b578485001bb3a2a049de2a2a9fe3d (diff)
convert sparkline api to one request - fixes archive (#18493)
* 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>
Diffstat (limited to 'plugins/Goals')
-rw-r--r--plugins/Goals/API.php2
-rw-r--r--plugins/Goals/Controller.php27
-rw-r--r--plugins/Goals/Pages.php23
-rw-r--r--plugins/Goals/Reports/Get.php4
-rw-r--r--plugins/Goals/Reports/GetMetrics.php8
-rw-r--r--plugins/Goals/tests/UI/expected-screenshots/GoalsPages_overview.png4
6 files changed, 48 insertions, 20 deletions
diff --git a/plugins/Goals/API.php b/plugins/Goals/API.php
index ba67f6aa1d..fe69afa1ce 100644
--- a/plugins/Goals/API.php
+++ b/plugins/Goals/API.php
@@ -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)) {
diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php
index 02f8ee5c9e..fd7ddc109a 100644
--- a/plugins/Goals/Controller.php
+++ b/plugins/Goals/Controller.php
@@ -8,6 +8,7 @@
*/
namespace Piwik\Plugins\Goals;
+use Piwik\API\Proxy;
use Piwik\API\Request;
use Piwik\Common;
use Piwik\DataTable;
@@ -16,10 +17,13 @@ use Piwik\DataTable\Filter\AddColumnsProcessedMetricsGoal;
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;
/**
*
@@ -219,6 +223,29 @@ class Controller extends \Piwik\Plugin\Controller
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 = '';
diff --git a/plugins/Goals/Pages.php b/plugins/Goals/Pages.php
index 6b105bfb9a..59ebb7b19d 100644
--- a/plugins/Goals/Pages.php
+++ b/plugins/Goals/Pages.php
@@ -54,23 +54,18 @@ class Pages
$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);
diff --git a/plugins/Goals/Reports/Get.php b/plugins/Goals/Reports/Get.php
index c29bdf4426..445f6fd1cc 100644
--- a/plugins/Goals/Reports/Get.php
+++ b/plugins/Goals/Reports/Get.php
@@ -66,7 +66,7 @@ class Get extends Base
if (empty($idSite)) {
return;
}
-
+
$goals = $this->getGoals();
$reports = Goals::getReportsWithGoalMetrics();
@@ -193,7 +193,7 @@ class Get extends Base
} else {
$view->config->title = Piwik::translate('General_EvolutionOverPeriod');
}
-
+
if (empty($view->config->columns_to_display)) {
$view->config->columns_to_display = array('nb_conversions');
}
diff --git a/plugins/Goals/Reports/GetMetrics.php b/plugins/Goals/Reports/GetMetrics.php
index 32cb019800..bf2d1c3ac8 100644
--- a/plugins/Goals/Reports/GetMetrics.php
+++ b/plugins/Goals/Reports/GetMetrics.php
@@ -10,8 +10,10 @@ namespace Piwik\Plugins\Goals\Reports;
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()
{
@@ -26,6 +28,10 @@ class GetMetrics extends Base
$this->parameters = null;
}
+ public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory)
+ {
+ }
+
public function configureReportMetadata(&$availableReports, $infos)
{
}
diff --git a/plugins/Goals/tests/UI/expected-screenshots/GoalsPages_overview.png b/plugins/Goals/tests/UI/expected-screenshots/GoalsPages_overview.png
index 9addb5c878..500b46f795 100644
--- a/plugins/Goals/tests/UI/expected-screenshots/GoalsPages_overview.png
+++ b/plugins/Goals/tests/UI/expected-screenshots/GoalsPages_overview.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:47f4954791162c63495b422e2bbf6eef330cd819ecb3f4490d0edc7dc7b9cbca
-size 164421
+oid sha256:d67025f70426ce81442c1fd0fc4ed2da51d0209fb4882863dc2b21009efa2d46
+size 163865