mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-04 20:24:04 +00:00
chore: add support for new monitor states
This commit is contained in:
parent
4c701593d4
commit
1630c01fd9
1 changed files with 11 additions and 1 deletions
|
@ -26,6 +26,16 @@ const { UptimeCacheList } = require("../uptime-cache-list");
|
|||
*/
|
||||
class Monitor extends BeanModel {
|
||||
|
||||
statusToKey(status) {
|
||||
switch (status) {
|
||||
case 0: return "down";
|
||||
case 1: return "up";
|
||||
case 2: return "pending";
|
||||
case 4: return "maintenance";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an object that ready to parse to JSON for public
|
||||
* Only show necessary data to public
|
||||
|
@ -49,7 +59,7 @@ class Monitor extends BeanModel {
|
|||
|
||||
if (includeStatus) {
|
||||
const heartbeat = await Monitor.getPreviousHeartbeat(this.id);
|
||||
obj.status = heartbeat.status === 1 ? "up" : "down";
|
||||
obj.status = this.statusToKey(heartbeat.status);
|
||||
}
|
||||
|
||||
return obj;
|
||||
|
|
Loading…
Reference in a new issue