mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-19 07:44:02 +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) {
|
async check(monitor, heartbeat) {
|
||||||
if (monitor.manual_status !== null) {
|
if (monitor.manual_status !== null) {
|
||||||
heartbeat.status = monitor.manual_status;
|
heartbeat.status = monitor.manual_status;
|
||||||
heartbeat.msg = monitor.manual_status === UP ? "Up" :
|
switch (monitor.manual_status) {
|
||||||
monitor.manual_status === DOWN ? "Down" :
|
case UP:
|
||||||
monitor.manual_status === MAINTENANCE ? "Maintenance" :
|
heartbeat.msg = "Up";
|
||||||
"Pending";
|
break;
|
||||||
heartbeat.ping = null;
|
case DOWN:
|
||||||
|
heartbeat.msg = "Down";
|
||||||
|
break;
|
||||||
|
case MAINTENANCE:
|
||||||
|
heartbeat.msg = "Maintenance";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
heartbeat.msg = "Pending";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
heartbeat.status = PENDING;
|
heartbeat.status = PENDING;
|
||||||
heartbeat.msg = "Manual monitoring - No status set";
|
heartbeat.msg = "Manual monitoring - No status set";
|
||||||
heartbeat.ping = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -875,6 +875,7 @@ let needSetup = false;
|
||||||
bean.rabbitmqUsername = monitor.rabbitmqUsername;
|
bean.rabbitmqUsername = monitor.rabbitmqUsername;
|
||||||
bean.rabbitmqPassword = monitor.rabbitmqPassword;
|
bean.rabbitmqPassword = monitor.rabbitmqPassword;
|
||||||
bean.conditions = JSON.stringify(monitor.conditions);
|
bean.conditions = JSON.stringify(monitor.conditions);
|
||||||
|
bean.manual_status = monitor.manual_status;
|
||||||
|
|
||||||
// ping advanced options
|
// ping advanced options
|
||||||
bean.ping_numeric = monitor.ping_numeric;
|
bean.ping_numeric = monitor.ping_numeric;
|
||||||
|
@ -1598,48 +1599,6 @@ let needSetup = false;
|
||||||
log.debug("auth", "need auth");
|
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");
|
log.debug("server", "Init the server");
|
||||||
|
|
|
@ -1202,10 +1202,6 @@ export default {
|
||||||
VueMultiselect,
|
VueMultiselect,
|
||||||
EditMonitorConditions,
|
EditMonitorConditions,
|
||||||
},
|
},
|
||||||
setup() {
|
|
||||||
const toast = useToast();
|
|
||||||
return { toast };
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
minInterval: MIN_INTERVAL_SECOND,
|
minInterval: MIN_INTERVAL_SECOND,
|
||||||
|
@ -2040,15 +2036,8 @@ message HealthCheckResponse {
|
||||||
},
|
},
|
||||||
|
|
||||||
setManualStatus(status) {
|
setManualStatus(status) {
|
||||||
let updatedMonitor = { ...this.monitor };
|
this.monitor.manual_status = this.getStatusCode(status);
|
||||||
updatedMonitor.id = this.monitor.id;
|
this.$root.getSocket().emit("editMonitor", this.monitor, (res) => {
|
||||||
|
|
||||||
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) => {
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
this.toast.success(this.$t("Success"));
|
this.toast.success(this.$t("Success"));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue