v0.38.5
This commit is contained in:
1 parent
963ec64398
commit
6fe2aa137b
18 files changed
+157
-88
No files matched your search
@@ -29,7 +29,26 @@ let lastApiLatencyMs = null, sessionCheckPromise = null;
|
||||
let adminAuthChannel = null; try { adminAuthChannel = new BroadcastChannel("rustproxy-admin-session"); adminAuthChannel.addEventListener("message", event => { if (event.data === "locked" && authenticated) lock(false); }); } catch { }
|
||||
let languagePacks = new Map(), defaultLanguage = null;
|
||||
function activePack() { return languagePacks.get(language) || languagePacks.get(defaultLanguage); }
|
||||
function locale() { try { return Intl.getCanonicalLocales(activePack()?.meta.locale || "und")[0]; } catch { return "und"; } }
|
||||
let canonicalLocale = { source: null, value: "und" };
|
||||
function locale() {
|
||||
const source = activePack()?.meta.locale || "und";
|
||||
if (canonicalLocale.source !== source) { let value = "und"; try { value = Intl.getCanonicalLocales(source)[0]; } catch { /* invalid tag */ } canonicalLocale = { source, value }; }
|
||||
return canonicalLocale.value;
|
||||
}
|
||||
// Live views format hundreds of numbers and times per update; constructing a
|
||||
// new Intl formatter for each value (toLocaleString with options) dominated
|
||||
// that work. Formatters are cached per language and options.
|
||||
const intlFormatters = new Map();
|
||||
function intlFormatter(kind, key, create) {
|
||||
const cacheKey = `${locale()}|${kind}|${key}`;
|
||||
let formatter = intlFormatters.get(cacheKey);
|
||||
if (!formatter) { formatter = create(locale()); intlFormatters.set(cacheKey, formatter); }
|
||||
return formatter;
|
||||
}
|
||||
function formatNumber(value, maximumFractionDigits = 0) { return intlFormatter("number", maximumFractionDigits, lang => new Intl.NumberFormat(lang, { maximumFractionDigits })).format(Number(value)); }
|
||||
function formatDateParts(date, withDate, hour12) {
|
||||
return intlFormatter(withDate ? "datetime" : "time", hour12, lang => new Intl.DateTimeFormat(lang, withDate ? { year: "numeric", month: "numeric", day: "numeric", hour: "numeric", minute: "numeric", second: "numeric", hour12 } : { hour: "numeric", minute: "numeric", second: "numeric", hour12 })).format(date);
|
||||
}
|
||||
// Sorting calls a comparator O(n log n) times; String#localeCompare with a
|
||||
// locale/options argument builds a new collator on every call, which made
|
||||
// periodic table re-renders slow. Collators are cached per language.
|
||||
@@ -179,9 +198,9 @@ function setPanel(name, navigate = true) {
|
||||
$("page-label").textContent = t(name); $("page-title").textContent = t(`${name}Title`); const descriptionKey = `${name}Description`, description = t(descriptionKey); $("page-description").textContent = description === descriptionKey ? "" : description; $("page-description").hidden = description === descriptionKey;
|
||||
if (navigate && typeof location !== "undefined" && ["http:", "https:"].includes(location.protocol) && location.pathname !== PANEL_PATHS[name]) history.pushState({ panel: name }, "", PANEL_PATHS[name]);
|
||||
if (name === "web-server" && latestStatus) window.rustProxyWebServer?.renderLive?.(latestStatus, false);
|
||||
if (name === "settings") window.rustProxySettings?.syncLocation?.();
|
||||
if (name === "settings") { if (previousPanel !== name) window.rustProxySettings?.render?.(); window.rustProxySettings?.syncLocation?.(); }
|
||||
window.rustProxyRefresh?.setPanel(name);
|
||||
if (name === "overview") window.rustProxyVhosts?.flushOverviewViews?.();
|
||||
if (name === "overview") { window.rustProxyVhosts?.flushOverviewViews?.(); if (previousPanel !== name) redrawOverviewHistoryCharts(); }
|
||||
if (name === "overview" && previousPanel !== name && typeof latestStatus !== "undefined" && latestStatus) { window.rustProxyStreamDashboard?.render?.(latestStatus, null, false); window.rustProxyDockerDashboard?.render?.(latestStatus, null, false); window.rustProxyBackendDashboard?.render?.(latestStatus, null, false); window.rustProxyExtraOverview?.render?.(latestStatus, false); window.rustProxyWideOverview?.render?.(latestStatus, false); window.rustProxyWebOverview?.render?.(latestStatus, false); }
|
||||
if (name === "docker-vhosts" && previousPanel !== name && authenticated && envelope) void window.rustProxyRefresh?.manual("docker");
|
||||
if (name === "tls") window.rustProxyAcme?.syncLocation?.();
|
||||
@@ -354,7 +373,7 @@ function renderStatusNow(s, systemSample = false) {
|
||||
listeners: s.listeners ? { ...(latestStatus?.listeners || {}), ...s.listeners } : latestStatus?.listeners,
|
||||
logging: s.logging ? { ...(latestStatus?.logging || {}), ...s.logging } : latestStatus?.logging
|
||||
};
|
||||
s = latestStatus; window.rustProxySettings?.render(); if (firstStatus) renderSettings();
|
||||
s = latestStatus; if (currentPanel === "settings") window.rustProxySettings?.render(); if (firstStatus) renderSettings();
|
||||
connected = true; $("connection-label").textContent = t("connected"); $("signal").classList.remove("status-error"); $("app-health-slot").hidden = false; appHealthUpdatedAt = new Date(); renderAppHealth(s); const m = s.metrics;
|
||||
$("metric-ws").textContent = m.websocket_active || 0;
|
||||
$("metric-ws-h1").textContent = m.websocket_h1_active || 0;
|
||||
@@ -381,7 +400,7 @@ function renderStatusNow(s, systemSample = false) {
|
||||
websocketProtocolSamples.h2.push(Number(m.websocket_h2_active) || 0); websocketProtocolSamples.h2 = websocketProtocolSamples.h2.slice(-window.rustProxyOverviewSamples.getLimit());
|
||||
websocketProtocolSamples.h3.push(Number(m.websocket_h3_active) || 0); websocketProtocolSamples.h3 = websocketProtocolSamples.h3.slice(-window.rustProxyOverviewSamples.getLimit());
|
||||
if (!pausedRate) { transformSamples.push(rates.transform); transformSamples = transformSamples.slice(-window.rustProxyOverviewSamples.getLimit()); }
|
||||
redrawOverviewHistoryCharts();
|
||||
if (currentPanel === "overview") redrawOverviewHistoryCharts();
|
||||
const rateText = key => pausedRate ? "-" : `${rates[key].toFixed(1)}/s`;
|
||||
$("request-rate").textContent = pausedRate ? "- req/s" : `${rates.total.toFixed(1)} req/s`;
|
||||
$("rate-total").textContent = rateText("total"); $("rate-h1").textContent = rateText("h1"); $("rate-h2").textContent = rateText("h2"); $("rate-h3").textContent = rateText("h3"); $("rate-transform").textContent = rateText("transform");
|
||||
|
||||
Reference in new issue
Block a user