Refactor server state and add health checks

This commit is contained in:
2026-05-24 22:24:13 +02:00
parent a78a708757
commit d49fe28f08
12 changed files with 378 additions and 104 deletions
+10
View File
@@ -54,6 +54,10 @@ function setBusy(button, busy) {
button.disabled = busy;
}
function confirmAction(message) {
return window.confirm(message);
}
function renderAuth(auth) {
document.getElementById("auth-status").textContent = auth.status;
document.getElementById("auth-details").textContent = auth.details || "";
@@ -133,6 +137,7 @@ function renderChannels(channels) {
});
node.querySelector(".remove-btn").addEventListener("click", async () => {
if (!confirmAction(`Remove ${channel.name} from tracked channels?`)) return;
await api("/api/channels/remove", {
method: "POST",
body: JSON.stringify({ channel_id: channel.channel_id }),
@@ -321,6 +326,7 @@ async function main() {
});
document.getElementById("scrape-all-btn").addEventListener("click", async (event) => {
if (!confirmAction("Queue scraping for all tracked channels?")) return;
setBusy(event.currentTarget, true);
try {
await api("/api/jobs/scrape", { method: "POST", body: JSON.stringify({}) });
@@ -331,6 +337,7 @@ async function main() {
});
document.getElementById("export-all-btn").addEventListener("click", async (event) => {
if (!confirmAction("Queue export for all tracked channels?")) return;
setBusy(event.currentTarget, true);
try {
await api("/api/jobs/export", { method: "POST", body: JSON.stringify({}) });
@@ -439,6 +446,9 @@ async function main() {
const channels = Array.from(document.querySelectorAll(".continuous-channel-checkbox:checked")).map(
(item) => item.value,
);
if (!runAllTracked && channels.length === 0 && enabled) {
if (!confirmAction("Continuous scraping is enabled with no selected channels. Save anyway?")) return;
}
await api("/api/continuous", {
method: "POST",
body: JSON.stringify({