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,
name: this.name,
sendUrl: this.sendUrl,
maintenance: await Monitor.isUnderMaintenance(this.id),
};
if (this.sendUrl) {

View File

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

View File

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