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:
Diffstat (limited to 'plugins/CoreHome/angularjs/reporting-page')
-rw-r--r--plugins/CoreHome/angularjs/reporting-page/reportingpage-model.js173
-rw-r--r--plugins/CoreHome/angularjs/reporting-page/reportingpage.controller.js245
-rw-r--r--plugins/CoreHome/angularjs/reporting-page/reportingpage.directive.html17
-rw-r--r--plugins/CoreHome/angularjs/reporting-page/reportingpage.directive.js31
-rw-r--r--plugins/CoreHome/angularjs/reporting-page/reportingpage.directive.less24
5 files changed, 0 insertions, 490 deletions
diff --git a/plugins/CoreHome/angularjs/reporting-page/reportingpage-model.js b/plugins/CoreHome/angularjs/reporting-page/reportingpage-model.js
deleted file mode 100644
index e91b5053a7..0000000000
--- a/plugins/CoreHome/angularjs/reporting-page/reportingpage-model.js
+++ /dev/null
@@ -1,173 +0,0 @@
-/*!
- * Matomo - free/libre analytics platform
- *
- * @link https://matomo.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- */
-(function () {
- angular.module('piwikApp').factory('reportingPageModel', reportingPageModelService);
-
- reportingPageModelService.$inject = ['$filter', 'reportingPagesModel', 'reportMetadataModel'];
-
- function reportingPageModelService ($filter, reportingPagesModel, reportMetadataModel) {
- // those sites are going to be displayed
- var model = {
- fetchPage: fetchPage,
- resetPage: resetPage,
- widgets: [],
- page: null,
- };
-
- return model;
-
- function resetPage()
- {
- model.page = null;
- model.widgets = [];
- }
-
- function sortWidgets(widgets)
- {
- return $filter('orderBy')(widgets, 'order');
- }
-
- function shouldBeRenderedWithFullWidth(widget)
- {
- // rather controller logic
- if ((widget.isContainer && widget.layout && widget.layout === 'ByDimension')
- || widget.viewDataTable === 'bydimension') {
- return true;
- }
-
- if ('undefined' !== typeof widget.isWide && widget.isWide) {
- return true;
- }
-
- return widget.viewDataTable && (widget.viewDataTable === 'tableAllColumns' || widget.viewDataTable === 'sparklines' || widget.viewDataTable === 'graphEvolution');
- }
-
- function buildPage(page)
- {
- if (!page) {
- return;
- }
-
- var widgets = [];
- var reportsToIgnore = [];
-
- angular.forEach(page.widgets, function (widget) {
-
- if (isIgnoredReport(reportsToIgnore, widget)) {
- return;
- }
-
- reportsToIgnore = reportsToIgnore.concat(getRelatedReports(widget));
-
- widgets.push(widget);
- });
-
- widgets = sortWidgets(widgets);
-
- var groupedWidgets = [];
-
- if (widgets.length === 1) {
- // if there is only one widget, we always display it full width
- groupedWidgets = widgets;
- } else {
- for (var i = 0; i < widgets.length; i++) {
- var widget = widgets[i];
-
- if (shouldBeRenderedWithFullWidth(widget) || (widgets[i+1] && shouldBeRenderedWithFullWidth(widgets[i+1]))) {
- widget.widgets = sortWidgets(widget.widgets);
-
- groupedWidgets.push(widget);
- } else {
-
- var counter = 0;
- var left = [widget];
- var right = [];
-
- while (widgets[i+1] && !shouldBeRenderedWithFullWidth(widgets[i+1])) {
- i++;
- counter++;
- if (counter % 2 === 0) {
- left.push(widgets[i]);
- } else {
- right.push(widgets[i]);
- }
- }
-
- groupedWidgets.push({group: true, left: left, right: right});
- }
- }
- }
-
- var copyWidgets = angular.copy(groupedWidgets);
- copyWidgets = markWidgetsInFirstRowOfPage(copyWidgets);
-
- // angular.copy forces the page to re-render. Otherwise it won't reload some pages
- model.widgets = copyWidgets;
- }
-
- function markWidgetsInFirstRowOfPage(widgets)
- {
- if (widgets && widgets[0]) {
- if (widgets[0].group) {
- markWidgetsInFirstRowOfPage(widgets[0].left);
- markWidgetsInFirstRowOfPage(widgets[0].right);
- } else {
- widgets[0].isFirstInPage = true;
- }
- }
-
- return widgets;
- }
-
- function getRelatedReports(widget)
- {
- if (widget.isReport) {
- var report = reportMetadataModel.findReport(widget.module, widget.action);
-
- if (report && report.relatedReports) {
- return report.relatedReports;
- }
- }
-
- return [];
- }
-
- function isIgnoredReport(reportsToIgnore, widget)
- {
- var found = false;
-
- if (widget.isReport) {
- angular.forEach(reportsToIgnore, function (report) {
- if (report.module === widget.module &&
- report.action === widget.action) {
- found = true;
- }
- });
- }
-
- return found;
- }
-
- function fetchPage(category, subcategory)
- {
- resetPage();
-
- var pagesPromise = reportingPagesModel.getAllPages();
- var reportsPromise = reportMetadataModel.fetchReportMetadata();
-
- return pagesPromise.then(function () {
- model.page = reportingPagesModel.findPage(category, subcategory);
-
- reportsPromise.then(function () {
- buildPage(model.page);
- });
-
- return model.page;
- });
- }
- }
-})();
diff --git a/plugins/CoreHome/angularjs/reporting-page/reportingpage.controller.js b/plugins/CoreHome/angularjs/reporting-page/reportingpage.controller.js
deleted file mode 100644
index 4fac133741..0000000000
--- a/plugins/CoreHome/angularjs/reporting-page/reportingpage.controller.js
+++ /dev/null
@@ -1,245 +0,0 @@
-/*!
- * Matomo - free/libre analytics platform
- *
- * @link https://matomo.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- */
-(function () {
- angular.module('piwikApp').controller('ReportingPageController', ReportingPageController);
-
- ReportingPageController.$inject = ['$scope', 'piwik', '$rootScope', '$location', 'reportingPageModel', 'reportingPagesModel', 'notifications', 'piwikUrl', 'piwikPeriods', 'piwikApi'];
-
- function ReportingPageController($scope, piwik, $rootScope, $location, pageModel, pagesModel, notifications, piwikUrl, $piwikPeriods, piwikApi) {
- pageModel.resetPage();
- $scope.pageModel = pageModel;
-
- var currentCategory = null;
- var currentSubcategory = null;
- var currentPeriod = null;
- var currentDate = null;
- var currentSegment = null;
-
- var currentCompareDates = null;
- var currentComparePeriods = null;
- var currentCompareSegments = null;
-
- var hasRawData = false;
- var hasNoVisits = false;
- var dateLastChecked = null;
-
- var UI = require('piwik/UI');
- var notification = new UI.Notification();
-
- function renderInitialPage()
- {
- var $search = $location.search();
- currentPeriod = piwikUrl.getSearchParam('period');
- currentDate = piwikUrl.getSearchParam('date');
- currentSegment = $search.segment;
- currentCompareSegments = piwikUrl.getSearchParam('compareSegments');
- currentCompareDates = piwikUrl.getSearchParam('compareDates');
- currentComparePeriods = piwikUrl.getSearchParam('comparePeriods');
- $scope.renderPage($search.category, $search.subcategory);
- }
-
- function showOnlyRawDataNotification() {
- var attributes = {};
- attributes.id = 'onlyRawData';
- attributes.animate = false;
- attributes.context = 'info';
- var url = broadcast.buildReportingUrl('category=General_Visitors&subcategory=Live_VisitorLog')
- var message = _pk_translate('CoreHome_PeriodHasOnlyRawData', ['<a href="' + url + '">', '</a>']);
- notification.show(message, attributes);
- }
-
- function hideOnlyRawDataNoticifation() {
- notification.remove('onlyRawData');
- }
-
- function showOnlyRawDataMessageIfRequired() {
- if (hasRawData && hasNoVisits) {
- showOnlyRawDataNotification();
- }
-
- var $search = $location.search();
-
- if ($search.segment) {
- hideOnlyRawDataNoticifation();
- return;
- }
-
- var subcategoryExceptions = [
- 'Live_VisitorLog',
- 'General_RealTime',
- 'UserCountryMap_RealTimeMap',
- 'MediaAnalytics_TypeAudienceLog',
- 'MediaAnalytics_TypeRealTime',
- 'FormAnalytics_TypeRealTime',
- 'Goals_AddNewGoal',
- ];
-
- var categoryExceptions = [
- 'HeatmapSessionRecording_Heatmaps',
- 'HeatmapSessionRecording_SessionRecordings',
- 'Marketplace_Marketplace',
- ];
-
- if (subcategoryExceptions.indexOf($search.subcategory) !== -1 || categoryExceptions.indexOf($search.category) !== -1 || $search.subcategory.toLowerCase().indexOf('manage') !== -1) {
- hideOnlyRawDataNoticifation();
- return;
- }
-
- var minuteInMilliseconds = 60000;
- if (dateLastChecked && (new Date().getTime() - dateLastChecked) < minuteInMilliseconds) {
- return;
- }
-
- piwikApi.fetch({ method: 'VisitsSummary.getVisits' }).then(function (json) {
- dateLastChecked = new Date().getTime();
-
- if (json.value > 0) {
- hasNoVisits = false;
- hideOnlyRawDataNoticifation();
- return;
- }
-
- hasNoVisits = true;
-
- if (hasRawData) {
- showOnlyRawDataNotification();
- return;
- }
-
- piwikApi.fetch({ method: 'Live.getLastVisitsDetails', filter_limit: 1, doNotFetchActions: 1 }).then(function (json) {
- if (json.length == 0) {
- hasRawData = false;
- hideOnlyRawDataNoticifation();
- return;
- }
-
- hasRawData = true;
- showOnlyRawDataNotification();
- });
- });
- }
-
- $scope.renderPage = function (category, subcategory) {
- if (!category || !subcategory) {
- pageModel.resetPage();
- $scope.loading = false;
- return;
- }
-
- try {
- $piwikPeriods.parse(currentPeriod, currentDate);
- } catch (e) {
- var attributes = {};
- attributes.id = 'invalidDate';
- attributes.animate = false;
- attributes.context = 'error';
- notification.show(_pk_translate('CoreHome_DateInvalid'), attributes);
-
- pageModel.resetPage();
- $scope.loading = false;
- return;
- }
-
- notification.remove('invalidDate');
-
- $rootScope.$emit('piwikPageChange', {});
-
- currentCategory = category;
- currentSubcategory = subcategory;
-
- notifications.clearTransientNotifications();
-
- if ($piwikPeriods.parse(currentPeriod, currentDate).containsToday()) {
- showOnlyRawDataMessageIfRequired();
- }
-
- if (category === 'Dashboard_Dashboard' && $.isNumeric(subcategory) && $('[piwik-dashboard]').length) {
- // hack to make loading of dashboards faster since all the information is already there in the
- // piwik-dashboard widget, we can let the piwik-dashboard widget render the page. We need to find
- // a proper solution for this. A workaround for now could be an event or something to let other
- // components render a specific page.
- $scope.loading = true;
- var element = $('[piwik-dashboard]');
- var scope = angular.element(element).scope();
- scope.fetchDashboard(parseInt(subcategory, 10)).then(function () {
- $scope.loading = false;
- }, function () {
- $scope.loading = false;
- });
- return;
- }
-
- pageModel.fetchPage(category, subcategory).then(function () {
- if (!pageModel.page) {
- var page = pagesModel.findPageInCategory(category);
- if (page && page.subcategory) {
- var $search = $location.search();
- $search.subcategory = page.subcategory.id;
- $location.search($search);
- return;
- }
- }
-
- $scope.hasNoPage = !pageModel.page;
- $scope.loading = false;
- });
- };
-
- $scope.loading = true; // we only set loading on initial load
-
- renderInitialPage();
-
- $rootScope.$on('$locationChangeSuccess', function () {
- var $search = $location.search();
-
- // should be handled by $route
- var category = $search.category;
- var subcategory = $search.subcategory;
- var period = piwikUrl.getSearchParam('period');
- var date = piwikUrl.getSearchParam('date');
- var segment = $search.segment;
-
- // $location does not handle array parameters properly
- var compareSegments = piwikUrl.getSearchParam('compareSegments');
- var compareDates = piwikUrl.getSearchParam('compareDates');
- var comparePeriods = piwikUrl.getSearchParam('comparePeriods');
-
- if (category === currentCategory
- && subcategory === currentSubcategory
- && period === currentPeriod
- && date === currentDate
- && segment === currentSegment
- && JSON.stringify(compareDates) === JSON.stringify(currentCompareDates)
- && JSON.stringify(comparePeriods) === JSON.stringify(currentComparePeriods)
- && JSON.stringify(compareSegments) === JSON.stringify(currentCompareSegments)
- ) {
- // this page is already loaded
- return;
- }
-
- if (date !== currentDate || period !== currentPeriod) {
- hideOnlyRawDataNoticifation();
- dateLastChecked = null;
- hasRawData = false;
- hasNoVisits = false;
- }
-
- currentPeriod = period;
- currentDate = date;
- currentSegment = segment;
- currentCompareDates = compareDates;
- currentComparePeriods = comparePeriods;
- currentCompareSegments = compareSegments;
-
- $scope.renderPage(category, subcategory);
- });
-
- $rootScope.$on('loadPage', function (event, category, subcategory) {
- $scope.renderPage(category, subcategory);
- });
- }
-})();
diff --git a/plugins/CoreHome/angularjs/reporting-page/reportingpage.directive.html b/plugins/CoreHome/angularjs/reporting-page/reportingpage.directive.html
deleted file mode 100644
index 4abf3a27e2..0000000000
--- a/plugins/CoreHome/angularjs/reporting-page/reportingpage.directive.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<div class="reporting-page">
-
- <div piwik-activity-indicator loading="loading"></div>
-
- <div ng-show="hasNoPage">{{ 'CoreHome_NoSuchPage'|translate }}</div>
-
- <div class="row" ng-repeat="widget in pageModel.widgets">
- <div class="col s12 fullWidgetColumn" ng-if="!widget.group" piwik-widget="widget"></div>
-
- <div ng-if="widget.group" class="col s12 l6 leftWidgetColumn">
- <div ng-repeat="widgetInGroup in widget.left" piwik-widget="widgetInGroup"></div>
- </div>
- <div ng-if="widget.group" class="col s12 l6 rightWidgetColumn">
- <div ng-repeat="widgetInGroup in widget.right" piwik-widget="widgetInGroup"></div>
- </div>
- </div>
-</div>
diff --git a/plugins/CoreHome/angularjs/reporting-page/reportingpage.directive.js b/plugins/CoreHome/angularjs/reporting-page/reportingpage.directive.js
deleted file mode 100644
index 375bd071db..0000000000
--- a/plugins/CoreHome/angularjs/reporting-page/reportingpage.directive.js
+++ /dev/null
@@ -1,31 +0,0 @@
-/*!
- * Matomo - free/libre analytics platform
- *
- * @link https://matomo.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- */
-
-/**
- * Shows a piwik reporting page.
- *
- * The content to be displayed is automatically loaded via API based on the current URL. The URL parameters
- * 'category' and 'subcategory' need to be present in the URL in order to see something in the reporting page.
- *
- * Example:
- * <div piwik-reporting-page></div>
- */
-(function () {
- angular.module('piwikApp').directive('piwikReportingPage', piwikReportingPage);
-
- piwikReportingPage.$inject = ['piwik'];
-
- function piwikReportingPage(piwik){
-
- return {
- restrict: 'A',
- scope: {},
- templateUrl: 'plugins/CoreHome/angularjs/reporting-page/reportingpage.directive.html?cb=' + piwik.cacheBuster,
- controller: 'ReportingPageController'
- };
- }
-})(); \ No newline at end of file
diff --git a/plugins/CoreHome/angularjs/reporting-page/reportingpage.directive.less b/plugins/CoreHome/angularjs/reporting-page/reportingpage.directive.less
deleted file mode 100644
index 1d9fde17b9..0000000000
--- a/plugins/CoreHome/angularjs/reporting-page/reportingpage.directive.less
+++ /dev/null
@@ -1,24 +0,0 @@
-.reporting-page {
- > .row {
- margin-bottom: 0;
- }
-
- .fullWidgetColumn {
- padding-left: 0;
- padding-right: 0;
- }
-
- .leftWidgetColumn {
- padding-left: 0;
- }
-
- .rightWidgetColumn {
- padding-right: 0;
- }
-
- .isFirstWidgetInPage {
- .card {
- margin-top: 0;
- }
- }
-} \ No newline at end of file