add connected instances list to aprelay
This commit is contained in:
@@ -64,3 +64,37 @@ async function loadStats() {
|
||||
loadStats();
|
||||
setInterval(loadStats, 300000);
|
||||
|
||||
async function loadInstanceStatuses() {
|
||||
const bodyEl = document.getElementById("instances-body");
|
||||
const updatedEl = document.getElementById("instances-updated");
|
||||
if (!bodyEl || !updatedEl) return;
|
||||
|
||||
try {
|
||||
const res = await fetch("aprelay_instances.json", { cache: "no-store" });
|
||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||
|
||||
const data = await res.json();
|
||||
const instances = Array.isArray(data.instances) ? data.instances : [];
|
||||
updatedEl.textContent = data.generated_at || "–";
|
||||
|
||||
if (!instances.length) {
|
||||
bodyEl.innerHTML = `<div class="instances-row"><span class="mono">No data</span><span>–</span></div>`;
|
||||
return;
|
||||
}
|
||||
|
||||
bodyEl.innerHTML = instances.map(x => `
|
||||
<div class="instances-row" role="row">
|
||||
<span class="mono" role="cell">${x.domain}</span>
|
||||
<span role="cell">${x.status}</span>
|
||||
</div>
|
||||
`).join("");
|
||||
} catch (e) {
|
||||
bodyEl.innerHTML = `<div class="instances-row"><span class="mono">Error loading list</span><span>–</span></div>`;
|
||||
updatedEl.textContent = "–";
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
loadInstanceStatuses();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user