UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

1,078 lines (1,056 loc) 61.5 kB
import * as i0 from '@angular/core'; import { InjectionToken, PipeTransform, OnDestroy, OnInit, OnChanges, SimpleChanges, AfterViewInit, EventEmitter, ElementRef, ModuleWithProviders } from '@angular/core'; import { IAlarm, IManagedObject, SeverityFilter, SeverityType, AlarmStatusType, AlarmStatusSettings, IAuditRecord, AlarmService, AlarmQueryFilter, IResultList, IApplication, AuditService, InventoryService } from '@c8y/client'; import * as rxjs from 'rxjs'; import { Observable, Subject, BehaviorSubject } from 'rxjs'; import * as i3 from '@c8y/ngx-components'; import { DateTimeContext, NavigatorNode, NavigatorNodeData, Route, ServiceRegistry, PluginsResolveService, Permissions, ApplicationOptions, OptionsService, ContextRouteService, ContextData, SupportedAppKey, AlertService, AppStateService, RelativeTimePipe, ColorService, InterAppService, GainsightService, CountdownIntervalComponent, LoadMoreMode, DynamicComponentAlertAggregator, ListItemComponent, AlarmWithChildrenRealtimeService, ModalService, ViewContext } from '@c8y/ngx-components'; import * as i6 from '@angular/router'; import { QueryParamsHandling, Router, ActivatedRoute, ActivatedRouteSnapshot, Routes } from '@angular/router'; import { SupportedIcons } from '@c8y/ngx-components/icon-selector/icons'; import * as i11 from '@c8y/ngx-components/interval-picker'; import { AlarmFilterInterval } from '@c8y/ngx-components/interval-picker'; import { TranslateService } from '@ngx-translate/core'; import { DateTimeContextPickerService } from '@c8y/ngx-components/global-context'; import * as _angular_forms from '@angular/forms'; import { FormBuilder, ControlValueAccessor } from '@angular/forms'; import * as i2 from 'ngx-bootstrap/dropdown'; import { BsDropdownDirective } from 'ngx-bootstrap/dropdown'; import * as i7 from '@c8y/ngx-components/alarm-event-selector'; import { AlarmDetails, AlarmEventSelectorService } from '@c8y/ngx-components/alarm-event-selector'; import * as i1 from '@angular/cdk/a11y'; import * as i4 from 'ngx-bootstrap/popover'; import * as i5 from 'ngx-bootstrap/tooltip'; interface AlarmsModuleConfig { /** * Indicates whether the application is a combination of Angular and AngularJS. * @optional */ hybrid?: boolean; /** * The root node of the navigator, which can be either a `NavigatorNode` or `NavigatorNodeData`. * This serves as the entry point for navigation structure for Alarms views. * @optional */ rootNavigatorNode?: NavigatorNode | NavigatorNodeData; /** * An array of `Route` objects representing the navigation routes available. * Each route defines a navigation path and its associated components related to Alarms. * @optional */ route?: Route[]; } declare const ALARMS_MODULE_CONFIG: InjectionToken<unknown>; type AlarmCount = { [key in SeverityType]: number; }; declare const ALARM_STATUS_ICON: { readonly ALERT_IDLE: "c8y-alert-idle"; readonly BELL_SLASH: "bell-slash"; readonly BELL: "bell"; }; type AlarmStatusIcon = (typeof ALARM_STATUS_ICON)[keyof typeof ALARM_STATUS_ICON]; /** * A lookup table to map alarm statuses to corresponding icons. */ declare const AlarmIconMap: Record<AlarmStatusType, AlarmStatusIcon>; declare const ALARM_SEVERITY_ICON: { readonly CIRCLE: "circle"; readonly HIGH_PRIORITY: "high-priority"; readonly WARNING: "warning"; readonly EXCLAMATION_CIRCLE: "exclamation-circle"; }; declare const HELP_ICON = "help"; type AlarmSeverityIcon = (typeof ALARM_SEVERITY_ICON)[keyof typeof ALARM_SEVERITY_ICON]; /** * A lookup table to map alarm severity types to corresponding icons. */ declare const ALARM_SEVERITY_ICON_MAP: Record<SeverityType, AlarmSeverityIcon>; type AlarmListFormFilters = { showCleared: boolean; severityOptions: SeverityFilter; selectedDates?: DateTimeContext; }; /** * Extended interval titles with an additional title for the case when no date is selected. */ declare const INTERVAL_TITLES_EXTENDED: Record<AlarmFilterInterval['id'], string>; declare const INTERVALS_EXTENDED: AlarmFilterInterval[]; type WidgetTimeContextStateExtended = { date: DateTimeContext; interval: AlarmFilterInterval['id']; }; type SelectedAlarm = IAlarm | null; declare const DEFAULT_ALARM_COUNTS: AlarmCount; declare const DEFAULT_SEVERITY_VALUES: SeverityFilter; declare const DEFAULT_STATUS_VALUES: AlarmStatusSettings; declare const ALARMS_PATH = "alarms"; type CustomFragment = { [key: string]: unknown; }; /** * Default properties of a alarm. Used to extract the custom properties from a Alarm object. */ declare const ALARM_DEFAULT_PROPERTIES: readonly ["severity", "source", "type", "time", "text", "id", "status", "count", "name", "history", "self", "creationTime", "firstOccurrenceTime", "lastUpdated"]; declare const THROTTLE_REALTIME_REFRESH = 1000; /** * Represents the navigation options for an alarm component. */ type AlarmNavigationOptions = { /** * Defines if the alarm should navigate to a detail view when clicked. */ allowNavigationToAlarmsView: boolean; /** * Defines if the component should try to determine the context to navigate * to the correct alarm detail view or not. If set to true, the component will * not try to determine the context and will always navigate to the all alarms view. */ alwaysNavigateToAllAlarms: boolean; /** * Defines if the cleared query parameter should be included in the navigation if * the alarm is cleared. */ includeClearedQueryParams: boolean; /** * Determines how query parameters should be handled during navigation. * This property can be set to one of three values: * * - `"merge"` : Merge new parameters with current parameters. * - `"preserve"` : Preserve current parameters. * - `""` : Replace current parameters with new parameters. This is the default behavior. */ queryParamsHandling: QueryParamsHandling; }; interface AlarmDetailsButton { additionalButtonClasses?: string; title: string; icon: SupportedIcons; additionalIconClasses?: string; label?: string; disabled?: boolean; /** * Action to be executed when the button is clicked. * @param alarm The alarm to apply this action to * @returns A boolean or a promise that resolves to a boolean or to the updated alarm. If the result is true, a reload will be triggered. If the result is an alarm, the alarm will be updated with the new values. */ action: (alarm: IAlarm) => boolean | Promise<boolean | IAlarm>; priority?: number; } interface AlarmListIndicatorBase { priority?: number; } interface AlarmListIndicatorIcon extends AlarmListIndicatorBase { icon: SupportedIcons; title: string; class?: string; } type AlarmListIndicator = AlarmListIndicatorIcon; declare const PRODUCT_EXPERIENCE_ALARMS: { readonly EVENTS: { readonly ALARMS: "Alarms"; }; readonly COMPONENTS: { readonly ALARMS_FILTER: "alarms-filter"; readonly ALARMS_INTERVAL_REFRESH: "alarms-interval-refresh"; readonly ALARMS: "alarms"; readonly ALARMS_TYPE_FILTER: "alarms-type-filter"; readonly ALARM_DETAILS: "alarm-details"; }; readonly ACTIONS: { readonly APPLY_FILTER: "applyFilter"; readonly REMOVE_CHIP_FILTER: "removeChipFilter"; readonly APPLY_TYPE_FILTER: "applyTypeFilter"; readonly CREATE_SMART_RULE: "createSmartRule"; readonly ACKNOWLEDGE_ALARM: "acknowledgeAlarm"; readonly REACTIVATE_ALARM: "reactivateAlarm"; readonly CLEAR_ALARM: "clearAlarm"; readonly RELOAD_AUDIT_LOGS: "reloadAuditLogs"; readonly USER_SPEND_TIME_ON_COMPONENT: "userSpendTimeOnComponent"; }; }; type ReloadAlarmsListType = 'gainsightTypeFilters' | null; declare global { namespace CumulocityServiceRegistry { interface SpecificExtensionKeys { alarmDetailsButton: AlarmDetailsButtonProvider; alarmListIndicator: AlarmListIndicatorProvider; } interface AlarmDetailsButtonProvider { /** * Determines whether the button should be shown for a given alarm. * @param alarm The alarm for which to determine button visibility. * @param source The managed object associated with the alarm. * @returns The button details or false. */ getAlarmDetailsButton$(alarm: IAlarm, source: IManagedObject): Observable<AlarmDetailsButton | false>; } interface AlarmListIndicatorProvider { /** * Determines whether the indicator should be shown for a given alarm. * @param alarm The alarm for which to determine indicator visibility. * @returns The indicator details or false. */ getAlarmListIndicator$(alarm: IAlarm): Observable<AlarmListIndicator | false>; } } } declare class AlarmDetailsButtonService { private serviceRegistry; private pluginsResolver; constructor(serviceRegistry: ServiceRegistry, pluginsResolver: PluginsResolveService); get$(alarm: IAlarm, source: IManagedObject): Observable<AlarmDetailsButton[]>; private byPriority; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmDetailsButtonService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<AlarmDetailsButtonService>; } declare class AlarmDetailsButtonPipe implements PipeTransform { private alarmDetailsButtonService; constructor(alarmDetailsButtonService: AlarmDetailsButtonService); transform(alarm: IAlarm, source: IManagedObject): Observable<AlarmDetailsButton[]>; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmDetailsButtonPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<AlarmDetailsButtonPipe, "alarmDetailsButton", true>; } declare class AlarmDetailsService { private permissions; private readonly STATUS_ATTRIBUTE; constructor(permissions: Permissions); /** * Retrieves the username of the user who acknowledged an alarm status. * * This method checks if the provided status is equal to the acknowledged * status. If it is not, or if the * audit log is empty or the first log item does not contain a user, the * method returns a default value ('--'). * * If the status is the acknowledged status and the audit log contains valid * records, the method iterates over the audit records in reverse order * (starting from the most recent). It finds the first record where the * status attribute (defined by this.STATUS_ATTRIBUTE) has been changed to * the acknowledged status. The method then returns the username of the user * who made this change. * * If no such change is found in the audit records, it returns the username * from the first record of the audit log. * * There can be multiple audit logs with ACKNOWLEDGED status. * * @param status - The current status of the alarm. * @param auditLog - An array of audit records to process. * @returns The username of the user who acknowledged the status * or '--' if the status is not acknowledged or audit log is invalid. */ getAcknowledgedBy(status: AlarmStatusType, auditLog: IAuditRecord[]): string; /** * Calculates the acknowledge time from a list of audit records. * * This method iterates over the provided audit records in reverse order * (starting from the most recent) and finds the first record where a * specific status attribute (defined by this.STATUS_ATTRIBUTE) has been * acknowledged. It then returns the creation time of that record. * * If no such record is found, the method returns the creation time of the * first audit record. If the audit record list is empty, it returns null. * * There can be multiple audit logs with ACKNOWLEDGED status. * * @param auditLog - An array of audit records to process. * @returns The creation time of the acknowledged record, * the creation time of the first record if no acknowledged record is found, * or null if the audit log is empty. */ getAcknowledgeTime(auditLog: IAuditRecord[]): string | null; /** * Retrieves the end time of an event from an audit log. * * The method processes the provided audit log to find the first instance * (starting from the most recent record) where the status was changed to 'CLEARED'. * It iterates over the audit records and * checks the changes in each record to find this status change. * * If a record with the CLEARED status is found, the method returns the creation time * of that record. If the entire audit log is processed without finding a CLEARED status, * the creation time of the first audit log record is returned. * * If the audit log is empty or null, the method returns null. * * There can be only one audit log with CLEARED status. * * @param auditLog - An array of audit records to process. * @returns The creation time of the record with the CLEARED status, * the creation time of the first record if no CLEARED status is found, * or null if the audit log is empty or null. */ getEndTime(auditLog: IAuditRecord[]): string | null; checkIfHasAnyRoleAllowingToCreateSmartRule(): boolean; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmDetailsService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<AlarmDetailsService>; } /** * This service is a duplicate of smart-rules-service with slight name change. * Duplicating allows to pass 'Verify App tutorial' job. * Name renames allows to pass 'Reusable build codex' job. * Overall this service is considered as a workaround. * In ticket MTM-58985 we will investigate if it's possible to remove this service * along with making failing jobs pass. */ declare abstract class Ng1SmartRulesUpgradeService { abstract permissionsCfgs: any; abstract addNewForOutputOperationWithUI(operation: any): any; abstract addNewForInputAlarmAndOutputUserWithUI(alarm: any, user: any): any; } declare function SmartRulesUpgradeServiceFactory(injector: any): any; declare const smartRulesUpgradeServiceProvider: { provide: typeof Ng1SmartRulesUpgradeService; useFactory: typeof SmartRulesUpgradeServiceFactory; deps: string[]; }; /** * Service for managing and retrieving alarms data within the alarms view. * * The `AlarmsViewService` provides functionality to interact with alarms, * including filtering, counting, and translation-related operations in an alarms view. * * This service relies on the `AlarmService` for fetching alarm data and the `OptionsService` * for configuring alarms view options. */ declare class AlarmsViewService { private alarmService; private optionsService; private dateTimeContextPickerService; private router; private contextRouteService; readonly ALARM_REFRESH_TYPE_KEY: keyof ApplicationOptions; readonly DEFAULT_INTERVAL_VALUE = 30000; readonly DEFAULT_REFRESH_OPTION_VALUE = "interval"; readonly DEFAULT_INTERVAL_VALUES: number[]; readonly REALTIME_UPDATE_ALARMS_MESSAGE: "The list was updated, click to refresh."; isIntervalEnabled$: Observable<boolean>; reloadAlarmsList$: Subject<"gainsightTypeFilters">; closeDetailsView$: Subject<void>; private _isIntervalEnabled; constructor(alarmService: AlarmService, optionsService: OptionsService, dateTimeContextPickerService: DateTimeContextPickerService, router: Router, contextRouteService: ContextRouteService); /** * Emits a subject to initialize the alarms reloading. */ updateAlarmList(value?: ReloadAlarmsListType): void; /** * Retrieves a list of alarms filtered by specified severities and other optional query filters. * * @param severities an array of severities to filter the alarms. * @param showCleared flag indicating whether to show cleared alarms. Defaults to false. * @param selectedDates an array of two dates to filter alarms by creation and last update dates. * @param filter additional query filters for retrieving alarms. * * @returns A promise that resolves to a list of alarms satisfying the specified filters. */ retrieveFilteredAlarms(severities: SeverityType[], showCleared?: boolean, selectedDates?: [Date, Date], filter?: AlarmQueryFilter): Promise<IResultList<IAlarm>>; retrieveAlarmsByDate(dates: DateTimeContext): Promise<IResultList<IAlarm>>; /** * Updates the state to enable or disable intervals. * @param value - A boolean value to indicate whether to enable intervals. */ updateIntervalState(value: boolean): void; /** * Fetches the count of alarms filtered by severity and clearance status. * * @param severity - The severity level to filter by (e.g., CRITICAL, MAJOR, etc.). * @param showCleared - Whether or not to include cleared alarms in the count. * @param filter - Additional filter criteria for alarms. * * @returns A promise that resolves to the number of alarms that match the filter criteria. * */ getAlarmsCountBySeverity(severity: SeverityType, showCleared: boolean, filter?: AlarmQueryFilter): Promise<number>; /** * Retrieves the current alarms refresh type from the OptionsService * and determines whether it is set to "interval". * * @returns `true` if the alarms refresh type is "interval," otherwise `false`. */ isIntervalRefresh(): boolean; /** * Updates the list of selected severities based on the new severity filter. * * @param severityUpdates - The object representing the updates to each severity. * * @returns An array representing the updated selected severities. */ updateSelectedSeverities(severityUpdates: SeverityFilter): SeverityType[]; /** * Clears all active alarms of the selected severities. * * This method clears all active alarms for the given list of severities by making bulk update calls. If no severities are selected, it defaults to using all available severities. * It works by sending a series of update requests for each severity and returns a Promise that resolves with an object indicating if all alarms were resolved immediately. * * @param selectedSeverities An array of severities to be cleared. If not provided, all severities will be cleared. * @param sourceId - Identifier for the source associated with the alarms to be cleared. * * @returns A Promise that resolves with an object with a flag `resolvedImmediately`. The flag is true if all alarms for all selected severities were cleared successfully; otherwise false. * * **Example** * ```typescript * const severitiesToClear: SeverityType[] = [Severity.MAJOR, Severity.MINOR]; * * clearAllActiveAlarms(severitiesToClear).then(({ resolvedImmediately }) => { * if (resolvedImmediately) { * console.log('All selected alarms were cleared successfully.'); * } else { * console.log('Some alarms could not be cleared.'); * } * }); * ``` * * **Note** * - The method uses the `alarmService.updateBulk` for each severity to clear the active alarms. * - It may fetch the `sourceId` based on the view (if applicable) and include it as a query parameter in the update calls. * - The method returns immediately but the returned Promise needs to have a `then` or `catch` method call to handle the result or error respectively. * - Uses `Promise.all` to wait for all update requests to complete before resolving the final result. */ clearAllActiveAlarms(selectedSeverities: SeverityType[], sourceId: string | number): Promise<{ resolvedImmediately: boolean; }>; /** * Returns the correct link based on the provided context data. * @param contextData The context the navigation was triggered from. * @param alarm The alarm to navigate to. * @returns A link to be used as an url navigation. */ getRouterLink(contextData?: ContextData, alarm?: IAlarm): string; /** * Returns the correct array navigation. * @param contextData The context the navigation was triggered from. * @param alarm The alarm to navigate to. * @returns A link to be used as a router.navigation. */ getRouterNavigationArray(contextData?: ContextData, alarm?: IAlarm): string[]; /** * Closes the details view and navigates based on the current route context, * preserving existing query parameters. */ closeDetailsView(activatedRoute: ActivatedRoute | ActivatedRouteSnapshot): Promise<void>; /** * Returns the correct from and to dates based on the selected interval * @param intervalId the selected interval. E.g. 'none', 'hours', 'custom' ... * @returns The calculated date context based on the selected interval. */ getDateTimeContextByInterval(intervalId: AlarmFilterInterval['id']): DateTimeContext; /** * Converts a given number of seconds into a formatted string representing hours, minutes, and seconds. * * @param totalSeconds - The total number of seconds to convert. * @returns A string in the format "HH:MM:SS", where HH is hours, MM is minutes, and SS is seconds. */ convertSecondsToTime(totalSeconds: number): string; /** * Creates a value for query parameter for filtering alarms by severity based on array of selected severities. * * @param severities - An array of alarm severity types to include in the filter. * If the array is empty or undefined, no severity filter will be applied. * * @returns A comma-separated string of selected alarm severities, * or null if no severities are provided. */ private getSeverityQueryParameter; /** * Creates a value for query parameter for filtering alarms by statuses based on showCleared option. * * @param showCleared - A flag indicating whether to include cleared statuses. * If true, all statuses, including 'CLEARED', will be included; if false, 'CLEARED' will be excluded. * * @returns A comma-separated string of alarm statuses. */ private getStatusQueryParameter; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmsViewService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<AlarmsViewService>; } declare class AlarmsActivityTrackerService implements OnDestroy { isUserActive$: BehaviorSubject<boolean>; userSecondsSpendOnPage: number; private gainsightTimerId; private readonly INACTIVITY_THRESHOLD_SECONDS; private readonly ONE_SECOND_IN_MILLISECONDS; private gainsightInactivityTimeoutId; private destroy$; ngOnDestroy(): void; setGainsightInterval(): void; clearGainsightInterval(): void; resetInactivityTimer(): void; setupEventListenersForGainsight(): void; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmsActivityTrackerService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<AlarmsActivityTrackerService>; } declare class AlarmDetailsComponent implements OnInit, OnChanges, OnDestroy { private alarmDetailsService; private alarmService; private alertService; private appState; private auditService; private relativeTime; private ng1SmartRulesUpgradeService; private translateService; private inventoryService; private alarmsViewService; private colorService; private interAppService; private gainsightService; private alarmsActivityTrackerService; selectedAlarm: IAlarm; readonly ACKNOWLEDGED_STATUS_VALUE: "ACKNOWLEDGED"; readonly ACTIVE_STATUS_VALUE: "ACTIVE"; readonly CLEARED_STATUS_VALUE: "CLEARED"; readonly ACKNOWLEDGE_LABEL: "Acknowledge"; readonly REACTIVATE_LABEL: "Reactivate"; readonly SEVERITY_LABELS: { readonly CRITICAL: "CRITICAL"; readonly MAJOR: "MAJOR"; readonly MINOR: "MINOR"; readonly WARNING: "WARNING"; }; readonly BELL_SLASH_ICON: "bell-slash"; readonly BELL_ICON: "bell"; readonly PRODUCT_EXPERIENCE_ALARMS: { readonly EVENTS: { readonly ALARMS: "Alarms"; }; readonly COMPONENTS: { readonly ALARMS_FILTER: "alarms-filter"; readonly ALARMS_INTERVAL_REFRESH: "alarms-interval-refresh"; readonly ALARMS: "alarms"; readonly ALARMS_TYPE_FILTER: "alarms-type-filter"; readonly ALARM_DETAILS: "alarm-details"; }; readonly ACTIONS: { readonly APPLY_FILTER: "applyFilter"; readonly REMOVE_CHIP_FILTER: "removeChipFilter"; readonly APPLY_TYPE_FILTER: "applyTypeFilter"; readonly CREATE_SMART_RULE: "createSmartRule"; readonly ACKNOWLEDGE_ALARM: "acknowledgeAlarm"; readonly REACTIVATE_ALARM: "reactivateAlarm"; readonly CLEAR_ALARM: "clearAlarm"; readonly RELOAD_AUDIT_LOGS: "reloadAuditLogs"; readonly USER_SPEND_TIME_ON_COMPONENT: "userSpendTimeOnComponent"; }; }; /** * Represents a Device Management application used by the user. * Determines the accurate name and context path required for navigating to alarms of the current device */ userDeviceManagementApp$: Observable<IApplication>; /** * Manages the visibility of the navigation link. * If set to true, the link is visible, otherwise, it remains hidden. */ showSourceNavigationLink$: Observable<boolean>; deviceManagementAppKey: SupportedAppKey; readonly linkTitle: "Open in {{ appName }}"; /** * Contains audit logs, including the very first audit log record in the alarms' history. * This ensures that the historical starting point of the audit logs is always included in the data set. * Usually it's an 'Alarm created' audit log. * * Only used when audit logs exceed PAGE_SIZE. * * @private */ private extendedAuditLogs; private readonly PAGE_SIZE; /** * Prevents the pipeline from failing for a tutorial application * because it's a pure Angular application and doesn't support any * AngularJS services. */ isCreateSmartRulesButtonAvailable: boolean; /** * Property contains a 100 (see PAGE_SIZE) of most recent audit logs records. */ auditLog: IResultList<IAuditRecord>; isLoading: boolean; /** * Indicates when alarms status change was started (Acknowledge/Reactivate) */ isAlarmStatusChanging: boolean; /** * Represents a value for a 'Status' section in details. */ statusMessage: string; /** * The color of the alarm type. */ typeColor: string; /** * Custom fragments of the selected alarm. If none exist, null is returned. */ customFragments: CustomFragment; selectedAlarmMO: IManagedObject; private readonly USER_MINIMUM_SPEND_TIME_SECONDS_TO_TRIGGER_EVENT; private destroy$; constructor(alarmDetailsService: AlarmDetailsService, alarmService: AlarmService, alertService: AlertService, appState: AppStateService, auditService: AuditService, relativeTime: RelativeTimePipe, ng1SmartRulesUpgradeService: Ng1SmartRulesUpgradeService, translateService: TranslateService, inventoryService: InventoryService, alarmsViewService: AlarmsViewService, colorService: ColorService, interAppService: InterAppService, gainsightService: GainsightService, alarmsActivityTrackerService: AlarmsActivityTrackerService); ngOnInit(): Promise<void>; ngOnChanges(changes: SimpleChanges): Promise<void>; ngOnDestroy(): void; visibilityChange(): void; createSmartRule(): void; /** * Navigates to a specific alarm source device based on the provided source. * * @param sourceId - The source id. */ goToAlarmSource(sourceId: string | number): Promise<void>; /** * Reloads audit log data asynchronously. * * This method fetches audit records using `getAlarmAuditRecords` and optionally updates the audit logs * state in the component based on the `isSetAuditLogs` flag. It handles the loading state and potential * errors during the fetch operation. * * @param isRevert - A boolean flag indicating whether to retrieve a 100 (see PAGE_SIZE) records (true) * or only record, that chronologically will be the oldest one (false). Defaults to true. * If set to false, it will set PAGE_SIZE to 1 and trigger a logic * concatenating a most recent record with the very first one to * calculate the alarm duration (change to CLEARED status). * It's passed to the `getAlarmAuditRecords` method. * @param isSetAuditLogs - A boolean flag to determine if the fetched audit logs should be set in the component state. Defaults to `false`. * @returns A promise that resolves to a list of `IAuditRecord` objects. */ reloadAuditLog(isRevert?: boolean, isSetAuditLogs?: boolean): Promise<IResultList<IAuditRecord>>; onUpdateDetails(status: AlarmStatusType): Promise<void>; detailsButtonAction(button: AlarmDetailsButton, alarm: IAlarm): Promise<void>; private updateAlarmStatus; /** * Retrieves the audit log and appends the last audit record to it. * * This method fetches the existing audit log data and makes a deep copy of it. It then * retrieves the last audit record and appends it to the copied audit log data. This is * useful for scenarios where the most recent audit record needs to be included in the * existing audit log data (calculating the CLEARED period). * * @returns A promise of `IResultList<IAuditRecord>`, which includes the * existing audit log data along with the last audit record appended. * @private */ private auditLogWithFirstRecord; private setAuditLogs; private updateLastUpdatedDate; private getActiveStatusMessage; private getAcknowledgedStatusMessage; private getClearedStatusMessage; /** * Calculates the duration of an alarm based on audit log records. * * This method computes the duration of an alarm by finding the difference * between the start and end times of the alarm. The start time is determined * from the last record in the audit log, using the first available time field * (`firstOccurrenceTime`, `time`, or `creationTime`). The end time is obtained * from the `alarmDetailsService`. * * @param auditLog - An array of `IAuditRecord` objects representing the audit log records. * @returns The duration of the alarm in milliseconds, or `null` if the end time is not available. * @private */ private calculateAlarmDuration; /** * Retrieves a list of audit records for a selected alarm. * * This method fetches audit records based on the specified properties, including * the date, page size, whether to revert, the source alarm ID, and whether to include total pages. * * @param isRevert - A boolean flag indicating whether to retrieve a 100 (see PAGE_SIZE) records (true) * or only record, that chronologically will be the oldest one (false). Defaults to true. * If set to false, it will set PAGE_SIZE to 1 and trigger a logic * concatenating a most recent record with the very first one to * calculate the alarm duration (change to CLEARED status). * @returns A Promise that resolves to an IResultList of IAuditRecord objects, representing the audit records. * @async * @private */ private getAlarmAuditRecords; private updateStatusMessage; private hasReachedOrExceededPageSizeLimit; private getCustomFragments; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmDetailsComponent, [null, null, null, null, null, null, { optional: true; }, null, null, null, null, null, null, null]>; static ɵcmp: i0.ɵɵComponentDeclaration<AlarmDetailsComponent, "c8y-alarm-details", never, { "selectedAlarm": { "alias": "selectedAlarm"; "required": false; }; }, {}, never, never, true, never>; } declare class AlarmEmptyComponent { static ɵfac: i0.ɵɵFactoryDeclaration<AlarmEmptyComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<AlarmEmptyComponent, "c8y-alarms-empty", never, {}, {}, never, never, true, never>; } declare class AlarmInfoComponent implements OnInit { activatedRoute: ActivatedRoute; private router; private contextRouteService; private alarmsViewService; selectedAlarm$: Observable<IAlarm>; hasAnyRoleAllowingToCreateSmartRule: boolean; isContextRoute: boolean; readonly TITLE: "Alarms"; constructor(activatedRoute: ActivatedRoute, router: Router, contextRouteService: ContextRouteService, alarmsViewService: AlarmsViewService); ngOnInit(): Promise<void>; back(): void; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmInfoComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<AlarmInfoComponent, "c8y-alarm-info", never, {}, {}, never, never, true, never>; } declare class AlarmListIndicatorService { private serviceRegistry; private pluginsResolver; constructor(serviceRegistry: ServiceRegistry, pluginsResolver: PluginsResolveService); get$(alarm: IAlarm): Observable<AlarmListIndicator[]>; private byPriority; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmListIndicatorService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<AlarmListIndicatorService>; } declare class AlarmListIndicatorPipe implements PipeTransform { private alarmListIndicatorService; constructor(alarmListIndicatorService: AlarmListIndicatorService); transform(alarm: IAlarm): Observable<AlarmListIndicator[]>; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmListIndicatorPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<AlarmListIndicatorPipe, "alarmListIndicator", true>; } /** * Pipe for transforming an array of alarm severity types into a comma-separated string. * * @example * Usage in a template: {{ ['WARNING', 'CRITICAL'] | AlarmSeveritiesToTitle }} * Result: 'Warning, Critical' */ declare class AlarmSeveritiesToTitlePipe implements PipeTransform { private translateService; private readonly severityOptionsCount; constructor(translateService: TranslateService); /** * Transforms an array of alarm severity types into a comma-separated string. * * @param severities - Array of severity types. * @returns - Transformed human-readable title string. */ transform(severities: SeverityType[]): string; /** * Translates and converts a severity type to title case. * * @private * @param chip - Severity type. * @returns - Translated and title-cased severity type. */ private translateSeverityLabel; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmSeveritiesToTitlePipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<AlarmSeveritiesToTitlePipe, "AlarmSeveritiesToTitle", true>; } /** * Pipe for transforming alarm severity types into corresponding icons. * * @example * Usage in an Angular template: * {{ 'CRITICAL' | AlarmSeverityToIcon }} * Result: 'exclamation-circle' */ declare class AlarmSeverityToIconPipe implements PipeTransform { /** * Transforms an alarm severity type into a corresponding icon. * * @param alarmSeverity - The severity type of the alarm. * @returns The corresponding icon for the given alarm severity type. */ transform(alarmSeverity: SeverityType): AlarmSeverityIcon | typeof HELP_ICON; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmSeverityToIconPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<AlarmSeverityToIconPipe, "AlarmSeverityToIcon", true>; } declare class AlarmSeverityToIconClassPipe implements PipeTransform { transform(alarmSeverity: SeverityType): string; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmSeverityToIconClassPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<AlarmSeverityToIconClassPipe, "AlarmSeverityToIconClass", true>; } /** * Pipe to transform alarm severity to corresponding label. */ declare class AlarmSeverityToLabelPipe implements PipeTransform { private translateService; constructor(translateService: TranslateService); /** * Transforms an alarm severity to its corresponding label. * @param alarmSeverity - The alarm severity to transform. * @returns The translated label corresponding to the given alarm severity. */ transform(alarmSeverity: string): string; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmSeverityToLabelPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<AlarmSeverityToLabelPipe, "AlarmSeverityToLabel", true>; } /** * Angular pipe for transforming alarm statuses into corresponding icons. * * @example * Usage in an Angular template: * {{ 'ACTIVE' | AlarmStatusToIcon }} * Result: 'bell' */ declare class AlarmStatusToIconPipe implements PipeTransform { /** * Transforms an alarm status into a corresponding icon. * * @param alarmStatus - The status of the alarm. * @returns - The corresponding icon for the given alarm status. */ transform(alarmStatus: AlarmStatusType): AlarmStatusIcon | typeof HELP_ICON; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmStatusToIconPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<AlarmStatusToIconPipe, "AlarmStatusToIcon", true>; } /** * Pipe to transform alarm status to corresponding label. */ declare class AlarmStatusToLabelPipe implements PipeTransform { private translateService; constructor(translateService: TranslateService); /** * Transforms an alarm status to its corresponding label. * @param alarmStatus - The alarm status to transform. * @returns The translated label corresponding to the given alarm status. */ transform(alarmStatus: AlarmStatusType): string; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmStatusToLabelPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<AlarmStatusToLabelPipe, "AlarmStatusToLabel", true>; } declare class AlarmsFilterComponent implements OnInit, AfterViewInit, OnDestroy { private formBuilder; private alarmsViewService; private alertService; private router; private activatedRoute; readonly severitiesList: SeverityType[]; contextSourceId: number | string | null; /** * EventEmitter to notify when filters have been applied. * Emits a `AlarmListFormFilters` object representing the filter criteria applied by the user. */ onFilterApplied: EventEmitter<AlarmListFormFilters>; filtersDropdown: BsDropdownDirective; formGroup: _angular_forms.FormGroup<{ CRITICAL?: _angular_forms.FormControl<boolean>; MAJOR?: _angular_forms.FormControl<boolean>; MINOR?: _angular_forms.FormControl<boolean>; WARNING?: _angular_forms.FormControl<boolean>; }>; chips: SeverityType[]; isIndeterminate$: Observable<boolean>; countLoading: boolean; showCleared: boolean; alarmCounts: AlarmCount; selectedDates: DateTimeContext; shouldDisableApplyButton$: Observable<boolean>; isEachCheckboxSelected$: Observable<boolean>; protected readonly SEVERITY_LABELS: { readonly CRITICAL: "CRITICAL"; readonly MAJOR: "MAJOR"; readonly MINOR: "MINOR"; readonly WARNING: "WARNING"; }; protected readonly PRODUCT_EXPERIENCE_ALARMS: { readonly EVENTS: { readonly ALARMS: "Alarms"; }; readonly COMPONENTS: { readonly ALARMS_FILTER: "alarms-filter"; readonly ALARMS_INTERVAL_REFRESH: "alarms-interval-refresh"; readonly ALARMS: "alarms"; readonly ALARMS_TYPE_FILTER: "alarms-type-filter"; readonly ALARM_DETAILS: "alarm-details"; }; readonly ACTIONS: { readonly APPLY_FILTER: "applyFilter"; readonly REMOVE_CHIP_FILTER: "removeChipFilter"; readonly APPLY_TYPE_FILTER: "applyTypeFilter"; readonly CREATE_SMART_RULE: "createSmartRule"; readonly ACKNOWLEDGE_ALARM: "acknowledgeAlarm"; readonly REACTIVATE_ALARM: "reactivateAlarm"; readonly CLEAR_ALARM: "clearAlarm"; readonly RELOAD_AUDIT_LOGS: "reloadAuditLogs"; readonly USER_SPEND_TIME_ON_COMPONENT: "userSpendTimeOnComponent"; }; }; private isNoneCheckboxSelected$; private severitiesTouched$; private currentFormGroupValues; private currentShowClearedValue; private destroy$; constructor(formBuilder: FormBuilder, alarmsViewService: AlarmsViewService, alertService: AlertService, router: Router, activatedRoute: ActivatedRoute); ngOnInit(): void; ngAfterViewInit(): void; ngOnDestroy(): void; allChanged(selected: boolean): void; applyFilters(emit?: boolean, navigate?: boolean): void; deselectChip(chip: SeverityType): void; closeDropdown(): void; resetForm(): void; markSeveritiesAsTouched(): void; /** * Asynchronously fetches and updates the count of alarms for each severity level. * * @param showCleared - Whether to include cleared alarms in the count. * Defaults to the current value of `this.currentShowClearedValue`. * @returns A Promise that resolves when all alarm counts have been fetched, * or rejects with an error if the operation fails. * @throws Will throw an error if any of the alarm count fetching promises reject. */ updateAlarmsCount(showCleared?: boolean): Promise<void>; private createFormValueWithChangesStream; private trackCheckboxStateWithFormChanges; private createAllSelectedStream; private createIndeterminateStream; private trackAllCheckboxesDisabled; private createDisableApplyButtonStream; private updateChipsAndDefaultValues; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmsFilterComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<AlarmsFilterComponent, "c8y-alarms-filter", never, { "contextSourceId": { "alias": "contextSourceId"; "required": false; }; }, { "onFilterApplied": "onFilterApplied"; }, never, never, true, never>; } declare class AlarmsIconComponent implements OnInit { alarm: IAlarm; typeFilters: AlarmDetails[]; iconBackgroundColor: string; isFilterApplied: boolean; alarmSeverityLabel: "Severity: {{ alarmSeverity }}"; alarmStatusLabel: "Status: {{ alarmStatus }}"; alarmStatusType: "Type: {{ alarmType }}"; ngOnInit(): void; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmsIconComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<AlarmsIconComponent, "c8y-alarms-icon", never, { "alarm": { "alias": "alarm"; "required": false; }; "typeFilters": { "alias": "typeFilters"; "required": false; }; }, {}, never, never, true, never>; } declare class AlarmsIntervalRefreshComponent implements OnInit, AfterViewInit, OnDestroy { private fb; private alarmsViewService; readonly refreshIntervalsInMilliseconds: number[]; readonly DISABLE_AUTO_REFRESH: "Disable auto refresh"; readonly ENABLE_AUTO_REFRESH: "Enable auto refresh"; readonly SECONDS_UNTIL_REFRESH: "{{ seconds }} s"; isDisabled: boolean; /** * Controls the loading state of the alarms list reload button. */ alarmsListLoading$: BehaviorSubject<boolean>; /** * * Set the value of `isIntervalEnabled` in response to user interactions with the alarm list scroll. * * * * This input setter allows you to control the `isIntervalEnabled` property, which is used to manage the state * * of a toggle button. When a user scrolls through the alarms list, you can update the `isIntervalEnabled` value * * using this setter. * * * * @param value - A boolean value representing the new state of the `isIntervalEnabled` property. * * - `true` indicates that the interval is enabled. * * - `false` indicates that the interval is disabled. */ set isIntervalToggleEnabled(value: boolean); /** * This getter allows you to access the current state of the `isIntervalEnabled` property, which reflects * the state of a toggle button. It retrieves the value from the associated form control, providing the * current state of the toggle button. */ get isIntervalToggleEnabled(): boolean; /** * Event emitter for notifying when a countdown timer has completed. */ onCountdownEnded: EventEmitter<void>; countdownIntervalComponent: CountdownIntervalComponent; toggleIntervalForm: _angular_forms.FormGroup<{ intervalToggle: _angular_forms.FormControl<boolean>; refreshInterval: _angular_forms.FormControl<number>; }>; private destroy$; /** * Indicates whether the user has been interacting with the interval toggle. * Property holds the current state of the interval toggle input element entered by the user, * distinguishing it from changes made programmatically (e.g. value from isIntervalToggleEnabled). */ private doesUserCheckedIntervalToggle; constructor(fb: FormBuilder, alarmsViewService: AlarmsViewService); ngOnInit(): void; ngAfterViewInit(): void; ngOnDestroy(): void; resetCountdown(): void; trackUserClickOnIntervalToggle(target: EventTarget): void; getTooltip(): "Disable auto refresh" | "Enable auto refresh" | "Disabled"; private startCountdown; private onIntervalToggleChange; private initForm; private listenToRefreshIntervalChange; private listenOnLoadingChanges; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmsIntervalRefreshComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<AlarmsIntervalRefreshComponent, "c8y-alarms-interval-refresh", never, { "isDisabled": { "alias": "isDisabled"; "required": false; }; "alarmsListLoading$": { "alias": "alarmsListLoading$"; "required": false; }; "isIntervalToggleEnabled": { "alias": "isIntervalToggleEnabled"; "required": false; }; }, { "onCountdownEnded": "onCountdownEnded"; }, never, never, true, never>; } declare class AlarmsListComponent implements OnChanges, AfterViewInit, OnDestroy { private activatedRoute; private alarmsViewService; private contextRouteService; private router; readonly alarmBadgeTooltip: "Number of occurrences`number of occurrences of alarm`. First occurrence {{ alarmFirstOccurrenceTime }} (device time)."; readonly alarmLastOccurrenceLabel: "Last occurrence of this alarm (device time)."; /** * Input property for receiving a list of alarms. */ alarms: IResultList<IAlarm & { link?: string; }>; hasPermissions: boolean; /** * Input property for the currently applied type filters. */ typeFilters: AlarmDetails[]; /** * Input property for receiving load more mode. */ loadMoreMode: LoadMoreMode; /** * Defines options, how the alarm list should be navigated if a user * clicks on an alarm. */ navigationOptions: AlarmNavigationOptions; /** * Controls the visibility of the loading bar * When set to `false`, the alarm list is displayed. When set to `true`, the opacity of alarms list is changed and a loading bar is shown. */ isInitialLoading: boolean; /** * Controls the visibility and functionality of some components * When set to `true`, means the list is displayed in a split view layout: * the list on the first column and the selected record detail on the second column (the cockpit * alarms view for example) * When set to false, the list is displayed as a standalone component, opening the detail will * redirect to the alarms */ splitView: boolean; /** * Indicates whether the component is in widget preview mode. */ isInPreviewMode: boolean; /** * Emits an instance of a selected alarm when one is chosen from the list. */ onSelectedAlarm: EventEmitter<IAlarm>; /** * Emits a boolean value indicating the scrolling state: true when the user starts scrolling, and false when the user reaches the top of the list. */ onScrollingStateChange: EventEmitter<boolean>; /** * Current alarm or last alarm marked as active by the routerLinkActive directive. */ activeAlarm$: BehaviorSubject<IAlarm>; activeChildParam$: Observable<string>; innerScrollWrapper: ElementRef; isScrolling: boolean; /** * Determines whether the c8y-loading component should be displayed. * The loading component is shown when no alarms are displayed in the view or when the request is initial, * as we don't want to see empty space on alarm list during loading. */ isEmptyListLoading: boolean; alertAggregator: DynamicComponentAlertAggregator; mapAlarmLink: rxjs.UnaryFunction<Observable<IAlarm[]>, Observable<IAlarm[]>>; private destroy$; private HIDE_INTERVAL_COUNTDOWN_SCROLL; constructor(activatedRoute: ActivatedRoute, alarmsViewService: AlarmsViewService, contextRouteService: ContextRouteService, router: Router); /** * Handles the change of the active route. * * @param isActive - A boolean indicating whether the route is active or not. * @param scrollAnchor - The ListItemComponent used as a scroll anchor. * @param alarm - The IAlarm object representing the active alarm. */ activeRouteChanged(isActive: boolean, scrollAnchor: ListItemComponent, alarm: IAlarm): void; ngOnChanges(changes: SimpleChanges): void; ngAfterViewInit(): voi