UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

79 lines 3.97 kB
import { AlarmStatusType, IAuditRecord } from '@c8y/client'; import { Permissions } from '@c8y/ngx-components'; import * as i0 from "@angular/core"; export 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>; } //# sourceMappingURL=alarm-details.service.d.ts.map