From 1630c01fd9038a5970dcb358958494ea170e2d38 Mon Sep 17 00:00:00 2001 From: Gero Gerke Date: Thu, 5 Jan 2023 15:56:08 +0100 Subject: [PATCH] chore: add support for new monitor states --- server/model/monitor.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 473c39d5..763763fe 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -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;