This commit is contained in:
Mateusz Gruszczyński committed 2026-10-10 20:56:36 +02:00
1 parent f213d853e2
commit 76b8bb7ee2
78 files changed
+7750 -5204

No files matched your search

+22 -6
View File
@@ -217,13 +217,24 @@
generation++; await refresh();
} catch (error) { operationMessage("cache-bans-status", error.message, true); }
}
async function refresh() {
async function loadCache({ signal, isCurrent }) {
if (!authenticated || !envelope || currentPanel !== "cache" || loading) return;
loading = true; const epoch = authEpoch, token = generation; const query = new URLSearchParams({ offset: String(offset), limit: "50" }); if (scope() !== "*") query.set("vhost", scope());
try { const data = await api(`/api/cache?${query}`); if (epoch !== authEpoch || token !== generation || !authenticated) return; render(data); }
catch (error) { if (epoch === authEpoch) { $("cache-panel-state").textContent = error.message; if (error.status === 401) lock(); } }
finally { loading = false; if (token !== generation && authenticated && currentPanel === "cache") void refresh(); }
loading = true;
const epoch = authEpoch, token = generation;
const query = new URLSearchParams({ offset: String(offset), limit: "50" });
if (scope() !== "*") query.set("vhost", scope());
try {
const data = await api(`/api/cache?${query}`, { signal });
if (isCurrent() && token === generation) render(data);
} catch (error) {
if (error?.name !== "AbortError" && epoch === authEpoch && isCurrent()) {
$("cache-panel-state").textContent = error.message;
if (error.status === 401) lock();
}
} finally { loading = false; }
}
function refresh() { return rustProxyRefresh.manual("cache"); }
initializeLiveChartLimit();
$("cache-live-samples")?.addEventListener("change", event => setLiveChartLimit(event.currentTarget.value));
$("cache-scope").addEventListener("change", () => { offset = 0; resetLiveChart(); generation++; void refresh(); });
@@ -319,7 +330,12 @@
offset = 0; generation++; await refresh();
} catch (error) { if (epoch === authEpoch) operationMessage("cache-toolbar-operation-status", error.message, true); } finally { button.disabled = false; }
});
setInterval(() => { if (!document.hidden && $("cache-live").checked) void refresh(); }, 3000);
rustProxyRefresh.register("cache", {
interval: () => rustProxyRefresh.current().cache_seconds,
active: () => currentPanel === "cache" && !!$("cache-live")?.checked,
run: loadCache
});
$("cache-live")?.addEventListener("change", () => rustProxyRefresh.sync());
window.rustProxyCachePanel = {
refresh, configure, reason, reset() {
generation++; offset = 0; resetLiveChart(); closeInvalidation(); closeBans();