@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
197 lines • 10.8 kB
TypeScript
import { AlarmQueryFilter, AlarmStatusSettings, IAlarm, SeverityFilter } from '@c8y/client';
import { SeverityType } from '@c8y/client';
import { AlarmsViewService } from '@c8y/ngx-components/alarms';
import { AlarmListWidgetConfig, AlarmOrderType, LegacyAlarmListConfig } from './alarm-list-widget.model';
import * as i0 from "@angular/core";
export declare const DEFAULT_PAGE_SIZE = 20;
export 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(isIntervalRefresh: boolean, widgetId?: string): 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, isIntervalRefresh: boolean): 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<AlarmWidgetService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<AlarmWidgetService>;
}
//# sourceMappingURL=alarm-widget.service.d.ts.map