alarms/alarm-details.service.ts
Properties |
|
Methods |
constructor(stateService: AppStateService, permissions: Permissions)
|
|||||||||
Parameters :
|
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 :
Parameters :
Returns :
string
The username of the user who acknowledged the status or '--' if the status is not acknowledged or audit log is invalid. |
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 :
Returns :
Promise<IApplication | undefined>
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 :
Parameters :
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. |
Readonly DEVICE_MANAGEMENT_APPLICATION_KEY |
Type : string
|
Default value : 'devicemanagement-application-key'
|
Readonly SMART_RULES_APPLICATION_KEY |
Type : string
|
Default value : 'smartrule-key'
|