v0.38.4
This commit is contained in:
1 parent
2d0d0f12c7
commit
963ec64398
11 files changed
+114
-28
No files matched your search
@@ -220,7 +220,14 @@ function syncPoolSortDirection() {
|
||||
control.setAttribute("aria-label", t(poolTablePrefs.descending ? "backendSortDescending" : "backendSortAscending"));
|
||||
}
|
||||
}
|
||||
// The backend pool and backend overview tables live on Overview. Rebuilding
|
||||
// them on every live snapshot while another panel is shown cost tens of
|
||||
// milliseconds per update; defer them until Overview is shown again.
|
||||
let overviewViewsPending = false;
|
||||
const overviewViewsHidden = () => typeof currentPanel !== "undefined" && currentPanel !== "overview";
|
||||
function flushOverviewViews() { if (!overviewViewsPending) return; overviewViewsPending = false; applyPoolTableView(); }
|
||||
function applyPoolTableView() {
|
||||
if (overviewViewsHidden()) { overviewViewsPending = true; return; }
|
||||
for (const id of ["pool-sort", "bo-sort"]) { const control = $(id); if (control && control.value !== poolTablePrefs.sort) control.value = poolTablePrefs.sort; }
|
||||
applyBackendOverviewView();
|
||||
const body = $("pool-rows"); if (!body) return;
|
||||
@@ -229,7 +236,7 @@ function applyPoolTableView() {
|
||||
const rows = [...body.querySelectorAll("tr")];
|
||||
rows.sort((left, right) => {
|
||||
const a = left.poolSort?.[key] ?? "", b = right.poolSort?.[key] ?? "";
|
||||
const result = typeof a === "number" && typeof b === "number" ? a - b : String(a).localeCompare(String(b), locale(), { numeric: true, sensitivity: "base" });
|
||||
const result = typeof a === "number" && typeof b === "number" ? a - b : compareText(a, b);
|
||||
return poolTablePrefs.descending ? -result : result;
|
||||
});
|
||||
body.replaceChildren(...rows);
|
||||
@@ -371,7 +378,7 @@ function boTrafficChart(inSamples, outSamples) {
|
||||
}
|
||||
return svg;
|
||||
}
|
||||
function renderBackendOverview(items, hasProxy, snapshot = null) {
|
||||
function renderBackendOverview(items, hasProxy, snapshot = null, apply = true) {
|
||||
boItems = items; boHasProxy = hasProxy !== false;
|
||||
const seen = new Set(), sample = snapshot === null || snapshot !== boSnapshot;
|
||||
boSnapshot = snapshot;
|
||||
@@ -389,7 +396,7 @@ function renderBackendOverview(items, hasProxy, snapshot = null) {
|
||||
for (const key of boSeries.keys()) if (!seen.has(key)) boSeries.delete(key);
|
||||
for (const key of boOpen) if (!seen.has(key)) boOpen.delete(key);
|
||||
$("backend-overview-card")?.classList.toggle("is-no-proxy", !boHasProxy);
|
||||
applyBackendOverviewView();
|
||||
if (apply) applyBackendOverviewView();
|
||||
}
|
||||
function boStack(parts) {
|
||||
const track = el("div", undefined, "bo-stack"), total = parts.reduce((sum, [value]) => sum + value, 0);
|
||||
@@ -453,6 +460,7 @@ const BO_EXTRA_CELLS = {
|
||||
},
|
||||
};
|
||||
function applyBackendOverviewView() {
|
||||
if (overviewViewsHidden()) { overviewViewsPending = true; return; }
|
||||
const body = $("bo-rows"); if (!body) return;
|
||||
const visibleColumns = new Set(poolTablePrefs.columns);
|
||||
const query = ($("bo-search")?.value || "").trim().toLowerCase();
|
||||
@@ -473,7 +481,7 @@ function applyBackendOverviewView() {
|
||||
const list = boItems.filter(item => (boFilter === "all" || item.group === boFilter) && (!query || item.search.includes(query)));
|
||||
list.sort((left, right) => {
|
||||
const a = left.sort[key] ?? "", b = right.sort[key] ?? "";
|
||||
const result = typeof a === "number" && typeof b === "number" ? a - b : String(a).localeCompare(String(b), locale(), { numeric: true, sensitivity: "base" });
|
||||
const result = typeof a === "number" && typeof b === "number" ? a - b : compareText(a, b);
|
||||
return poolTablePrefs.descending ? -result : result;
|
||||
});
|
||||
const showIdentity = visibleColumns.has("vhost") || visibleColumns.has("backend"), showEvent = visibleColumns.has("lastFailure") || visibleColumns.has("lastRecovery");
|
||||
@@ -607,7 +615,7 @@ function render() {
|
||||
backends: Number(v.backends?.length || 0),
|
||||
}[vhostListPrefs.sort]);
|
||||
visibleVhosts.sort((left, right) => {
|
||||
const a = sortValue(left), b = sortValue(right); const result = typeof a === "number" && typeof b === "number" ? a - b : String(a).localeCompare(String(b), locale(), { numeric: true, sensitivity: "base" });
|
||||
const a = sortValue(left), b = sortValue(right); const result = typeof a === "number" && typeof b === "number" ? a - b : compareText(a, b);
|
||||
return vhostListPrefs.descending ? -result : result;
|
||||
});
|
||||
const cards = visibleVhosts.map(v => {
|
||||
@@ -840,7 +848,7 @@ function renderStatus(status) {
|
||||
vhost.source?.type !== "web_server" || (vhost.routes || []).some(route => !route.response && (route.source?.type || "reverse_proxy") === "reverse_proxy")
|
||||
);
|
||||
$("pool-rows").replaceChildren(...rows);
|
||||
renderBackendOverview(overviewItems, hasConfiguredProxySource, status);
|
||||
renderBackendOverview(overviewItems, hasConfiguredProxySource, status, false);
|
||||
const backendDiagnosticsCard = $("backend-diagnostics-card");
|
||||
backendDiagnosticsCard?.classList.toggle("is-no-proxy", !hasConfiguredProxySource);
|
||||
applyPoolTableView();
|
||||
@@ -939,5 +947,5 @@ $("pool-open").addEventListener("click", () => setPanel("vhosts"));
|
||||
initPoolTableTools();
|
||||
$("location-help-close")?.addEventListener("click", () => $("location-help-dialog")?.close());
|
||||
window.rustProxyDrafts.register("vhost", { labelKey: "vhosts", isOpen: () => dialog.open, isDirty: () => dirty, suspend: suspendDraft, restore: restoreDraft, close: () => { dirty = false; if (dialog.open) dialog.close(); } });
|
||||
window.rustProxyVhosts = { render, renderStatus, applyPreferences, reset() { closeVhostBackendPopup(); dialog.close(); draftEpoch++; stagedCertificates = []; uploading = false; editing = null; revision = null; dirty = false; initialized = false; backendHealthEditorControl = null; poolTablePrefs = defaultPoolTablePrefs(); vhostListPrefs = defaultVhostListPrefs(); poolPreferenceSaveRunning = false; poolPreferenceSaveQueued = false; chartHistory.clear(); backendTrafficHistory.clear(); backendRequestHistory.clear(); vhostTrafficHistory.clear(); container.replaceChildren(); $("vhost-search").value = ""; if ($("pool-search")) $("pool-search").value = ""; $("vhost-list").replaceChildren(); $("pool-rows").replaceChildren(); const sort = $("pool-sort"); if (sort) sort.value = poolTablePrefs.sort; const vhostSort = $("vhost-sort"); if (vhostSort) vhostSort.value = vhostListPrefs.sort; syncVhostSortDirection(); applyPoolTableView(); } };
|
||||
window.rustProxyVhosts = { render, renderStatus, applyPreferences, flushOverviewViews, reset() { closeVhostBackendPopup(); dialog.close(); draftEpoch++; stagedCertificates = []; uploading = false; editing = null; revision = null; dirty = false; initialized = false; backendHealthEditorControl = null; poolTablePrefs = defaultPoolTablePrefs(); vhostListPrefs = defaultVhostListPrefs(); poolPreferenceSaveRunning = false; poolPreferenceSaveQueued = false; chartHistory.clear(); backendTrafficHistory.clear(); backendRequestHistory.clear(); vhostTrafficHistory.clear(); container.replaceChildren(); $("vhost-search").value = ""; if ($("pool-search")) $("pool-search").value = ""; $("vhost-list").replaceChildren(); $("pool-rows").replaceChildren(); const sort = $("pool-sort"); if (sort) sort.value = poolTablePrefs.sort; const vhostSort = $("vhost-sort"); if (vhostSort) vhostSort.value = vhostListPrefs.sort; syncVhostSortDirection(); applyPoolTableView(); } };
|
||||
if (envelope) render(); if (latestStatus) renderStatus(latestStatus);
|
||||
Reference in new issue
Block a user