@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
141 lines • 6.51 kB
TypeScript
import { EventEmitter } from '@angular/core';
import { BehaviorSubject, Subscription } from 'rxjs';
import { CountdownIntervalComponent } from '../countdown-interval';
import { GainsightService } from '../product-experience';
export declare const WIDGET_TYPE_VALUES: {
readonly ALARMS: "alarms";
readonly DATA_POINTS_TABLE: "dataPointsTable";
};
type WidgetType = (typeof WIDGET_TYPE_VALUES)[keyof typeof WIDGET_TYPE_VALUES];
/**
* Abstract class representing an interval reload functionality.
* This class provides methods and properties for managing an interval-based reload mechanism.
*/
export declare abstract class IntervalBasedReload {
protected gainsightService: GainsightService;
abstract countdownIntervalComponent: CountdownIntervalComponent;
/**
* Holds the subscription to a countdown observable.
*/
protected countdownSubscription: Subscription;
/**
* Indicates whether auto-refresh is enabled for the datapoints reload component that is set in widget config.
*/
isAutoRefreshEnabled: boolean;
/**
* Indicates whether refreshing should be enabled or disabled.
* It's 'true' when user is not allowed to view a measurement.
*/
abstract isRefreshDisabled: boolean;
/**
* Current isLoading state. Based on it next countdown cycle is being started.
*/
abstract isLoading: BehaviorSubject<boolean>;
/**
* Indicates whether the alarm list is being scrolled or not.
*/
abstract isScrolling: boolean;
/**
* Current refresh interval set in a widget config.
*/
abstract refreshInterval: number;
/**
* Indicates that a countdown cycle has ended.
*/
abstract onCountdownEnded: EventEmitter<void>;
/**
* Indicates the current state of an interval refresh toggle button.
*/
abstract isIntervalRefreshToggleOn: boolean;
abstract toggleCountdownButtonTooltipText: string;
/**
* Indicates whether the countdown has been manually disabled by the user.
*/
protected abstract manuallyDisabledCountdown: boolean;
/**
* Controls the visibility of the countdown timer component in the current component's UI.
*/
protected abstract hideCountdown: boolean;
/**
* Stops the countdown and triggers a refresh action.
* This function is responsible for halting the countdown interval component's operation.
* After stopping the countdown, it emits an `onCountdownEnded` event.
* This event is used to inform external components that the countdown has ended,
* typically prompting them to reload or refresh their data.
*/
autoRefreshList(): void;
/**
* Manages the countdown timer's visibility and state in response to user scrolling.
*
* This method toggles the countdown timer based on the user's scrolling behavior. It uses
* the `disableCountdown` and `enableCountdown` methods for handling the countdown state.
*
* - If the user is scrolling down while the countdown is visible (`isScrolling` is true and
* `hideCountdown` is false), `disableCountdown` is called to stop and hide the countdown,
* and `isIntervalRefreshToggleOn` is set to false.
*
* - If the user has stopped scrolling, the countdown subscription is closed, and the countdown
* is hidden (`!isScrolling`, `countdownSubscription?.closed`, `hideCountdown`), `enableCountdown`
* is called to show and restart the countdown, and `isIntervalRefreshToggleOn` is set to true.
*/
handleScrolling(): void;
abstract reload(): void;
/**
* Wrapper method where it's name better describes a context where it was called.
*/
abstract countdownEnded(): void;
/**
* Handles the toggle state of the countdown on button click.
*
* This method is triggered by a mouse event, typically a click on the countdown toggle button.
* It toggles `isIntervalRefreshToggleOn` to reflect the current state of the countdown timer.
*
* - If `isIntervalRefreshToggleOn` is set to false, indicating that the countdown should be stopped,
* `disableCountdown` is called, and `manuallyDisabledCountdown` is set to true.
*
* - If `isIntervalRefreshToggleOn` is true and the countdown subscription is closed, indicating that
* the countdown can be started, `enableCountdown` is called, and `manuallyDisabledCountdown`
* is set to false.
*
* @param $event - The MouseEvent that triggered this method.
* @param widgetType - The type of the widget that triggered the event
*/
onToggleCountdownButtonState($event: MouseEvent, widgetType: WidgetType): void;
/**
* This function listens for changes in the `isLoading` observable, filtering out any truthy values.
* Once a falsy value is detected (indicating that loading has finished), it attempts to start the countdown.
*
* IMPORTANT: If the widget's configuration (refreshInterval, check template) is not set prior to executing countdownIntervalComponent?.start,
* the countdown interval will not start!
*
* @param injector - The injector used to provide necessary dependencies
* within the `runInInjectionContext`.
*/
startCountdown(): void;
/**
* Enables and starts the countdown timer.
*
* This method makes the countdown visible (`hideCountdown` is set to false) and then
* starts the countdown process. It ensures the countdown timer is updated immediately
* by triggering change detection with `cdRef.detectChanges()` before starting the countdown.
* This method encapsulates the logic required to initiate the countdown timer.
*/
abstract enableCountdown(): void;
/**
* Disables and hides the countdown timer.
*
* This method stops the ongoing countdown process by
* stopping the `countdownIntervalComponent` if it exists. It then hides the countdown timer
* by setting `hideCountdown` to true. This method encapsulates the logic required to halt and
* conceal the countdown timer.
*/
disableCountdown(): void;
/**
* Updates the countdown button tooltip text based on the state of the interval refresh toggle state.
*/
protected abstract updateCountdownButtonTooltipText(): void;
private triggerGainsightEvent;
private determineComponentName;
}
export {};
//# sourceMappingURL=interval-based-reload.abstract.d.ts.map