mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-18 23:34:04 +02:00
DEVOPS-000 Fix review comments
This commit is contained in:
parent
85df67e4e4
commit
9d00424420
3 changed files with 16 additions and 61 deletions
|
@ -18,15 +18,22 @@ class ManualMonitorType extends MonitorType {
|
|||
async check(monitor, heartbeat) {
|
||||
if (monitor.manual_status !== null) {
|
||||
heartbeat.status = monitor.manual_status;
|
||||
heartbeat.msg = monitor.manual_status === UP ? "Up" :
|
||||
monitor.manual_status === DOWN ? "Down" :
|
||||
monitor.manual_status === MAINTENANCE ? "Maintenance" :
|
||||
"Pending";
|
||||
heartbeat.ping = null;
|
||||
switch (monitor.manual_status) {
|
||||
case UP:
|
||||
heartbeat.msg = "Up";
|
||||
break;
|
||||
case DOWN:
|
||||
heartbeat.msg = "Down";
|
||||
break;
|
||||
case MAINTENANCE:
|
||||
heartbeat.msg = "Maintenance";
|
||||
break;
|
||||
default:
|
||||
heartbeat.msg = "Pending";
|
||||
}
|
||||
} else {
|
||||
heartbeat.status = PENDING;
|
||||
heartbeat.msg = "Manual monitoring - No status set";
|
||||
heartbeat.ping = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -875,6 +875,7 @@ let needSetup = false;
|
|||
bean.rabbitmqUsername = monitor.rabbitmqUsername;
|
||||
bean.rabbitmqPassword = monitor.rabbitmqPassword;
|
||||
bean.conditions = JSON.stringify(monitor.conditions);
|
||||
bean.manual_status = monitor.manual_status;
|
||||
|
||||
// ping advanced options
|
||||
bean.ping_numeric = monitor.ping_numeric;
|
||||
|
@ -1598,48 +1599,6 @@ let needSetup = false;
|
|||
log.debug("auth", "need auth");
|
||||
}
|
||||
|
||||
socket.on("updateManual", async (data, callback) => {
|
||||
try {
|
||||
checkLogin(socket);
|
||||
|
||||
let monitor = await R.findOne("monitor", " id = ? AND user_id = ? ", [
|
||||
data.monitorID,
|
||||
socket.userID,
|
||||
]);
|
||||
|
||||
if (!monitor) {
|
||||
throw new Error("Monitor not found");
|
||||
}
|
||||
|
||||
let status;
|
||||
if (data.status === 1) {
|
||||
status = UP;
|
||||
} else if (data.status === 0) {
|
||||
status = DOWN;
|
||||
} else if (data.status === 3) {
|
||||
status = MAINTENANCE;
|
||||
} else {
|
||||
status = PENDING;
|
||||
}
|
||||
|
||||
monitor.manual_status = status;
|
||||
await R.store(monitor);
|
||||
|
||||
callback({
|
||||
ok: true,
|
||||
msg: "Saved.",
|
||||
msgi18n: true,
|
||||
id: monitor.id,
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
callback({
|
||||
ok: true,
|
||||
msg: e.message,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
log.debug("server", "Init the server");
|
||||
|
|
|
@ -1202,10 +1202,6 @@ export default {
|
|||
VueMultiselect,
|
||||
EditMonitorConditions,
|
||||
},
|
||||
setup() {
|
||||
const toast = useToast();
|
||||
return { toast };
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
minInterval: MIN_INTERVAL_SECOND,
|
||||
|
@ -2040,15 +2036,8 @@ message HealthCheckResponse {
|
|||
},
|
||||
|
||||
setManualStatus(status) {
|
||||
let updatedMonitor = { ...this.monitor };
|
||||
updatedMonitor.id = this.monitor.id;
|
||||
|
||||
this.$root.getSocket().emit("updateManual", {
|
||||
monitorID: this.monitor.id,
|
||||
status: status === "up" ? 1 : status === "down" ? 0 : 3,
|
||||
msg: status === "up" ? "Up" : status === "down" ? "Down" : "Maintenance",
|
||||
time: new Date().getTime(),
|
||||
}, (res) => {
|
||||
this.monitor.manual_status = this.getStatusCode(status);
|
||||
this.$root.getSocket().emit("editMonitor", this.monitor, (res) => {
|
||||
if (res.ok) {
|
||||
this.toast.success(this.$t("Success"));
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue