Drop the property monitor.maintenance, use lastHeartBeat.status to check status instead

This commit is contained in:
Louis Lam 2023-01-17 17:34:47 +08:00
parent 7bb12a7e00
commit a5ff27da7a
3 changed files with 15 additions and 15 deletions

View File

@ -36,7 +36,6 @@ class Monitor extends BeanModel {
id: this.id, id: this.id,
name: this.name, name: this.name,
sendUrl: this.sendUrl, sendUrl: this.sendUrl,
maintenance: await Monitor.isUnderMaintenance(this.id),
}; };
if (this.sendUrl) { if (this.sendUrl) {

View File

@ -3,6 +3,8 @@
</template> </template>
<script> <script>
import { DOWN, MAINTENANCE, PENDING, UP } from "../util.ts";
export default { export default {
props: { props: {
/** Monitor this represents */ /** Monitor this represents */
@ -24,7 +26,6 @@ export default {
computed: { computed: {
uptime() { uptime() {
if (this.type === "maintenance") { if (this.type === "maintenance") {
return this.$t("statusMaintenance"); return this.$t("statusMaintenance");
} }
@ -39,19 +40,19 @@ export default {
}, },
color() { color() {
if (this.type === "maintenance" || this.monitor.maintenance) { if (this.lastHeartBeat.status === MAINTENANCE) {
return "maintenance"; return "maintenance";
} }
if (this.lastHeartBeat.status === 0) { if (this.lastHeartBeat.status === DOWN) {
return "danger"; return "danger";
} }
if (this.lastHeartBeat.status === 1) { if (this.lastHeartBeat.status === UP) {
return "primary"; return "primary";
} }
if (this.lastHeartBeat.status === 2) { if (this.lastHeartBeat.status === PENDING) {
return "warning"; return "warning";
} }

View File

@ -627,28 +627,28 @@ export default {
for (let monitorID in this.lastHeartbeatList) { for (let monitorID in this.lastHeartbeatList) {
let lastHeartBeat = this.lastHeartbeatList[monitorID]; let lastHeartBeat = this.lastHeartbeatList[monitorID];
if (this.monitorList[monitorID] && this.monitorList[monitorID].maintenance) { if (! lastHeartBeat) {
result[monitorID] = {
text: this.$t("statusMaintenance"),
color: "maintenance",
};
} else if (! lastHeartBeat) {
result[monitorID] = unknown; result[monitorID] = unknown;
} else if (lastHeartBeat.status === 1) { } else if (lastHeartBeat.status === UP) {
result[monitorID] = { result[monitorID] = {
text: this.$t("Up"), text: this.$t("Up"),
color: "primary", color: "primary",
}; };
} else if (lastHeartBeat.status === 0) { } else if (lastHeartBeat.status === DOWN) {
result[monitorID] = { result[monitorID] = {
text: this.$t("Down"), text: this.$t("Down"),
color: "danger", color: "danger",
}; };
} else if (lastHeartBeat.status === 2) { } else if (lastHeartBeat.status === PENDING) {
result[monitorID] = { result[monitorID] = {
text: this.$t("Pending"), text: this.$t("Pending"),
color: "warning", color: "warning",
}; };
} else if (lastHeartBeat.status === MAINTENANCE) {
result[monitorID] = {
text: this.$t("statusMaintenance"),
color: "maintenance",
};
} else { } else {
result[monitorID] = unknown; result[monitorID] = unknown;
} }