24 lines
608 B
JavaScript
24 lines
608 B
JavaScript
const rows = document.querySelectorAll("tr[data-path]");
|
|
|
|
async function poll() {
|
|
for (const row of rows) {
|
|
const dot = row.querySelector(".status");
|
|
try {
|
|
const r = await fetch(`${row.dataset.path}/health`, {
|
|
method: "GET",
|
|
cache: "no-store",
|
|
});
|
|
dot.classList.toggle("ok", r.ok);
|
|
dot.classList.toggle("err", !r.ok);
|
|
dot.setAttribute("aria-label", r.ok ? "ok" : "error");
|
|
} catch {
|
|
dot.classList.remove("ok");
|
|
dot.classList.add("err");
|
|
dot.setAttribute("aria-label", "unreachable");
|
|
}
|
|
}
|
|
}
|
|
|
|
poll();
|
|
setInterval(poll, 5000);
|