mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-25 08:21:12 -06:00
Fix: Improve syntax & fix weird label logic
This commit is contained in:
parent
942b55ca03
commit
dd82f36da3
@ -143,36 +143,23 @@ router.get("/api/badge/:id/status", cache("5 minutes"), async (request, response
|
||||
const heartbeat = await Monitor.getPreviousHeartbeat(requestedMonitorId);
|
||||
const state = overrideValue !== undefined ? overrideValue : heartbeat.status;
|
||||
|
||||
badgeValues.label = label ? label : "";
|
||||
badgeValues.label = label ?? "";
|
||||
switch (state) {
|
||||
case 1:
|
||||
badgeValues.color = upColor;
|
||||
badgeValues.message = upLabel;
|
||||
break;
|
||||
case 3:
|
||||
badgeValues.color = maintenanceColor;
|
||||
badgeValues.message = maintenanceLabel;
|
||||
break;
|
||||
case 0:
|
||||
badgeValues.color = downColor;
|
||||
badgeValues.message = downLabel;
|
||||
break;
|
||||
default:
|
||||
badgeValues.color = badgeConstants.naColor;
|
||||
}
|
||||
if (label !== undefined) {
|
||||
badgeValues.message = label;
|
||||
} else {
|
||||
switch (state) {
|
||||
case 1:
|
||||
badgeValues.message = upLabel;
|
||||
break;
|
||||
case 3:
|
||||
badgeValues.message = maintenanceLabel;
|
||||
break;
|
||||
case 0:
|
||||
badgeValues.message = downLabel;
|
||||
break;
|
||||
default:
|
||||
badgeValues.message = "N/A";
|
||||
}
|
||||
badgeValues.message = "N/A";
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user