Refactor server state and add health checks
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
<a class="nav-link active" href="/">Dashboard</a>
|
||||
<a class="nav-link" href="/viewer">Message Viewer</a>
|
||||
<a class="nav-link" href="/swagger">API Docs</a>
|
||||
<a class="nav-link" href="/health">Health</a>
|
||||
</nav>
|
||||
|
||||
<section class="status-card">
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
</div>
|
||||
<nav class="nav-links">
|
||||
<a class="nav-link" href="/openapi.json">openapi.json</a>
|
||||
<a class="nav-link" href="/health">Health</a>
|
||||
<a class="nav-link" href="/viewer">Message Viewer</a>
|
||||
</nav>
|
||||
</aside>
|
||||
|
||||
Reference in New Issue
Block a user