Add startup management functionality to the agent. Implement API endpoints for enabling and disabling startup, and update the web interface to reflect the current startup state.
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
const shotGallery = document.getElementById("shot-gallery");
|
||||
const execOut = document.getElementById("exec-out");
|
||||
const execMeta = document.getElementById("exec-meta");
|
||||
const startupState = document.getElementById("startup-state");
|
||||
const startupAdd = document.getElementById("startup-add");
|
||||
const startupRemove = document.getElementById("startup-remove");
|
||||
|
||||
let objectUrls = [];
|
||||
|
||||
@@ -89,7 +92,9 @@
|
||||
["Listen", data.listen_address],
|
||||
["Uptime", `${data.uptime_seconds}s`],
|
||||
["Local IPs", (data.local_ips || []).join(", ") || "—"],
|
||||
["Startup", data.startup_enabled ? "enabled" : "disabled"],
|
||||
];
|
||||
setStartup(Boolean(data.startup_enabled));
|
||||
statusFields.replaceChildren(
|
||||
...fields.flatMap(([label, value]) => {
|
||||
const dt = document.createElement("dt");
|
||||
@@ -180,6 +185,19 @@
|
||||
shotGallery.append(figure);
|
||||
}
|
||||
|
||||
function setStartup(enabled) {
|
||||
startupState.textContent = enabled ? "Startup: enabled" : "Startup: disabled";
|
||||
startupAdd.disabled = enabled;
|
||||
startupRemove.disabled = !enabled;
|
||||
}
|
||||
|
||||
async function setStartupEnabled(enabled) {
|
||||
const res = await api("/api/v1/startup", { method: enabled ? "POST" : "DELETE" });
|
||||
const data = await res.json();
|
||||
setStartup(Boolean(data.startup_enabled));
|
||||
loadStatus().catch((err) => showError(err.message));
|
||||
}
|
||||
|
||||
async function runCommand() {
|
||||
const command = document.getElementById("exec-command").value.trim();
|
||||
const timeout = Number(document.getElementById("exec-timeout").value);
|
||||
@@ -207,6 +225,12 @@
|
||||
document.getElementById("refresh-status").addEventListener("click", () => {
|
||||
Promise.all([loadHealth(), loadStatus()]).catch((err) => showError(err.message));
|
||||
});
|
||||
startupAdd.addEventListener("click", () => {
|
||||
setStartupEnabled(true).catch((err) => showError(err.message));
|
||||
});
|
||||
startupRemove.addEventListener("click", () => {
|
||||
setStartupEnabled(false).catch((err) => showError(err.message));
|
||||
});
|
||||
document.getElementById("file-list").addEventListener("click", () => {
|
||||
listFiles(pathInput.value.trim()).catch((err) => showError(err.message));
|
||||
});
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
border-color: var(--accent);
|
||||
color: #fff;
|
||||
}
|
||||
button:disabled { opacity: 0.45; cursor: default; }
|
||||
.panel {
|
||||
display: none;
|
||||
background: var(--card);
|
||||
@@ -142,6 +143,11 @@
|
||||
<button id="refresh-status" class="primary" type="button">Refresh</button>
|
||||
</div>
|
||||
<dl id="status-fields"></dl>
|
||||
<div class="row" style="margin-top:1rem">
|
||||
<span id="startup-state" class="meta">Startup: —</span>
|
||||
<button id="startup-add" type="button">Add to startup</button>
|
||||
<button id="startup-remove" type="button">Remove from startup</button>
|
||||
</div>
|
||||
</section>
|
||||
<section id="files" class="panel">
|
||||
<div class="row">
|
||||
|
||||
Reference in New Issue
Block a user