This commit is contained in:
Mateusz Gruszczyński committed 2026-11-20 17:18:02 +01:00
1 parent 5e43752041
commit 15425fb803
34 files changed
+1423 -89

No files matched your search

+15 -5
View File
@@ -31,8 +31,8 @@
const selected = scope(), options = [el("option", t("logAllVhosts"))];
options[0].value = "*";
for (const vhost of data.vhosts || []) {
const option = el("option", `${vhost.id} / ${(vhost.hosts || []).join(", ")}`);
option.value = vhost.id; options.push(option);
const option = el("option", vhost.label || `${vhost.id} / ${(vhost.hosts || []).join(", ")}`);
option.value = vhost.id; option.title = vhost.id; options.push(option);
}
$("traffic-scope").replaceChildren(...options);
$("traffic-scope").value = options.some(option => option.value === selected) ? selected : "*";
@@ -117,12 +117,22 @@
loading = true;
try {
const base = `/api/traffic?vhost=${encodeURIComponent(scope())}`;
let data = await api(staticData ? `${base}&view=live` : base, { signal });
if (staticData && data.revision !== staticRevision) {
let data;
try {
data = await api(staticData ? `${base}&view=live` : base, { signal });
} catch (error) {
// Labels are inventory-derived. If the selected publication
// vanished, fall back to All rather than polling a stale ID.
if (error?.status !== 404 || scope() === "*") throw error;
$("traffic-scope").value = "*";
staticData = null; staticRevision = null;
data = await api("/api/traffic?vhost=*", { signal });
}
if (staticData && (data.revision !== staticRevision || data.catalog_version !== staticData.catalog_version)) {
data = await api(base, { signal });
}
if (Array.isArray(data.vhosts)) {
staticData = { vhosts: data.vhosts };
staticData = { vhosts: data.vhosts, catalog_version: data.catalog_version };
staticRevision = data.revision;
} else if (staticData) {
data = { ...staticData, ...data };