UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

203 lines 10.2 kB
import { OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'; import { AlarmService, AlarmStatusType, AuditService, IAlarm, IApplication, IAuditRecord, IManagedObject, IResultList, InventoryService } from '@c8y/client'; import { AlertService, AppStateService, ColorService, RelativeTimePipe, SupportedAppKey, InterAppService, GainsightService } from '@c8y/ngx-components'; import { TranslateService } from '@ngx-translate/core'; import { AlarmDetailsService } from './alarm-details.service'; import { AlarmDetailsButton, CustomFragment } from './alarms.model'; import { Ng1SmartRulesUpgradeService } from './ng1-smart-rules-upgrade.service'; import { AlarmsViewService } from './alarms-view.service'; import { Observable } from 'rxjs'; import { AlarmsActivityTrackerService } from './alarms-activity-tracker.service'; import * as i0 from "@angular/core"; export 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>; } //# sourceMappingURL=alarm-details.component.d.ts.map