import * as _c8y_ngx_components_context_dashboard from '@c8y/ngx-components/context-dashboard'; import { WidgetConfigService } from '@c8y/ngx-components/context-dashboard'; import * as i0 from '@angular/core'; import { OnInit, OnDestroy, TemplateRef, PipeTransform } from '@angular/core'; import * as i4 from '@angular/forms'; import { NgForm, FormBuilder, FormArray } from '@angular/forms'; import { SeverityFilter, AlarmStatusSettings, AlarmQueryFilter, IAlarm, SeverityType, IResultList, AlarmService } from '@c8y/client'; import * as i2 from '@c8y/ngx-components'; import { GlobalAutoRefreshWidgetConfig, OnBeforeSave, AlertService, DynamicComponent, DynamicComponentAlertAggregator, DashboardChildComponent } from '@c8y/ngx-components'; import * as i1 from '@c8y/ngx-components/alarms'; import { AlarmsViewService } from '@c8y/ngx-components/alarms'; import * as i12 from '@c8y/ngx-components/global-context'; import { GlobalContextState, PresetName, GLOBAL_CONTEXT_DISPLAY_MODE } from '@c8y/ngx-components/global-context'; import { BehaviorSubject, Observable } from 'rxjs'; import * as i3 from '@angular/common'; import * as i5 from 'ngx-bootstrap/popover'; import * as i6 from '@angular/router'; import * as i7 from 'ngx-bootstrap/tooltip'; declare const ALARM_ORDER_VALUES: { readonly BY_ACTIVE: "BY_ACTIVE"; readonly BY_DATE_ASCENDING: "BY_DATE_ASCENDING"; readonly BY_DATE_DESCENDING: "BY_DATE_DESCENDING"; readonly BY_SEVERITY: "BY_SEVERITY"; }; declare const ALARM_ORDER_LABELS: { readonly BY_ACTIVE: "By active status"; readonly BY_DATE_ASCENDING: "By date (ascending)"; readonly BY_DATE_DESCENDING: "By date (descending)"; readonly BY_SEVERITY: "By severity"; }; type AlarmOrderType = keyof typeof ALARM_ORDER_VALUES; type SelectedDevice = { id: string; name: string; }; declare const ASSET_ALARMS_WIDGET_ID = "Asset Alarms"; declare const RECENT_ALARMS_WIDGET_ID = "Recent Alarms"; type AlarmListRefreshOption = 'none' | 'interval' | 'global-interval'; declare const GLOBAL_INTERVAL_OPTION: AlarmListRefreshOption; type LegacyAlarmListConfig = { realtime: boolean; options: { severity: SeverityFilter; types: string[]; orderMode: string; device: string; status: AlarmStatusSettings; }; device?: { name: string; id: string; }; }; interface AlarmListWidgetConfig extends Partial, GlobalAutoRefreshWidgetConfig { order: AlarmOrderType; showAlarmsForChildren?: boolean; device?: SelectedDevice | null; severities: SeverityFilter; status: AlarmStatusSettings; types?: string[]; isRealtime?: boolean; realtime?: boolean; widgetId?: string; } declare const DEFAULT_PAGE_SIZE = 20; declare class AlarmWidgetService { private alarmsViewService; constructor(alarmsViewService: AlarmsViewService); /** * Checks if the provided data follows the LegacyAlarmConfig structure. * * This function determines if a given data object is an instance of LegacyAlarmConfig * by checking for the presence of the 'options' property. * * @param data - The data object to be checked. * @returns - Returns `true` if the data object is a LegacyAlarmConfig, otherwise `false`. */ isOldAlarmConfigStructure(data: LegacyAlarmListConfig | AlarmListWidgetConfig): data is LegacyAlarmListConfig; /** * Creates predefined widget configuration object. * * This method creates a new configuration object based on * a widgets ID (that determines if is a legacy Recent or Critical alarms widget). * * @param isIntervalRefresh - determines a type of a refresh. * @param widgetId - determines if a config should be done for Recent or Critical alarms widget. * @returns The new, predefined configuration object. */ getPredefinedConfiguration(widgetId?: string, existingConfig?: any): AlarmListWidgetConfig; /** * Transforms a LegacyAlarmConfig object into an AlarmListWidgetConfig object. * * This function maps the properties from an old configuration structure (LegacyAlarmConfig) * to a new configuration structure (AlarmListWidgetConfig). * * @param oldConfig - The old configuration object to be transformed. * @returns - The new configuration object mapped from the old one. */ mapToNewConfigStructure(oldConfig: LegacyAlarmListConfig): AlarmListWidgetConfig; /** * Checks if the provided severity object contains all the predefined severity types. * * @param severity - A record object where keys are severity type strings and values are boolean. * - This object is checked against the predefined severity types. * @returns `true` if all predefined severity types are present in the severity object; otherwise, `false`. */ isContainingAllSeverityTypes(severity: SeverityFilter): boolean; /** * Adds any missing severity types to the provided severity object with a default value of `false`. * * @param severity - A record object where keys are severity type strings and values are boolean. * - Missing severity types will be added to this object. * @returns The modified severity object, which includes all predefined severity types, adding any * that were missing with a value of `false`. */ addAllMissingSeverityTypes(severity: SeverityFilter): SeverityFilter; /** * Maps an AlarmListWidgetConfig object to an AlarmQueryFilter. * * This function converts the provided AlarmListWidgetConfig into a format suitable for querying alarms. * * @param config - The configuration object for the alarm list widget. * @param pageSize - Optional number specifying the size of the pages to be returned in the query. * @returns - The query filter object constructed from the provided configuration. */ mapConfigToQueryFilter(config: AlarmListWidgetConfig, pageSize?: number): AlarmQueryFilter; /** * Extracts and concatenates filter parameters from a given object. * * This function takes an object containing filter settings (either SeverityFilter * or AlarmStatusSettings) and returns a string of all keys where the corresponding value is true. * If the object is empty or null, an empty string is returned. * * @param obj - The object containing filter settings. * @returns - A concatenated string of keys with true values, separated by commas. */ extractFilterParams(obj: SeverityFilter | AlarmStatusSettings): string; /** * Determines if an incoming real-time alarm has a different status than an existing alarm. * * This function checks if the provided incoming real-time alarm's status differs * from that of an existing alarm with the same ID in the given array of alarms. * * @param existingAlarms - The array of existing alarms. * @param incomingRealtimeAlarm - The incoming real-time alarm to check. * @returns - True if the existing alarm's status has changed, otherwise false. */ hasExistingAlarmChangedStatus(existingAlarms: IAlarm[], incomingRealtimeAlarm: IAlarm): boolean; /** * Filters alarms based on their status, severity, and type. * * This method determines if a given alarm, identified either by a numeric ID or an `IAlarm` object, * matches specific criteria defined in `alarms` and optionally `config`. * * @param alarm - The alarm to check, represented either by a numeric ID or an `IAlarm` object. * @param alarms - An array of `IAlarm` objects against which the given alarm is evaluated. * @param config - Optional. Configuration for the alarm list widget, used to define additional * filtering criteria. * * @returns `true` if the alarm matches the specified criteria; otherwise, `false`. * If `alarm` is a number, it always returns `false`. * If `config` is not provided, it uses a legacy filter for critical alarms. * * @remarks * - When `alarm` is a numeric ID, the function returns `false` as it cannot match against type and severity. * - If `config` is not provided, the function assumes a legacy scenario for filtering all critical alarms. */ filterAlarmsByStatusSeverityAndType(alarm: number | IAlarm, alarms: IAlarm[], config?: AlarmListWidgetConfig): boolean; /** * Determines if all values in the given object are false. * * This function checks every value in the provided object to see if they are all false. * * @param obj - An object with boolean values. * @returns - Returns `true` if all values in the object are false, otherwise `false`. */ allValuesFalse(obj: { [key: string]: boolean; }): boolean; /** * Constructs a string of order parameters for a query based on the specified alarm order. * * This function takes an alarm order and maps it to a corresponding set of order parameters. * It supports different ordering types, such as BY_ACTIVE, BY_SEVERITY, and BY_DATE_ASCENDING. * The order parameters are used to construct a query string that determines the order * in which alarms are retrieved or displayed. * * @param order - The specified order for sorting alarms (e.g., BY_ACTIVE). * @returns - A string of order parameters to be used in a query, or an empty string if the order type is unrecognized. */ getOrderParameters(order: AlarmOrderType): string; /** * Determines if an alarm is matched by the specified widget configuration. * * This function evaluates whether a given alarm should be included based on the severity, * status, and type filters defined in the AlarmListWidgetConfig. It checks if the alarm's * severity and status match the configuration settings and if the alarm's type is included * in the configuration's types (if specified). * * @ignore * @param alarm - The alarm to evaluate. * @param alarms - An array of existing alarms, used for status matching. * @param config - The configuration settings to match against. * @returns - Returns `true` if the alarm matches the configuration criteria; otherwise, `false`. */ isAlarmMatchedByConfig(alarm: IAlarm, alarms: IAlarm[], config: AlarmListWidgetConfig): boolean; /** * Checks if the severity of an alarm matches the configuration setting. * * This function determines whether the severity of an alarm is included in the * severity settings defined in the AlarmListWidgetConfig. * * @ignore * @param severity - The severity of the alarm to check. * @param config - The configuration with severity settings. * @returns - Returns `true` if the alarm's severity matches the configuration; otherwise, `false`. */ isSeverityMatching(severity: SeverityType, config: AlarmListWidgetConfig): boolean; /** * Evaluates if the status of an alarm matches the configuration setting or has changed. * * This function checks if the status of an alarm is included in the status settings defined in * the AlarmListWidgetConfig, or if the alarm's status has changed based on the existing alarms. * * @ignore * @param alarm - The alarm whose status is to be evaluated. * @param alarms - An array of existing alarms to compare against for status changes. * @param config - The configuration with status settings. * @returns - Returns `true` if the alarm's status matches or has changed as per the configuration; otherwise, `false`. */ isStatusMatching(alarm: IAlarm, alarms: IAlarm[], config: AlarmListWidgetConfig): boolean; /** * Checks if the configuration's types array contains only empty string or includes a specific alarm type. * * @param config - The configuration object with a `types` property. * @param alarm - The alarm object with a `type` property to check against the config's types. * @returns `true` if the config's types array contains only empty string or includes the alarm's type, otherwise `false`. */ isTypesMatching(config: AlarmListWidgetConfig, alarm: IAlarm): boolean; /** * Constructs a query string from an array of order parameters. * * This function takes an array of ordering parameters and constructs a query string * for use in alarm ordering queries. The parameters are concatenated into a single string, * prefixed with '$orderby='. * * @ignore * @private * @param orderParams - The order parameters to be included in the query. * @returns - A query string representing the order parameters. */ private buildOrderParameters; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class AlarmListWidgetConfigComponent implements OnInit, OnBeforeSave, OnDestroy { private alarmListWidgetService; private alarmService; private alarmsViewService; private alertService; private form; private formBuilder; private widgetConfigService; config: AlarmListWidgetConfig; readonly REFRESH_INTERVAL_IN_MILLISECONDS: number[]; readonly SEVERITY_LABELS: { readonly CRITICAL: "CRITICAL"; readonly MAJOR: "MAJOR"; readonly MINOR: "MINOR"; readonly WARNING: "WARNING"; }; readonly STATUS_LABELS: { readonly ACKNOWLEDGED: "ACKNOWLEDGED"; readonly CLEARED: "CLEARED"; readonly ACTIVE: "ACTIVE"; }; readonly ACKNOWLEDGE_STATUS_VALUE: "ACKNOWLEDGED"; readonly CLEARED_STATUS_VALUE: "CLEARED"; readonly BELL_SLASH_ICON: "bell-slash"; readonly BELL_ICON: "bell"; readonly C8Y_ALERT_IDLE_ICON: "c8y-alert-idle"; readonly ALARM_ORDER_LABELS: { readonly BY_ACTIVE: "By active status"; readonly BY_DATE_ASCENDING: "By date (ascending)"; readonly BY_DATE_DESCENDING: "By date (descending)"; readonly BY_SEVERITY: "By severity"; }; alarms$: BehaviorSubject | null>; formGroup: ReturnType; isLoading: boolean; orderList: ("BY_ACTIVE" | "BY_DATE_ASCENDING" | "BY_DATE_DESCENDING" | "BY_SEVERITY")[]; severityList: string[]; /** * Order does matter. */ statusList: ("ACKNOWLEDGED" | "CLEARED" | "ACTIVE")[]; set previewMapSet(template: TemplateRef); private destroy$; config$: Observable<_c8y_ngx_components_context_dashboard.ContextWidgetConfig>; controls: PresetName; constructor(alarmListWidgetService: AlarmWidgetService, alarmService: AlarmService, alarmsViewService: AlarmsViewService, alertService: AlertService, form: NgForm, formBuilder: FormBuilder, widgetConfigService: WidgetConfigService); ngOnInit(): void; ngOnDestroy(): void; onBeforeSave(config?: AlarmListWidgetConfig): boolean | Promise | Observable; removeType(index: number): void; addType(): void; get types(): FormArray; private filterEmptyTypes; private isContainingOnlyEmptyTypes; private getAlarms; private initializeForm; private createForm; private minSelectedCheckboxes; private initializeTypes; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class AlarmListWidgetComponent implements OnInit, OnDestroy, DynamicComponent { private alarmWidgetService; private alarmService; private dashboardChild; private alertService; private widgetConfigMigrationService; config: AlarmListWidgetConfig; displayMode: i0.WritableSignal<"dashboard" | "config" | "view_and_config">; contextConfig: i0.WritableSignal; isLinkedToGlobal: i0.WritableSignal; alarms$: BehaviorSubject | null>; isLoading$: BehaviorSubject; alerts: DynamicComponentAlertAggregator; widgetControls: i0.WritableSignal; readonly GLOBAL_CONTEXT_DISPLAY_MODE: typeof GLOBAL_CONTEXT_DISPLAY_MODE; readonly CONTEXT_FEATURE: { readonly LIVE_TIME: "liveTime"; readonly HISTORY_TIME: "historyTime"; readonly AGGREGATION: "aggregation"; readonly AUTO_REFRESH: "autoRefresh"; readonly REFRESH: "refresh"; }; readonly REFRESH_OPTION: { readonly LIVE: "live"; readonly HISTORY: "history"; }; readonly PRESET_NAME: { readonly DEFAULT: "default"; readonly ALARM_LIST: "alarmList"; readonly CHART: "chart"; readonly LIVE_ONLY: "liveOnly"; readonly HISTORY_ONLY: "historyOnly"; readonly ALARM_LIST_CONFIG: "alarmListConfig"; readonly ALARM_LIST_LEGACY: "alarmListLegacy"; }; private TIMEOUT_ERROR_TEXT; private SERVER_ERROR_TEXT; private unsubscribe$; hasPermissions: boolean; ngOnInit(): Promise; ngOnDestroy(): void; onContextChange(event: { context: GlobalContextState; diff: GlobalContextState; }): void; getDashboardChild(): DashboardChildComponent; onRefresh(): void; onScrollingStateChange(isScrolling: boolean): void; private fetchAlarms; private getAlarms; private setLegacyRecentOrCriticalAlarmWidgetConfig; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } interface SeverityIcon { c8yIcon?: string; iconClass: string; severityClass?: string; } declare class SeverityIconPipe implements PipeTransform { transform(severity: string): SeverityIcon; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class SortingDescriptionPopoverMessagePipe implements PipeTransform { transform(order: AlarmOrderType): string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class AlarmsWidgetModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } export { ALARM_ORDER_LABELS, ALARM_ORDER_VALUES, ASSET_ALARMS_WIDGET_ID, AlarmListWidgetComponent, AlarmListWidgetConfigComponent, AlarmWidgetService, AlarmsWidgetModule, DEFAULT_PAGE_SIZE, GLOBAL_INTERVAL_OPTION, RECENT_ALARMS_WIDGET_ID, SeverityIconPipe, SortingDescriptionPopoverMessagePipe }; export type { AlarmListRefreshOption, AlarmListWidgetConfig, AlarmOrderType, LegacyAlarmListConfig, SelectedDevice }; //# sourceMappingURL=index.d.ts.map