import { Subject, Subscription } from 'rxjs'; import * as i0 from '@angular/core'; import { InjectionToken, Type, OnDestroy, OnInit } from '@angular/core'; import { SearchService } from '@sinequa/components/search'; import { Query } from '@sinequa/core/app-utils'; import { ModalService, ModalButton, ModalRef } from '@sinequa/core/modal'; import { UserSettingsWebService, AuditEvents, AuditEvent } from '@sinequa/core/web-services'; import * as i6 from '@angular/forms'; import { UntypedFormGroup, UntypedFormBuilder, ValidatorFn } from '@angular/forms'; import * as i5 from '@angular/common'; import { KeyValue } from '@angular/common'; import * as i7 from '@angular/cdk/drag-drop'; import { CdkDragDrop } from '@angular/cdk/drag-drop'; import * as i12 from '@sinequa/components/action'; import { Action } from '@sinequa/components/action'; import { LoginService } from '@sinequa/core/login'; import * as i8 from '@sinequa/components/modal'; import * as i9 from '@sinequa/core/intl'; import * as i10 from '@sinequa/core/validation'; import * as i11 from '@sinequa/components/utils'; declare namespace Alert { enum Frequency { Daily = 0, Hourly = 1, Immediate = 2, Weekly = 3, Monthly = 4 } enum Days { None = 0, Monday = 1, Tuesday = 2, Wednesday = 4, Thursday = 8, Friday = 16, Saturday = 32, Sunday = 64, AllDays = 127, WeekDays = 31 } } interface Alert { name: string; description?: string; query: Query; timezone: string; timezoneOffset?: string; frequency: Alert.Frequency; days: Alert.Days; interval: number; index: number; times: string; active: boolean; combine: boolean; respectTabSelection: boolean; appQueryUrl?: string; } declare const enum AlertEventType { Loaded = "Alert_Loaded", Patched = "Alert_Patched", Add = "Alert_Add", Delete = "Alert_Delete", DeleteAll = "Alert_DeleteAll", Update = "Alert_Update", Search_AlertQuery = "Search_AlertQuery" } declare const ALERT_CHANGE_EVENTS: AlertEventType[]; interface AlertChangeEvent { type: AlertEventType; alert?: Alert; } interface ManageAlertsModel { alerts: Alert[]; auditEvents?: AuditEvent[]; searchRoute?: string; } /** * The modal types are unknown to this service. * The module using this service must provide these components * in their forRoot() method * * Example below: * * public static forRoot(): ModuleWithProviders { return { ngModule: AlertsModule, providers: [ { provide: ALERT_COMPONENTS, useValue: { editAlertModal: EditAlert, manageAlertsModal: ManageAlerts } }, AlertsService ] }; } * */ interface AlertComponents { editAlertModal: Type; manageAlertsModal: Type; } declare const ALERT_COMPONENTS: InjectionToken; declare const WINDOW: InjectionToken; declare class AlertsService implements OnDestroy { userSettingsService: UserSettingsWebService; searchService: SearchService; modalService: ModalService; alertComponents: AlertComponents; private window; private readonly _events; private readonly _changes; constructor(userSettingsService: UserSettingsWebService, searchService: SearchService, modalService: ModalService, alertComponents: AlertComponents, window: Window); /** * Returns the list of this user's alerts. * The list is stored in the user settings (this is a redirection). * Using this service creates the list of alerts if it does not already exist. */ get alerts(): Alert[]; set alerts(alerts: Alert[]); /** * Triggers any event among AlertChangeEvent * (use for fine-grained control of alerts workflow) */ get events(): Subject; /** * Triggers when events affect the list of alerts * (use to refresh alert menus) * Cf. CHANGE_EVENTS list */ get changes(): Subject; /** * @returns true if there is at least one alert */ get hasAlert(): boolean; /** * @returns an alert with the given name or undefined if it does not exist * @param name */ alert(name: string): Alert | undefined; private alertIndex; /** * Creates a new alert unless it already exists. * Emits an Alert event. * Update the data on the server. * @param alert the alert to create * @returns true if alert was created */ createAlert(alert: Alert): boolean; /** * Update the alert at the given index, unless an alert with the same name * already exists in the list of alerts. * Emits an Alert event. * Update the data on the server. * @param alert the alert to update * @param index the index at which to update the alert * @returns true if alert was updated */ updateAlert(alert: Alert, index: number): boolean; /** * Updates the full list of alerts. * Emits an Alert event. * Update the data on the server. * @param alerts the new list of alerts * @param auditEvents the list of audit events to log */ updateAlerts(alerts: Alert[], auditEvents?: AuditEvents): boolean; /** * Deletes the given alert (based on its name) * Emits an Alert event. * Update the data on the server. * @param alert * @returns true if alert was deleted */ deleteAlert(alert: Alert): boolean; /** * Sets this alert to the current search context, using the search service */ setAlertToCurrentQuery(alert: Alert): void; /** * Updates Alerts in User settings. * @param auditEvents : Audit Events to be triggered * @returns an Observable which can be used to trigger further events */ private patchAlerts; /** * Uses the SearchService to perform a search returning all * the documents matching this alert. * @param alert * @returns the search service promise */ searchAlert(alert: Alert, path?: string): Promise; /** * Opens a dialog allowing a user to create a new alert. * @returns a boolean promise resolved when the user closes the dialog * the result is true if the alert was created. */ createAlertModal(): Promise; /** * Opens a dialog allowing a user to edit an existing alert. * @param alert: The alert to edit * @param noUpdate: if true, will not update the server after the edit * @param searchRoute: the route to use when replaying the alert's query * @returns a boolean promise resolved when the user closes the dialog * the result is true if the alert was updated. */ editAlertModal(alert: Alert, noUpdate?: boolean, searchRoute?: string): Promise; /** * Opens a dialog allowing a user to reorganize and edit the * list of alerts. * @returns a boolean promise resolved when the user closes the dialog * the result is true is the list was updated. */ manageAlertsModal(searchRoute?: string): Promise; ngOnDestroy(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class BsEditAlert implements OnInit, OnDestroy { model: { alert: Alert; searchRoute?: string; }; private formBuilder; private searchService; private alertsService; private modalRef; form: UntypedFormGroup; formChanges: Subscription; buttons: ModalButton[]; frequencies: Alert.Frequency[]; frequency: typeof Alert.Frequency; canUpdateQuery: boolean; updateQuery: boolean; weekdays: { monday: Alert.Days; tuesday: Alert.Days; wednesday: Alert.Days; thursday: Alert.Days; friday: Alert.Days; saturday: Alert.Days; sunday: Alert.Days; }; showDirtyMessage: boolean; originalOrder: (a: KeyValue, b: KeyValue) => number; private alertDaysControl; private alertNameControl; private alertFrequencyControl; private alertTimesControl; private alertActiveControl; private alertRespectTabSelectionControl; private alertCombineWithOtherAlertsControl; private updateQueryControl; constructor(model: { alert: Alert; searchRoute?: string; }, formBuilder: UntypedFormBuilder, searchService: SearchService, alertsService: AlertsService, modalRef: ModalRef); get alert(): Alert; ngOnInit(): void; private createButtons; private createYesNoButtons; ngOnDestroy(): void; dayChecked(day: Alert.Days): boolean; dayChange(event: UIEvent, day: Alert.Days): void; runQuery(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class BsManageAlerts implements OnInit { model: ManageAlertsModel; alertsService: AlertsService; reordering: boolean; buttons: ModalButton[]; removeAllButton: ModalButton; nameValidators: ValidatorFn[]; showDirtyMessage: boolean; constructor(model: ManageAlertsModel, alertsService: AlertsService); ngOnInit(): void; addAuditEvent(auditEvent: AuditEvent): void; reorder(): void; remove(alert: Alert, index: number): boolean; editAlert(alert: Alert): boolean; dropped(drop: CdkDragDrop): void; private createButtons; private createYesNoButtons; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class BsAlertsMenuComponent implements OnInit, OnDestroy { loginService: LoginService; alertsService: AlertsService; searchService: SearchService; searchRoute: string; icon: string; autoAdjust: boolean; autoAdjustBreakpoint: string; collapseBreakpoint: string; size: string; menu: Action | undefined; createAction: Action; manageAction: Action; constructor(loginService: LoginService, alertsService: AlertsService, searchService: SearchService); ngOnInit(): void; private _alertsServiceSubscription; private _loginServiceSubscription; private _searchServiceSubscription; ngOnDestroy(): void; updateMenu(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class BsAlertMessageComponent { message: string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class BsAlertsModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } declare const enAlerts: any; declare const frAlerts: any; declare const deAlerts: any; export { ALERT_CHANGE_EVENTS, ALERT_COMPONENTS, Alert, AlertEventType, AlertsService, BsAlertsMenuComponent, BsAlertsModule, BsEditAlert, BsManageAlerts, WINDOW, deAlerts, enAlerts, frAlerts }; export type { AlertChangeEvent, AlertComponents, ManageAlertsModel };