fix: Improve monitor status retrieval logic in Overview component

This commit is contained in:
Simon Larsen 2024-10-01 16:50:39 +01:00
parent 32fa57c63b
commit 0733c15363
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA

View File

@ -725,13 +725,27 @@ const Overview: FunctionComponent<PageComponentProps> = (
getResourcesInGroup(group);
for (const resource of resourcesInGroup) {
let currentMonitorStatus: MonitorStatus | undefined =
monitorStatuses.find((status: MonitorStatus) => {
let currentMonitorStatus: MonitorStatus | undefined = undefined;
if (resource.monitor) {
currentMonitorStatus = monitorStatuses.find((status: MonitorStatus) => {
return (
status._id?.toString() ===
resource.monitor?.currentMonitorStatusId?.toString()
);
});
}
if (resource.monitorGroupId) {
currentMonitorStatus = monitorStatuses.find((status: MonitorStatus) => {
return (
status._id?.toString() ===
monitorGroupCurrentStatuses[
resource.monitorGroupId?.toString() || ""
]?.toString()
);
});
}
if (!currentMonitorStatus) {
currentMonitorStatus = currentStatus;