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:
authordizzy <diosmosis@users.noreply.github.com>2021-10-08 08:55:23 +0300
committerGitHub <noreply@github.com>2021-10-08 08:55:23 +0300
commit61f6b2da14fdb2c93c2106a2a6f008f4716f26ee (patch)
treebf4b58bcbdd050089cf9628c7e373434aed0c14f /plugins/CoreHome/angularjs/common
parent52caa6e3bcfe4b9d66cf42825f5523510664c53e (diff)
[Vue] Migrate ajaxHelper.ts + piwik-url service (#18104)
Diffstat (limited to 'plugins/CoreHome/angularjs/common')
-rw-r--r--plugins/CoreHome/angularjs/common/services/global-ajax-queue.js14
-rw-r--r--plugins/CoreHome/angularjs/common/services/periods.spec.js159
-rw-r--r--plugins/CoreHome/angularjs/common/services/piwik-url.js38
3 files changed, 0 insertions, 211 deletions
diff --git a/plugins/CoreHome/angularjs/common/services/global-ajax-queue.js b/plugins/CoreHome/angularjs/common/services/global-ajax-queue.js
deleted file mode 100644
index 2a216b296d..0000000000
--- a/plugins/CoreHome/angularjs/common/services/global-ajax-queue.js
+++ /dev/null
@@ -1,14 +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.service').service('globalAjaxQueue', ajaxQueue);
-
- function ajaxQueue() {
-
- return globalAjaxQueue;
- }
-})(); \ No newline at end of file
diff --git a/plugins/CoreHome/angularjs/common/services/periods.spec.js b/plugins/CoreHome/angularjs/common/services/periods.spec.js
deleted file mode 100644
index 1ae3a52106..0000000000
--- a/plugins/CoreHome/angularjs/common/services/periods.spec.js
+++ /dev/null
@@ -1,159 +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 () {
- describe('piwikPeriods', function() {
- var piwikPeriods;
-
- function clearDate(date)
- {
- var date = new Date(date);
- date.setHours(0);
- date.setMinutes(0);
- date.setSeconds(0);
- date.setMilliseconds(0);
-
- return date;
- }
-
- beforeEach(module('piwikApp.service'));
- beforeEach(inject(function($injector) {
- piwikPeriods = $injector.get('piwikPeriods');
- }));
-
- it('should get daterange for day', function() {
- var day = '2021-03-10';
-
- var result = piwikPeriods.parse('day', day).getDateRange();
- var expected = [clearDate(day), clearDate(day)];
-
- expect(result).to.eql(expected);
- });
-
- it('should get daterange for week', function() {
- var day = '2021-03-10';
- var monday = '2021-03-08';
- var sunday = '2021-03-14';
-
- var result = piwikPeriods.parse('week', day).getDateRange();
- var expected = [clearDate(monday), clearDate(sunday)];
-
- expect(result).to.eql(expected);
- });
-
- it('should get daterange for month', function() {
- var day = '2021-03-10';
- var first = '2021-03-01';
- var last = '2021-03-31';
-
- var result = piwikPeriods.parse('month', day).getDateRange();
- var expected = [clearDate(first), clearDate(last)];
-
- expect(result).to.eql(expected);
- });
-
- it('should get daterange for month for date 31th', function() {
- var day = '2021-03-31';
- var first = '2021-03-01';
- var last = '2021-03-31';
-
- var result = piwikPeriods.parse('month', day).getDateRange();
- var expected = [clearDate(first), clearDate(last)];
-
- expect(result).to.eql(expected);
- });
-
- it('should get daterange for year', function() {
- var day = '2021-03-10';
- var first = '2021-01-01';
- var last = '2021-12-31';
-
- var result = piwikPeriods.parse('year', day).getDateRange();
- var expected = [clearDate(first), clearDate(last)];
-
- expect(result).to.eql(expected);
- });
-
- it('should get daterange for year for date 31th december', function() {
- var day = '2021-12-31';
- var first = '2021-01-01';
- var last = '2021-12-31';
-
- var result = piwikPeriods.parse('year', day).getDateRange();
- var expected = [clearDate(first), clearDate(last)];
-
- expect(result).to.eql(expected);
- });
-
- it('should get proper month rangeperiod when date is 31th march', function() {
- var day = '2021-03-31';
- var first = '2021-02-01';
- var last = '2021-03-31';
-
- var result = piwikPeriods.RangePeriod.getLastNRange('month', 2, day);
-
- expect(result.startDate).to.eql(clearDate(first));
- expect(result.endDate).to.eql(clearDate(last));
- });
-
- it('should parse last month properly when date is 31th march', function() {
- originalDateNow = Date.now;
- Date.now = function() {
- return clearDate('2021-03-31').getTime();
- }
-
- var result = piwikPeriods.parseDate('last month');
-
- expect(result.getMonth()).to.eql(1); // 1 is February
-
- Date.now = originalDateNow;
- });
-
- it('should parse last month properly', function() {
- originalDateNow = Date.now;
- Date.now = function() {
- return clearDate('2021-03-10').getTime();
- };
-
- var result = piwikPeriods.parseDate('last month');
-
- expect(result.getMonth()).to.eql(1); // 1 is February
-
- Date.now = originalDateNow;
- });
-
- it('should contains today for daterange if it contains', function() {
- var day = '2021-03-10';
-
- originalDateNow = Date.now;
- Date.now = function() {
- return clearDate(day).getTime();
- };
-
- var result = piwikPeriods.parse('week', day).containsToday();
-
- expect(result).to.be.true;
-
- Date.now = originalDateNow;
- });
-
- it('should not contains today for daterange if it not contains', function() {
- var today = '2021-03-10';
- var day = '2021-03-17';
-
- originalDateNow = Date.now;
- Date.now = function() {
- return clearDate(today).getTime();
- };
-
- var result = piwikPeriods.parse('week', day).containsToday();
-
- expect(result).to.be.false;
-
- Date.now = originalDateNow;
- });
- });
-})();
diff --git a/plugins/CoreHome/angularjs/common/services/piwik-url.js b/plugins/CoreHome/angularjs/common/services/piwik-url.js
deleted file mode 100644
index 3743bf0d62..0000000000
--- a/plugins/CoreHome/angularjs/common/services/piwik-url.js
+++ /dev/null
@@ -1,38 +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.service').service('piwikUrl', piwikUrl);
-
- piwikUrl.$inject = ['$location', '$window'];
-
- /**
- * Similar to angulars $location but works around some limitation. Use it if you need to access search params
- */
- function piwikUrl($location, $window) {
-
- var model = {
- getSearchParam: getSearchParam
- };
-
- return model;
-
- function getSearchParam(paramName)
- {
- var hash = $window.location.href.split('#');
- if (hash && hash[1] && (new RegExp(paramName + '(\\[]|=)')).test(decodeURIComponent(hash[1]))) {
- var valueFromHash = broadcast.getValueFromHash(paramName, $window.location.href);
-
- // for date, period and idsite fall back to parameter from url, if non in hash was provided
- if (valueFromHash || (paramName !== 'date' && paramName !== 'period' && paramName !== 'idSite')) {
- return valueFromHash;
- }
-
- }
- return broadcast.getValueFromUrl(paramName, $window.location.search);
- }
- }
-})();