@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
169 lines • 7.58 kB
TypeScript
import { BehaviorSubject, MonoTypeOperatorFunction, Observable, Subject } from 'rxjs';
import { GlobalAutoRefreshQueryParam } from './widget-auto-refresh-context.model';
import { Event } from '@angular/router';
import * as i0 from "@angular/core";
export declare class WidgetGlobalAutoRefreshService {
/**
* A BehaviorSubject that tracks the number of loading operations in progress.
* Initialized with a count of 0.
*/
private loadingCount$;
/**
* An Observable that emits a boolean indicating whether any widgets with global refresh option are currently loading.
* The value is true if the loading count is non-zero, and false if the loading count is zero.
* Uses distinctUntilChanged() to emit only when the boolean value changes.
*/
private isLoadingWidgets$;
/**
* Object containing behavior subjects for managing auto-refresh settings.
*/
autoRefreshSettings: {
/**
* BehaviorSubject that emits the current state of auto-refresh button.
* Defaults to DEFAULT_INTERVAL_STATE.
*/
isEnabled$: BehaviorSubject<boolean>;
/**
* BehaviorSubject that emits the current auto-refresh interval value.
* Defaults to DEFAULT_INTERVAL_VALUE.
*/
refreshInterval$: BehaviorSubject<number>;
/**
* BehaviorSubject that emits whether auto-refresh has been manually disabled by the user.
* Defaults to false.
*/
userDisabledManually$: BehaviorSubject<boolean>;
};
/**
* Object containing subjects for managing countdown actions.
*/
countdownActions: {
/**
* Subject used to stop the countdown.
*/
stop$: Subject<void>;
/**
* Subject used to reset the countdown.
*/
reset$: Subject<void>;
/**
* Subject that emits when the countdown has ended.
*/
countdownEnded$: Subject<void>;
};
/**
* Subject that emits when a dashboard save operation is triggered.
*/
onDashboardSave$: Subject<void>;
/**
* A signal representing the number of widgets with the global auto-refresh option enabled.
*/
globalRefreshWidgetsCount: import("@angular/core").WritableSignal<number>;
/**
* Tracks the navigation state.
*
* The signal returns a boolean indicating whether a navigation operation is currently in progress.
* It initializes with a default value of `false` and can be toggled to `true` during navigation events from `handleNavigationInProgress$`.
*/
private navigationInProgress;
private readonly router;
private readonly activatedRoute;
/**
* Increments the loading count by 1.
*/
incrementLoading(): void;
/**
* Decrements the loading count by 1.
*/
decrementLoading(): void;
/**
* Retrieves an observable that emits the value of a Global Auto Refresh query parameter
* whenever it changes. The query parameter being tracked is determined by
* `GlobalAutoRefreshName.GLOBAL_CONTEXT_AUTO_REFRESH`.
*
* @returns An observable that emits the parsed value of the `GLOBAL_CONTEXT_AUTO_REFRESH` query parameter.
*/
getQueryParamChangeValue$(): Observable<boolean | null>;
/**
* Monitors router navigation events and updates the navigation progress state.
*
* @returns An Observable that emits router events of types NavigationStart, NavigationEnd,
* NavigationCancel, and NavigationError.
*/
handleNavigationInProgress$(): Observable<Event>;
/**
* Sets the global auto-refresh query parameter in the current route.
*
* @param queryParams - An object representing the query parameters to set for the global auto-refresh option.
* The existing query parameters will be merged with these.
*/
setAutoRefreshQueryParam(queryParams: GlobalAutoRefreshQueryParam): Promise<void>;
/**
* Handles changes to the edit mode and updates the isEnabled$ variable.
*
* - If auto-refresh was manually disabled by the user (`userDisabledManually$` is `true`), auto-refresh will remain disabled regardless of the edit mode state.
* - If auto-refresh was not manually disabled, it will be disabled when entering edit mode and enabled when exiting edit mode.
*
* @param editMode - A boolean indicating the current state of edit mode (`true` if edit mode is active, `false` otherwise).
*/
onEditModeChange(editMode: boolean): void;
/**
* Returns an Observable that triggers the countdown reset action when loading completes.
*
* This method creates an Observable that:
* - Skips a specified number of initial emissions from `isLoadingWidgets$` based on the `skipInitialBehaviorSubjectEmission$` method.
* - Filters out emissions where the loading state is true.
* - On emission where the loading state is false, it triggers a countdown reset action.
*
*/
resetCountdownOnLoadingComplete$(): MonoTypeOperatorFunction<any>;
/**
* Resets the service's settings and parameters to their default values.
*/
resetServiceToDefaults(): void;
/**
* Resets the countdown timer by emitting a reset action after a short delay.
*/
resetCountdown(): void;
/**
* Initializes the auto-refresh countdown logic based on the widget loading state and edit mode.
*
* This method returns an observable that monitors the widget loading state and triggers specific actions
* related to the countdown process. It performs the following steps:
*
* 1. Skips the initial loading state emitted by `isLoadingWidgets$`.
* 2. Stops the countdown if the widgets are currently loading.
* 3. Filters out cases where widgets are loading or the application is in edit mode.
* 4. Resets the countdown when widgets are not loading and the application is not in edit mode.
*
* @param editMode$ - A `BehaviorSubject` representing whether the application is currently in edit mode.
*
* @returns An `Observable<boolean>` that emits the loading state of the widgets after the initialization steps.
*/
initializeAutoRefreshCountdownLoading$(editMode$: BehaviorSubject<boolean>): Observable<boolean>;
/**
* Parses a string representation of global auto-refresh parameter into a boolean or null.
*
* Converts the provided `globalAutoRefresh` string into a boolean value or null based on its content:
* - Returns `true` if `globalAutoRefresh` is 'true'.
* - Returns `false` if `globalAutoRefresh` is 'false'.
* - Returns `null` if `globalAutoRefresh` is neither 'true' nor 'false'.
*
* @param globalAutoRefresh - The string representation of the global auto-refresh parameter.
*
* @returns A boolean value corresponding to the parsed global auto-refresh state, or null if the input is not 'true' or 'false'.
*/
private parseGlobalAutoRefreshParam;
/**
* Resets the loading count to zero.
*/
private resetLoadingToZero;
/**
* Clears the global auto-refresh query parameter by navigating to the current route with the parameter set to null.
*
*/
private clearQueryParam;
static ɵfac: i0.ɵɵFactoryDeclaration<WidgetGlobalAutoRefreshService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<WidgetGlobalAutoRefreshService>;
}
//# sourceMappingURL=widget-global-auto-refresh.service.d.ts.map