2020-10-07 08:53:19 +00:00
|
|
|
// (C) Copyright 2015 Moodle Pty Ltd.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
import { Subject } from 'rxjs';
|
|
|
|
|
|
|
|
import { CoreLogger } from '@singletons/logger';
|
2021-03-10 10:20:24 +00:00
|
|
|
import { CoreSite, CoreSiteInfoResponse, CoreSitePublicConfigResponse } from '@classes/site';
|
2021-03-10 11:30:18 +00:00
|
|
|
import { CoreFilepoolComponentFileEventData } from '@services/filepool';
|
2022-01-28 14:19:01 +00:00
|
|
|
import { CoreRedirectPayload } from '@services/navigator';
|
2021-05-07 08:09:31 +00:00
|
|
|
import { CoreCourseModuleCompletionData } from '@features/course/services/course-helper';
|
2021-10-04 14:40:06 +00:00
|
|
|
import { CoreScreenOrientation } from '@services/screen';
|
2020-10-07 08:53:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Observer instance to stop listening to an event.
|
|
|
|
*/
|
|
|
|
export interface CoreEventObserver {
|
|
|
|
/**
|
|
|
|
* Stop the observer.
|
|
|
|
*/
|
|
|
|
off: () => void;
|
|
|
|
}
|
|
|
|
|
2021-03-01 12:40:17 +00:00
|
|
|
/**
|
|
|
|
* Event payloads.
|
|
|
|
*/
|
|
|
|
export interface CoreEventsData {
|
|
|
|
[CoreEvents.SITE_UPDATED]: CoreEventSiteUpdatedData;
|
|
|
|
[CoreEvents.SITE_ADDED]: CoreEventSiteAddedData;
|
2021-03-10 10:20:24 +00:00
|
|
|
[CoreEvents.SITE_DELETED]: CoreSite;
|
2021-03-01 12:40:17 +00:00
|
|
|
[CoreEvents.SESSION_EXPIRED]: CoreEventSessionExpiredData;
|
|
|
|
[CoreEvents.CORE_LOADING_CHANGED]: CoreEventLoadingChangedData;
|
|
|
|
[CoreEvents.COURSE_STATUS_CHANGED]: CoreEventCourseStatusChanged;
|
|
|
|
[CoreEvents.PACKAGE_STATUS_CHANGED]: CoreEventPackageStatusChanged;
|
|
|
|
[CoreEvents.USER_DELETED]: CoreEventUserDeletedData;
|
2022-01-27 15:28:12 +00:00
|
|
|
[CoreEvents.USER_SUSPENDED]: CoreEventUserSuspendedData;
|
2022-02-09 10:01:05 +00:00
|
|
|
[CoreEvents.USER_NO_LOGIN]: CoreEventUserNoLoginData;
|
2021-03-01 12:40:17 +00:00
|
|
|
[CoreEvents.FORM_ACTION]: CoreEventFormActionData;
|
|
|
|
[CoreEvents.NOTIFICATION_SOUND_CHANGED]: CoreEventNotificationSoundChangedData;
|
|
|
|
[CoreEvents.SELECT_COURSE_TAB]: CoreEventSelectCourseTabData;
|
|
|
|
[CoreEvents.COMPLETION_MODULE_VIEWED]: CoreEventCompletionModuleViewedData;
|
2021-05-07 08:09:31 +00:00
|
|
|
[CoreEvents.MANUAL_COMPLETION_CHANGED]: CoreEventManualCompletionChangedData;
|
2021-03-01 12:40:17 +00:00
|
|
|
[CoreEvents.SECTION_STATUS_CHANGED]: CoreEventSectionStatusChangedData;
|
|
|
|
[CoreEvents.ACTIVITY_DATA_SENT]: CoreEventActivityDataSentData;
|
2021-03-09 08:29:09 +00:00
|
|
|
[CoreEvents.IAB_LOAD_START]: InAppBrowserEvent;
|
2022-10-27 13:40:36 +00:00
|
|
|
[CoreEvents.IAB_LOAD_STOP]: InAppBrowserEvent;
|
|
|
|
[CoreEvents.IAB_MESSAGE]: Record<string, unknown>;
|
2021-03-10 10:20:24 +00:00
|
|
|
[CoreEvents.LOGIN_SITE_CHECKED]: CoreEventLoginSiteCheckedData;
|
2022-02-16 12:26:33 +00:00
|
|
|
[CoreEvents.LOGIN_SITE_UNCHECKED]: CoreEventLoginSiteUncheckedData;
|
2021-03-10 11:30:18 +00:00
|
|
|
[CoreEvents.SEND_ON_ENTER_CHANGED]: CoreEventSendOnEnterChangedData;
|
|
|
|
[CoreEvents.COMPONENT_FILE_ACTION]: CoreFilepoolComponentFileEventData;
|
2021-03-10 14:58:10 +00:00
|
|
|
[CoreEvents.FILE_SHARED]: CoreEventFileSharedData;
|
|
|
|
[CoreEvents.APP_LAUNCHED_URL]: CoreEventAppLaunchedData;
|
2021-10-04 14:40:06 +00:00
|
|
|
[CoreEvents.ORIENTATION_CHANGE]: CoreEventOrientationData;
|
2022-03-09 13:38:00 +00:00
|
|
|
[CoreEvents.COURSE_MODULE_VIEWED]: CoreEventCourseModuleViewed;
|
2022-04-13 13:38:13 +00:00
|
|
|
[CoreEvents.COMPLETE_REQUIRED_PROFILE_DATA_FINISHED]: CoreEventCompleteRequiredProfileDataFinished;
|
2021-05-07 08:09:31 +00:00
|
|
|
}
|
2021-03-01 12:40:17 +00:00
|
|
|
|
2020-10-07 08:53:19 +00:00
|
|
|
/*
|
|
|
|
* Service to send and listen to events.
|
|
|
|
*/
|
2020-10-22 10:48:23 +00:00
|
|
|
export class CoreEvents {
|
2020-10-14 06:30:07 +00:00
|
|
|
|
|
|
|
static readonly SESSION_EXPIRED = 'session_expired';
|
|
|
|
static readonly PASSWORD_CHANGE_FORCED = 'password_change_forced';
|
|
|
|
static readonly USER_NOT_FULLY_SETUP = 'user_not_fully_setup';
|
2021-11-05 08:37:29 +00:00
|
|
|
static readonly SITE_POLICY_AGREED = 'site_policy_agreed';
|
2020-10-14 06:30:07 +00:00
|
|
|
static readonly SITE_POLICY_NOT_AGREED = 'site_policy_not_agreed';
|
|
|
|
static readonly LOGIN = 'login';
|
|
|
|
static readonly LOGOUT = 'logout';
|
|
|
|
static readonly LANGUAGE_CHANGED = 'language_changed';
|
|
|
|
static readonly NOTIFICATION_SOUND_CHANGED = 'notification_sound_changed';
|
|
|
|
static readonly SITE_ADDED = 'site_added';
|
|
|
|
static readonly SITE_UPDATED = 'site_updated';
|
|
|
|
static readonly SITE_DELETED = 'site_deleted';
|
|
|
|
static readonly COMPLETION_MODULE_VIEWED = 'completion_module_viewed';
|
2022-01-24 10:19:34 +00:00
|
|
|
/**
|
|
|
|
* Deprecated on 4.0 use COMPLETION_CHANGED instead.
|
|
|
|
*/
|
2021-05-07 08:09:31 +00:00
|
|
|
static readonly MANUAL_COMPLETION_CHANGED = 'manual_completion_changed';
|
2022-01-24 10:19:34 +00:00
|
|
|
static readonly COMPLETION_CHANGED = 'completion_changed';
|
2020-10-14 06:30:07 +00:00
|
|
|
static readonly USER_DELETED = 'user_deleted';
|
2022-01-27 15:28:12 +00:00
|
|
|
static readonly USER_SUSPENDED = 'user_suspended';
|
2022-02-09 10:01:05 +00:00
|
|
|
static readonly USER_NO_LOGIN = 'user_no_login';
|
2020-10-14 06:30:07 +00:00
|
|
|
static readonly PACKAGE_STATUS_CHANGED = 'package_status_changed';
|
|
|
|
static readonly COURSE_STATUS_CHANGED = 'course_status_changed';
|
|
|
|
static readonly SECTION_STATUS_CHANGED = 'section_status_changed';
|
|
|
|
static readonly COMPONENT_FILE_ACTION = 'component_file_action';
|
|
|
|
static readonly SITE_PLUGINS_LOADED = 'site_plugins_loaded';
|
|
|
|
static readonly SITE_PLUGINS_COURSE_RESTRICT_UPDATED = 'site_plugins_course_restrict_updated';
|
|
|
|
static readonly LOGIN_SITE_CHECKED = 'login_site_checked';
|
|
|
|
static readonly LOGIN_SITE_UNCHECKED = 'login_site_unchecked';
|
|
|
|
static readonly IAB_LOAD_START = 'inappbrowser_load_start';
|
2022-10-27 13:40:36 +00:00
|
|
|
static readonly IAB_LOAD_STOP = 'inappbrowser_load_stop';
|
2020-10-14 06:30:07 +00:00
|
|
|
static readonly IAB_EXIT = 'inappbrowser_exit';
|
2022-10-27 13:40:36 +00:00
|
|
|
static readonly IAB_MESSAGE = 'inappbrowser_message';
|
2020-10-14 06:30:07 +00:00
|
|
|
static readonly APP_LAUNCHED_URL = 'app_launched_url'; // App opened with a certain URL (custom URL scheme).
|
|
|
|
static readonly FILE_SHARED = 'file_shared';
|
|
|
|
static readonly KEYBOARD_CHANGE = 'keyboard_change';
|
2022-03-15 10:46:25 +00:00
|
|
|
/**
|
2023-01-25 09:34:13 +00:00
|
|
|
* @deprecated since app 4.0. Use CoreDirectivesRegistry promises instead.
|
2022-03-15 10:46:25 +00:00
|
|
|
*/
|
2020-10-14 06:30:07 +00:00
|
|
|
static readonly CORE_LOADING_CHANGED = 'core_loading_changed';
|
|
|
|
static readonly ORIENTATION_CHANGE = 'orientation_change';
|
|
|
|
static readonly SEND_ON_ENTER_CHANGED = 'send_on_enter_changed';
|
|
|
|
static readonly SELECT_COURSE_TAB = 'select_course_tab';
|
|
|
|
static readonly WS_CACHE_INVALIDATED = 'ws_cache_invalidated';
|
|
|
|
static readonly SITE_STORAGE_DELETED = 'site_storage_deleted';
|
|
|
|
static readonly FORM_ACTION = 'form_action';
|
|
|
|
static readonly ACTIVITY_DATA_SENT = 'activity_data_sent';
|
2020-12-17 14:37:25 +00:00
|
|
|
static readonly DEVICE_REGISTERED_IN_MOODLE = 'device_registered_in_moodle';
|
2022-03-09 13:38:00 +00:00
|
|
|
static readonly COURSE_MODULE_VIEWED = 'course_module_viewed';
|
2022-04-13 13:38:13 +00:00
|
|
|
static readonly COMPLETE_REQUIRED_PROFILE_DATA_FINISHED = 'complete_required_profile_data_finished';
|
2022-09-20 07:51:45 +00:00
|
|
|
static readonly MAIN_HOME_LOADED = 'main_home_loaded';
|
2022-11-23 10:46:39 +00:00
|
|
|
static readonly FULL_SCREEN_CHANGED = 'full_screen_changed';
|
2020-10-07 08:53:19 +00:00
|
|
|
|
2020-10-22 10:48:23 +00:00
|
|
|
protected static logger = CoreLogger.getInstance('CoreEvents');
|
|
|
|
protected static observables: { [eventName: string]: Subject<unknown> } = {};
|
|
|
|
protected static uniqueEvents: { [eventName: string]: {data: unknown} } = {};
|
2020-10-07 08:53:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Listen for a certain event. To stop listening to the event:
|
|
|
|
* let observer = eventsProvider.on('something', myCallBack);
|
|
|
|
* ...
|
|
|
|
* observer.off();
|
|
|
|
*
|
|
|
|
* @param eventName Name of the event to listen to.
|
|
|
|
* @param callBack Function to call when the event is triggered.
|
|
|
|
* @param siteId Site where to trigger the event. Undefined won't check the site.
|
2022-12-01 11:31:00 +00:00
|
|
|
* @returns Observer to stop listening.
|
2020-10-07 08:53:19 +00:00
|
|
|
*/
|
2021-03-01 12:40:17 +00:00
|
|
|
static on<Fallback = unknown, Event extends string = string>(
|
|
|
|
eventName: Event,
|
2021-03-10 11:30:18 +00:00
|
|
|
callBack: (value: CoreEventData<Event, Fallback> & CoreEventSiteData) => void,
|
2021-01-18 15:40:34 +00:00
|
|
|
siteId?: string,
|
|
|
|
): CoreEventObserver {
|
2020-10-07 08:53:19 +00:00
|
|
|
// If it's a unique event and has been triggered already, call the callBack.
|
|
|
|
// We don't need to create an observer because the event won't be triggered again.
|
|
|
|
if (this.uniqueEvents[eventName]) {
|
2021-03-10 11:30:18 +00:00
|
|
|
callBack(this.uniqueEvents[eventName].data as CoreEventData<Event, Fallback> & CoreEventSiteData);
|
2020-10-07 08:53:19 +00:00
|
|
|
|
|
|
|
// Return a fake observer to prevent errors.
|
|
|
|
return {
|
|
|
|
off: (): void => {
|
|
|
|
// Nothing to do.
|
2020-10-14 06:30:07 +00:00
|
|
|
},
|
2020-10-07 08:53:19 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
this.logger.debug(`New observer listening to event '${eventName}'`);
|
|
|
|
|
2021-12-16 09:46:40 +00:00
|
|
|
if (this.observables[eventName] === undefined) {
|
2020-10-07 08:53:19 +00:00
|
|
|
// No observable for this event, create a new one.
|
2021-03-01 12:40:17 +00:00
|
|
|
this.observables[eventName] = new Subject();
|
2020-10-07 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2021-03-01 12:40:17 +00:00
|
|
|
const subscription = this.observables[eventName].subscribe(
|
2021-03-10 11:30:18 +00:00
|
|
|
(value: CoreEventData<Event, Fallback> & CoreEventSiteData) => {
|
2021-03-01 12:40:17 +00:00
|
|
|
if (!siteId || value.siteId == siteId) {
|
|
|
|
callBack(value);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
2020-10-07 08:53:19 +00:00
|
|
|
|
|
|
|
// Create and return a CoreEventObserver.
|
|
|
|
return {
|
|
|
|
off: (): void => {
|
|
|
|
this.logger.debug(`Stop listening to event '${eventName}'`);
|
|
|
|
subscription.unsubscribe();
|
2020-10-14 06:30:07 +00:00
|
|
|
},
|
2020-10-07 08:53:19 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-04-01 09:48:54 +00:00
|
|
|
/**
|
|
|
|
* Listen once for a certain event. To stop listening to the event (in case it wasn't triggered):
|
|
|
|
* let observer = eventsProvider.on('something', myCallBack);
|
|
|
|
* ...
|
|
|
|
* observer.off();
|
|
|
|
*
|
|
|
|
* @param eventName Name of the event to listen to.
|
|
|
|
* @param callBack Function to call when the event is triggered.
|
|
|
|
* @param siteId Site where to trigger the event. Undefined won't check the site.
|
2022-12-01 11:31:00 +00:00
|
|
|
* @returns Observer to stop listening.
|
2022-04-01 09:48:54 +00:00
|
|
|
*/
|
|
|
|
static once<Fallback = unknown, Event extends string = string>(
|
|
|
|
eventName: Event,
|
|
|
|
callBack: (value: CoreEventData<Event, Fallback> & CoreEventSiteData) => void,
|
|
|
|
siteId?: string,
|
|
|
|
): CoreEventObserver {
|
|
|
|
const listener = CoreEvents.on<Fallback, Event>(eventName, (value) => {
|
2022-05-11 06:58:13 +00:00
|
|
|
listener.off();
|
2022-04-01 09:48:54 +00:00
|
|
|
callBack(value);
|
|
|
|
}, siteId);
|
|
|
|
|
|
|
|
return listener;
|
|
|
|
}
|
|
|
|
|
2020-10-07 08:53:19 +00:00
|
|
|
/**
|
|
|
|
* Listen for several events. To stop listening to the events:
|
|
|
|
* let observer = eventsProvider.onMultiple(['something', 'another'], myCallBack);
|
|
|
|
* ...
|
|
|
|
* observer.off();
|
|
|
|
*
|
|
|
|
* @param eventNames Names of the events to listen to.
|
|
|
|
* @param callBack Function to call when any of the events is triggered.
|
|
|
|
* @param siteId Site where to trigger the event. Undefined won't check the site.
|
2022-12-01 11:31:00 +00:00
|
|
|
* @returns Observer to stop listening.
|
2020-10-07 08:53:19 +00:00
|
|
|
*/
|
2020-11-13 08:08:58 +00:00
|
|
|
static onMultiple<T = unknown>(eventNames: string[], callBack: (value: T) => void, siteId?: string): CoreEventObserver {
|
|
|
|
const observers = eventNames.map((name) => this.on<T>(name, callBack, siteId));
|
2020-10-07 08:53:19 +00:00
|
|
|
|
|
|
|
// Create and return a CoreEventObserver.
|
|
|
|
return {
|
|
|
|
off: (): void => {
|
|
|
|
observers.forEach((observer) => {
|
|
|
|
observer.off();
|
|
|
|
});
|
2020-10-14 06:30:07 +00:00
|
|
|
},
|
2020-10-07 08:53:19 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggers an event, notifying all the observers.
|
|
|
|
*
|
2022-12-01 11:31:00 +00:00
|
|
|
* @param eventName Name of the event to trigger.
|
2020-10-07 08:53:19 +00:00
|
|
|
* @param data Data to pass to the observers.
|
|
|
|
* @param siteId Site where to trigger the event. Undefined means no Site.
|
|
|
|
*/
|
2021-03-01 12:40:17 +00:00
|
|
|
static trigger<Fallback = unknown, Event extends string = string>(
|
|
|
|
eventName: Event,
|
|
|
|
data?: CoreEventData<Event, Fallback>,
|
|
|
|
siteId?: string,
|
|
|
|
): void {
|
2020-10-07 08:53:19 +00:00
|
|
|
this.logger.debug(`Event '${eventName}' triggered.`);
|
|
|
|
if (this.observables[eventName]) {
|
|
|
|
if (siteId) {
|
2020-11-13 08:08:58 +00:00
|
|
|
Object.assign(data || {}, { siteId });
|
2020-10-07 08:53:19 +00:00
|
|
|
}
|
2022-05-11 06:58:13 +00:00
|
|
|
this.observables[eventName].next(data || {});
|
2020-10-07 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggers a unique event, notifying all the observers. If the event has already been triggered, don't do anything.
|
|
|
|
*
|
2022-12-01 11:31:00 +00:00
|
|
|
* @param eventName Name of the event to trigger.
|
2020-10-07 08:53:19 +00:00
|
|
|
* @param data Data to pass to the observers.
|
|
|
|
* @param siteId Site where to trigger the event. Undefined means no Site.
|
|
|
|
*/
|
2021-03-01 12:40:17 +00:00
|
|
|
static triggerUnique<Fallback = unknown, Event extends string = string>(
|
|
|
|
eventName: Event,
|
|
|
|
data: CoreEventData<Event, Fallback>,
|
|
|
|
siteId?: string,
|
|
|
|
): void {
|
2020-10-07 08:53:19 +00:00
|
|
|
if (this.uniqueEvents[eventName]) {
|
|
|
|
this.logger.debug(`Unique event '${eventName}' ignored because it was already triggered.`);
|
|
|
|
} else {
|
|
|
|
this.logger.debug(`Unique event '${eventName}' triggered.`);
|
|
|
|
|
|
|
|
if (siteId) {
|
2020-11-13 08:08:58 +00:00
|
|
|
Object.assign(data || {}, { siteId });
|
2020-10-07 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Store the data so it can be passed to observers that register from now on.
|
|
|
|
this.uniqueEvents[eventName] = {
|
|
|
|
data,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Now pass the data to observers.
|
|
|
|
if (this.observables[eventName]) {
|
|
|
|
this.observables[eventName].next(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-14 06:30:07 +00:00
|
|
|
|
2022-09-21 09:12:53 +00:00
|
|
|
/**
|
|
|
|
* Wait until an event has been emitted.
|
|
|
|
*
|
|
|
|
* @param eventName Event name.
|
|
|
|
*/
|
|
|
|
static waitUntil(eventName: string): Promise<void> {
|
|
|
|
return new Promise(resolve => this.once(eventName, () => resolve()));
|
|
|
|
}
|
|
|
|
|
2020-10-07 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2021-03-01 12:40:17 +00:00
|
|
|
/**
|
|
|
|
* Resolve payload type for a given event.
|
|
|
|
*/
|
|
|
|
export type CoreEventData<Event, Fallback> = Event extends keyof CoreEventsData ? CoreEventsData[Event] : Fallback;
|
|
|
|
|
2020-11-12 08:53:56 +00:00
|
|
|
/**
|
|
|
|
* Some events contains siteId added by the trigger function. This type is intended to be combined with others.
|
|
|
|
*/
|
|
|
|
export type CoreEventSiteData = {
|
|
|
|
siteId?: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data passed to SITE_UPDATED event.
|
|
|
|
*/
|
2021-03-10 11:30:18 +00:00
|
|
|
export type CoreEventSiteUpdatedData = CoreSiteInfoResponse;
|
2020-11-12 08:53:56 +00:00
|
|
|
|
2020-11-23 11:29:56 +00:00
|
|
|
/**
|
|
|
|
* Data passed to SITE_ADDED event.
|
|
|
|
*/
|
2021-03-10 11:30:18 +00:00
|
|
|
export type CoreEventSiteAddedData = CoreSiteInfoResponse;
|
2020-11-23 11:29:56 +00:00
|
|
|
|
2020-10-19 06:55:46 +00:00
|
|
|
/**
|
2020-10-19 10:31:31 +00:00
|
|
|
* Data passed to SESSION_EXPIRED event.
|
2020-10-19 06:55:46 +00:00
|
|
|
*/
|
2022-01-28 14:19:01 +00:00
|
|
|
export type CoreEventSessionExpiredData = CoreRedirectPayload;
|
2020-10-19 10:31:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Data passed to CORE_LOADING_CHANGED event.
|
|
|
|
*/
|
|
|
|
export type CoreEventLoadingChangedData = {
|
|
|
|
loaded: boolean;
|
|
|
|
uniqueId: string;
|
|
|
|
};
|
2020-10-22 11:04:57 +00:00
|
|
|
|
2020-11-20 11:08:30 +00:00
|
|
|
/**
|
|
|
|
* Data passed to COURSE_STATUS_CHANGED event.
|
|
|
|
*/
|
|
|
|
export type CoreEventCourseStatusChanged = {
|
|
|
|
courseId: number; // Course Id.
|
|
|
|
status: string;
|
|
|
|
};
|
2020-11-13 08:08:58 +00:00
|
|
|
|
2020-12-11 14:40:34 +00:00
|
|
|
/**
|
|
|
|
* Data passed to PACKAGE_STATUS_CHANGED event.
|
|
|
|
*/
|
|
|
|
export type CoreEventPackageStatusChanged = {
|
|
|
|
component: string;
|
|
|
|
componentId: string | number;
|
|
|
|
status: string;
|
|
|
|
};
|
|
|
|
|
2020-11-13 08:08:58 +00:00
|
|
|
/**
|
|
|
|
* Data passed to USER_DELETED event.
|
|
|
|
*/
|
2021-03-10 11:30:18 +00:00
|
|
|
export type CoreEventUserDeletedData = {
|
2020-11-13 08:08:58 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
params: any; // Params sent to the WS that failed.
|
|
|
|
};
|
2020-12-03 15:01:02 +00:00
|
|
|
|
2022-01-27 15:28:12 +00:00
|
|
|
/**
|
|
|
|
* Data passed to USER_SUSPENDED event.
|
|
|
|
*/
|
|
|
|
export type CoreEventUserSuspendedData = {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2020-11-13 08:08:58 +00:00
|
|
|
params: any; // Params sent to the WS that failed.
|
|
|
|
};
|
2020-12-03 15:01:02 +00:00
|
|
|
|
2022-02-09 10:01:05 +00:00
|
|
|
/**
|
|
|
|
* Data passed to USER_NO_LOGIN event.
|
|
|
|
*/
|
|
|
|
export type CoreEventUserNoLoginData = {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
params: any; // Params sent to the WS that failed.
|
|
|
|
};
|
|
|
|
|
2020-12-03 15:01:02 +00:00
|
|
|
export enum CoreEventFormAction {
|
|
|
|
CANCEL = 'cancel',
|
|
|
|
SUBMIT = 'submit',
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data passed to FORM_ACTION event.
|
|
|
|
*/
|
2021-03-10 11:30:18 +00:00
|
|
|
export type CoreEventFormActionData = {
|
2020-12-03 15:01:02 +00:00
|
|
|
action: CoreEventFormAction; // Action performed.
|
|
|
|
form: HTMLElement; // Form element.
|
|
|
|
online?: boolean; // Whether the data was sent to server or not. Only when submitting.
|
|
|
|
};
|
2021-01-12 09:38:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Data passed to NOTIFICATION_SOUND_CHANGED event.
|
|
|
|
*/
|
2021-03-10 11:30:18 +00:00
|
|
|
export type CoreEventNotificationSoundChangedData = {
|
2021-01-12 09:38:34 +00:00
|
|
|
enabled: boolean;
|
|
|
|
};
|
2021-01-15 09:32:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Data passed to SELECT_COURSE_TAB event.
|
|
|
|
*/
|
2021-03-10 11:30:18 +00:00
|
|
|
export type CoreEventSelectCourseTabData = {
|
2021-01-15 09:32:21 +00:00
|
|
|
name?: string; // Name of the tab's handler. If not set, load course contents.
|
|
|
|
sectionId?: number;
|
|
|
|
sectionNumber?: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data passed to COMPLETION_MODULE_VIEWED event.
|
|
|
|
*/
|
2021-03-10 11:30:18 +00:00
|
|
|
export type CoreEventCompletionModuleViewedData = {
|
2021-05-07 08:09:31 +00:00
|
|
|
courseId: number;
|
|
|
|
cmId?: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data passed to MANUAL_COMPLETION_CHANGED event.
|
|
|
|
*/
|
|
|
|
export type CoreEventManualCompletionChangedData = {
|
|
|
|
completion: CoreCourseModuleCompletionData;
|
2021-01-15 09:32:21 +00:00
|
|
|
};
|
2021-01-18 14:19:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Data passed to SECTION_STATUS_CHANGED event.
|
|
|
|
*/
|
2021-03-10 11:30:18 +00:00
|
|
|
export type CoreEventSectionStatusChangedData = {
|
2021-01-18 14:19:30 +00:00
|
|
|
courseId: number;
|
|
|
|
sectionId?: number;
|
|
|
|
};
|
2021-02-19 11:41:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Data passed to ACTIVITY_DATA_SENT event.
|
|
|
|
*/
|
2021-03-10 11:30:18 +00:00
|
|
|
export type CoreEventActivityDataSentData = {
|
2021-02-19 11:41:30 +00:00
|
|
|
module: string;
|
|
|
|
};
|
2021-03-10 10:20:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Data passed to LOGIN_SITE_CHECKED event.
|
|
|
|
*/
|
|
|
|
export type CoreEventLoginSiteCheckedData = {
|
|
|
|
config: CoreSitePublicConfigResponse;
|
|
|
|
};
|
2021-03-10 11:30:18 +00:00
|
|
|
|
2022-02-16 12:26:33 +00:00
|
|
|
/**
|
|
|
|
* Data passed to LOGIN_SITE_UNCHECKED event.
|
|
|
|
*/
|
|
|
|
export type CoreEventLoginSiteUncheckedData = {
|
|
|
|
config?: CoreSitePublicConfigResponse;
|
|
|
|
loginSuccessful: boolean;
|
|
|
|
};
|
|
|
|
|
2021-03-10 11:30:18 +00:00
|
|
|
/**
|
|
|
|
* Data passed to SEND_ON_ENTER_CHANGED event.
|
|
|
|
*/
|
|
|
|
export type CoreEventSendOnEnterChangedData = {
|
|
|
|
sendOnEnter: boolean;
|
|
|
|
};
|
2021-03-10 14:58:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Data passed to FILE_SHARED event.
|
|
|
|
*/
|
|
|
|
export type CoreEventFileSharedData = {
|
|
|
|
name: string;
|
|
|
|
siteId: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data passed to APP_LAUNCHED_URL event.
|
|
|
|
*/
|
2021-03-11 13:33:46 +00:00
|
|
|
export type CoreEventAppLaunchedData = {
|
2021-03-10 14:58:10 +00:00
|
|
|
url: string;
|
|
|
|
};
|
2021-10-04 14:40:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Data passed to ORIENTATION_CHANGE event.
|
|
|
|
*/
|
|
|
|
export type CoreEventOrientationData = {
|
|
|
|
orientation: CoreScreenOrientation;
|
|
|
|
};
|
2022-03-09 13:38:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Data passed to COURSE_MODULE_VIEWED event.
|
|
|
|
*/
|
|
|
|
export type CoreEventCourseModuleViewed = {
|
|
|
|
courseId: number;
|
|
|
|
cmId: number;
|
|
|
|
timeaccess: number;
|
|
|
|
sectionId?: number;
|
|
|
|
};
|
2022-04-13 13:38:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Data passed to COMPLETE_REQUIRED_PROFILE_DATA_FINISHED event.
|
|
|
|
*/
|
|
|
|
export type CoreEventCompleteRequiredProfileDataFinished = {
|
|
|
|
path: string;
|
|
|
|
};
|