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-10 02:36:08 +0300
committerGitHub <noreply@github.com>2021-12-10 02:36:08 +0300
commit35bcf9c94b6c652f677b9b7b148498a23919be22 (patch)
tree8d7ba666fdb250f3ae888be5e749b3c237ed6989 /plugins/Goals/Controller.php
parentcfb9a81f1bf761ee7ff9ef70749c46021c4471c1 (diff)
convert sparkline api to one request - fixes archive (#18399)
* 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 Co-authored-by: Ben Burgess <88810029+bx80@users.noreply.github.com> Co-authored-by: peterhashair <peterhashair@users.noreply.github.com>
Diffstat (limited to 'plugins/Goals/Controller.php')
-rw-r--r--plugins/Goals/Controller.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php
index 02f8ee5c9e..705c5aab3a 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,37 @@ class Controller extends \Piwik\Plugin\Controller
return $this->renderView($view);
}
+ public function getSparklines()
+ {
+ $module = "Goals";
+ $action = "getMetrics";
+ $content = "";
+
+ $idSite = Common::getRequestVar('idSite', null, 'int');
+ $goals = Request::processRequest('Goals.getGoals', ['idSite' => $idSite, 'filter_limit' => '-1'], []);
+
+ $apiProxy = Proxy::getInstance();
+ $queryString = $_SERVER['QUERY_STRING'];
+ if (!$apiProxy->isExistingApiAction($module, $action)) {
+ throw new \Exception("Invalid action name '$action' for '$module' plugin.");
+ }
+
+ $apiAction = $apiProxy->buildApiActionName($module, $action);
+ foreach ($goals as $goal) {
+ //load Visualisations Sparkline
+ $view = ViewDataTableFactory::build(Sparklines::ID, $apiAction, 'Goals.' . __METHOD__, true);
+ $view->requestConfig->request_parameters_to_modify['idGoal'] = $goal['idgoal'];
+ $view->requestConfig->request_parameters_to_modify['allow_multiple'] = (int)$goal['allow_multiple'];
+ $view->requestConfig->request_parameters_to_modify['only_summary'] = 1;
+ $view->config->show_title = true;
+ $_SERVER['QUERY_STRING'] .= $queryString . '&idGoal='. $goal['idgoal'];
+ $view->config->title = $goal['name'];
+ $content .= $view->render();
+ }
+
+ return $content;
+ }
+
private function getColumnTranslation($nameToLabel, $columnName, $idGoal)
{
$columnTranslation = '';