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/vue/src/AjaxHelper/AjaxHelper.ts')
-rw-r--r--plugins/CoreHome/vue/src/AjaxHelper/AjaxHelper.ts37
1 files changed, 23 insertions, 14 deletions
diff --git a/plugins/CoreHome/vue/src/AjaxHelper/AjaxHelper.ts b/plugins/CoreHome/vue/src/AjaxHelper/AjaxHelper.ts
index 788f3a8f45..c4e61b2ad5 100644
--- a/plugins/CoreHome/vue/src/AjaxHelper/AjaxHelper.ts
+++ b/plugins/CoreHome/vue/src/AjaxHelper/AjaxHelper.ts
@@ -5,7 +5,8 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-import PiwikUrl from '../PiwikUrl/PiwikUrl';
+import MatomoUrl from '../MatomoUrl/MatomoUrl';
+import Matomo from '../Matomo/Matomo';
window.globalAjaxQueue = [] as GlobalAjaxQueue;
window.globalAjaxQueue.active = 0;
@@ -62,7 +63,7 @@ function defaultErrorCallback(deferred: XMLHttpRequest, status: string): void {
}
/**
- * Global ajax helper to handle requests within piwik
+ * Global ajax helper to handle requests within Matomo
*/
export default class AjaxHelper {
/**
@@ -87,6 +88,8 @@ export default class AjaxHelper {
/**
* Callback function to be executed on error
+ *
+ * @deprecated use the jquery promise API
*/
errorCallback: AnyFunction;
@@ -94,6 +97,8 @@ export default class AjaxHelper {
/**
* Callback function to be executed on complete (after error or success)
+ *
+ * @deprecated use the jquery promise API
*/
completeCallback: AnyFunction;
@@ -212,6 +217,7 @@ export default class AjaxHelper {
* Sets the callback called after the request finishes
*
* @param callback Callback function
+ * @deprecated use the jquery promise API
*/
setCallback(callback: AnyFunction): void {
this.callback = callback;
@@ -240,6 +246,8 @@ export default class AjaxHelper {
/**
* Sets the callback called in case of an error within the request
+ *
+ * @deprecated use the jquery promise API
*/
setErrorCallback(callback: AnyFunction): void {
this.errorCallback = callback;
@@ -247,6 +255,8 @@ export default class AjaxHelper {
/**
* Sets the complete callback which is called after an error or success callback.
+ *
+ * @deprecated use the jquery promise API
*/
setCompleteCallback(callback: AnyFunction): void {
this.completeCallback = callback;
@@ -315,7 +325,7 @@ export default class AjaxHelper {
/**
* Send the request
*/
- send(): void {
+ send(): JQuery.jqXHR {
if ($(this.errorElement).length) {
$(this.errorElement).hide();
}
@@ -326,6 +336,8 @@ export default class AjaxHelper {
this.requestHandle = this.buildAjaxCall();
globalAjaxQueue.push(this.requestHandle);
+
+ return this.requestHandle;
}
/**
@@ -404,11 +416,8 @@ export default class AjaxHelper {
}
globalAjaxQueue.active -= 1;
- const { piwik } = window;
- if (piwik
- && piwik.ajaxRequestFinished
- ) {
- piwik.ajaxRequestFinished();
+ if (Matomo.ajaxRequestFinished) {
+ Matomo.ajaxRequestFinished();
}
},
data: this.mixinDefaultPostParams(this.postParams),
@@ -428,9 +437,9 @@ export default class AjaxHelper {
}
private getDefaultPostParams() {
- if (this.withToken || this.isRequestToApiMethod() || piwik.shouldPropagateTokenAuth) {
+ if (this.withToken || this.isRequestToApiMethod() || Matomo.shouldPropagateTokenAuth) {
return {
- token_auth: piwik.token_auth,
+ token_auth: Matomo.token_auth,
// When viewing a widgetized report there won't be any session that can be used, so don't
// force session usage
force_api_session: broadcast.isWidgetizeRequestWithoutSession() ? 0 : 1,
@@ -462,11 +471,11 @@ export default class AjaxHelper {
* @param params parameter object
*/
private mixinDefaultGetParams(originalParams): Parameters {
- const segment = PiwikUrl.getSearchParam('segment');
+ const segment = MatomoUrl.getSearchParam('segment');
const defaultParams = {
- idSite: piwik.idSite || broadcast.getValueFromUrl('idSite'),
- period: piwik.period || broadcast.getValueFromUrl('period'),
+ idSite: Matomo.idSite || broadcast.getValueFromUrl('idSite'),
+ period: Matomo.period || broadcast.getValueFromUrl('period'),
segment,
};
@@ -490,7 +499,7 @@ export default class AjaxHelper {
// handle default date & period if not already set
if (this.useGETDefaultParameter('date') && !params.date && !this.postParams.date) {
- params.date = piwik.currentDateString;
+ params.date = Matomo.currentDateString;
}
return params;