File

alarms/alarm-details.service.ts

Index

Properties
Methods

Constructor

constructor(stateService: AppStateService, permissions: Permissions)
Parameters :
Name Type Optional
stateService AppStateService No
permissions Permissions No

Methods

checkIfHasAnyRoleAllowingToCreateSmartRule
checkIfHasAnyRoleAllowingToCreateSmartRule()
Returns : boolean
getAcknowledgedBy
getAcknowledgedBy(status: AlarmStatusType, auditLog: IAuditRecord[])

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.

Example :
      or '--' if the status is not acknowledged or audit log is invalid.
Parameters :
Name Type Optional Description
status AlarmStatusType No
  • The current status of the alarm.
auditLog IAuditRecord[] No
  • An array of audit records to process.
Returns : string

The username of the user who acknowledged the status or '--' if the status is not acknowledged or audit log is invalid.

getAcknowledgeTime
getAcknowledgeTime(auditLog: IAuditRecord[])

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.

Example :
      the creation time of the first record if no acknowledged record is found,
      or null if the audit log is empty.
Parameters :
Name Type Optional Description
auditLog IAuditRecord[] No
  • An array of audit records to process.
Returns : string | null

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.

Async getApplication
getApplication(applicationKey: string)

Retrieves a specified application based on the provided application key.

This method first checks if the requested application, identified by its key (which could belong to Device Management or Smart Rules Microservice), is present in the user's current applications cache. If not found in the cache, it fetches the application from the list of current user's applications, which is maintained by the state service.

The application is searched by its key, and this method returns a promise that either resolves to the found application or undefined if the application with the specified key does not exist.

Parameters :
Name Type Optional Description
applicationKey string No

The key of the application to retrieve.

A promise that resolves to the requested application or undefined if the application is not found.

getEndTime
getEndTime(auditLog: IAuditRecord[])

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.

Example :
     the creation time of the first record if no CLEARED status is found,
     or null if the audit log is empty or null.
Parameters :
Name Type Optional Description
auditLog IAuditRecord[] No
  • An array of audit records to process.
Returns : string | null

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.

Properties

Readonly DEVICE_MANAGEMENT_APPLICATION_KEY
Type : string
Default value : 'devicemanagement-application-key'
Readonly SMART_RULES_APPLICATION_KEY
Type : string
Default value : 'smartrule-key'

results matching ""

    No results matching ""