v0.41.4
This commit is contained in:
1 parent
f3ad1c9d35
commit
c0fac56520
19 files changed
+250
-33
No files matched your search
@@ -3101,7 +3101,7 @@ html[data-dashboard-density] #panel-overview .stat :is(.stat-chart-legend, .over
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.bo-latency>span {
|
||||
.bo-latency-content>span {
|
||||
display: inline-block;
|
||||
min-width: 62px;
|
||||
}
|
||||
@@ -3808,7 +3808,7 @@ html[data-table-density=ultra] .bo-traffic-text {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.bo-causes {
|
||||
.bo-causes-content {
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
@@ -3840,6 +3840,43 @@ html[data-table-density=ultra] .bo-traffic-text {
|
||||
font: 11px var(--mono);
|
||||
}
|
||||
|
||||
/* Keep the ordinary table layout when the option is disabled. In responsive
|
||||
mode only the three sparkline columns consume surplus table width. Native
|
||||
table sizing still preserves intrinsic text widths and horizontal scrolling. */
|
||||
.bo-table.bo-responsive-charts {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.bo-table.bo-responsive-charts :is(th, td)[data-bo-column]:not([data-bo-column="requests"], [data-bo-column="latency"], [data-bo-column="traffic"]) {
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.bo-table.bo-responsive-charts :is(.bo-requests, .bo-latency, .bo-traffic) {
|
||||
min-width: 0;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.bo-table.bo-responsive-charts .bo-latency-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.bo-table.bo-responsive-charts :is(.bo-requests .bo-chartcell>span, .bo-latency-content>span, .bo-traffic-text) {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.bo-table.bo-responsive-charts .bo-spark {
|
||||
width: 0;
|
||||
min-width: 44px;
|
||||
margin-left: 0;
|
||||
flex: 1 1 0;
|
||||
}
|
||||
|
||||
.bo-table.bo-responsive-charts .bo-spark :is(polyline, line) {
|
||||
vector-effect: non-scaling-stroke;
|
||||
}
|
||||
|
||||
html[data-table-density=ultra] .bo-pair small {
|
||||
display: inline;
|
||||
margin-left: 6px;
|
||||
|
||||
@@ -286,6 +286,13 @@
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.backend-column-options .bo-responsive-option {
|
||||
grid-column: 1 / -1;
|
||||
padding-bottom: 8px;
|
||||
margin-bottom: 4px;
|
||||
border-bottom: 1px solid var(--row-line);
|
||||
}
|
||||
|
||||
.location-summary {
|
||||
overflow-wrap: anywhere;
|
||||
cursor: pointer;
|
||||
|
||||
@@ -715,7 +715,12 @@
|
||||
id="bo-sort-direction" type="button">↑</button>
|
||||
<details class="backend-column-picker">
|
||||
<summary class="quiet" data-i18n="backendColumns">Columns</summary>
|
||||
<div class="backend-column-options" id="bo-column-options"></div>
|
||||
<div class="backend-column-options" id="bo-column-options">
|
||||
<label class="check bo-responsive-option">
|
||||
<input class="switch" id="bo-responsive-charts" type="checkbox" />
|
||||
<span data-i18n="backendResponsiveCharts">Responsive charts</span>
|
||||
</label>
|
||||
</div>
|
||||
</details>
|
||||
<button class="quiet" data-i18n="vhManage" id="bo-open" type="button">Manage
|
||||
vhosts</button>
|
||||
|
||||
@@ -155,7 +155,7 @@ const poolColumns = ["vhost", "backend", "status", "active", "requests", "errors
|
||||
const poolOptionalColumns = ["rate", "p95", "probe", "causes", "protocol"];
|
||||
const vhostSortColumns = ["id", "hostname", "status", "listeners", "certificate", "backends"];
|
||||
const defaultPoolColumns = () => poolColumns.filter(key => !poolOptionalColumns.includes(key));
|
||||
const defaultPoolTablePrefs = () => ({ sort: "vhost", descending: false, columns: defaultPoolColumns() });
|
||||
const defaultPoolTablePrefs = () => ({ sort: "vhost", descending: false, columns: defaultPoolColumns(), responsiveCharts: false });
|
||||
const defaultVhostListPrefs = () => ({ sort: "id", descending: false });
|
||||
let poolTablePrefs = defaultPoolTablePrefs(), vhostListPrefs = defaultVhostListPrefs(), poolPreferenceSaveRunning = false, poolPreferenceSaveQueued = false;
|
||||
function normalizePoolTablePrefs(preferences) {
|
||||
@@ -164,6 +164,7 @@ function normalizePoolTablePrefs(preferences) {
|
||||
sort: poolColumns.includes(preferences?.backend_table_sort) ? preferences.backend_table_sort : "vhost",
|
||||
descending: preferences?.backend_table_descending === true,
|
||||
columns: selected.length ? selected : defaultPoolColumns(),
|
||||
responsiveCharts: preferences?.backend_table_responsive_charts === true,
|
||||
};
|
||||
}
|
||||
function normalizeVhostListPrefs(preferences) {
|
||||
@@ -175,7 +176,8 @@ function syncVhostSortDirection() {
|
||||
control.setAttribute("aria-label", t(vhostListPrefs.descending ? "backendSortDescending" : "backendSortAscending"));
|
||||
}
|
||||
function applyPreferences(preferences) {
|
||||
poolTablePrefs = normalizePoolTablePrefs(preferences);
|
||||
// A queued local change must survive the response to an earlier save.
|
||||
if (!poolPreferenceSaveQueued) poolTablePrefs = normalizePoolTablePrefs(preferences);
|
||||
vhostListPrefs = normalizeVhostListPrefs(preferences);
|
||||
const poolSort = $("pool-sort"); if (poolSort) poolSort.value = poolTablePrefs.sort;
|
||||
const vhostSort = $("vhost-sort"); if (vhostSort) vhostSort.value = vhostListPrefs.sort;
|
||||
@@ -200,6 +202,7 @@ async function savePoolTablePrefs() {
|
||||
backend_table_columns: poolColumns.filter(key => poolTablePrefs.columns.includes(key)),
|
||||
backend_table_sort: poolTablePrefs.sort,
|
||||
backend_table_descending: poolTablePrefs.descending,
|
||||
backend_table_responsive_charts: poolTablePrefs.responsiveCharts,
|
||||
});
|
||||
if (!authenticated) return;
|
||||
if (!poolPreferenceSaveQueued) poolTablePrefs = normalizePoolTablePrefs(saved);
|
||||
@@ -212,6 +215,8 @@ function syncPoolColumns() {
|
||||
const visible = new Set(poolTablePrefs.columns);
|
||||
document.querySelectorAll("[data-pool-column]").forEach(node => { node.hidden = !visible.has(node.dataset.poolColumn); });
|
||||
document.querySelectorAll("[data-pool-column-toggle]").forEach(input => { input.checked = visible.has(input.dataset.poolColumnToggle); });
|
||||
const responsive = $("bo-responsive-charts"); if (responsive) responsive.checked = poolTablePrefs.responsiveCharts;
|
||||
$("bo-rows")?.closest(".bo-table")?.classList.toggle("bo-responsive-charts", poolTablePrefs.responsiveCharts && ["requests", "latency", "traffic"].some(key => visible.has(key)));
|
||||
}
|
||||
function syncPoolSortDirection() {
|
||||
for (const id of ["pool-sort-direction", "bo-sort-direction"]) {
|
||||
@@ -257,6 +262,10 @@ function initPoolTableTools() {
|
||||
$("pool-search")?.addEventListener("input", applyPoolTableView);
|
||||
$("bo-search")?.addEventListener("input", applyBackendOverviewView);
|
||||
$("bo-open")?.addEventListener("click", () => setPanel("vhosts"));
|
||||
$("bo-responsive-charts")?.addEventListener("change", event => {
|
||||
poolTablePrefs.responsiveCharts = event.currentTarget.checked;
|
||||
syncPoolColumns(); applyBackendOverviewView(); void savePoolTablePrefs();
|
||||
});
|
||||
document.querySelectorAll("[data-pool-column-toggle]").forEach(input => input.addEventListener("change", () => {
|
||||
const visible = new Set(poolTablePrefs.columns);
|
||||
if (input.checked) visible.add(input.dataset.poolColumnToggle); else visible.delete(input.dataset.poolColumnToggle);
|
||||
@@ -274,7 +283,7 @@ let boItems = [], boFilter = "all", boHasProxy = true;
|
||||
function buildBackendOverviewTools() {
|
||||
const sort = $("bo-sort"), options = $("bo-column-options");
|
||||
if (sort && !sort.options.length) for (const key of poolColumns) { const option = el("option", t(BO_SORT_LABELS[key])); option.value = key; option.dataset.i18n = BO_SORT_LABELS[key]; sort.append(option); }
|
||||
if (options && !options.children.length) for (const key of poolColumns) {
|
||||
if (options && !options.querySelector("[data-pool-column-toggle]")) for (const key of poolColumns) {
|
||||
const label = el("label", undefined, "check"), input = el("input"), text = el("span", t(BO_SORT_LABELS[key]));
|
||||
input.type = "checkbox"; input.dataset.poolColumnToggle = key; text.dataset.i18n = BO_SORT_LABELS[key]; label.append(input, text); options.append(label);
|
||||
}
|
||||
@@ -337,6 +346,7 @@ const BO_SVG = "http://www.w3.org/2000/svg";
|
||||
function boSvg(width, kind) {
|
||||
const svg = document.createElementNS(BO_SVG, "svg");
|
||||
svg.setAttribute("viewBox", `0 0 ${width} 20`); svg.setAttribute("class", `bo-spark bo-spark-${kind}`); svg.setAttribute("aria-hidden", "true");
|
||||
if (poolTablePrefs.responsiveCharts) svg.setAttribute("preserveAspectRatio", "none");
|
||||
boBaseline(svg, width, kind === "latency" ? 10 : 19);
|
||||
return svg;
|
||||
}
|
||||
@@ -449,8 +459,10 @@ const BO_EXTRA_CELLS = {
|
||||
causes(cell, extra) {
|
||||
cell.className = "bo-causes"; cell.title = extra.text.causes;
|
||||
if (!extra.causes.length) { cell.append(el("span", "-", "is-zero")); return; }
|
||||
for (const cause of extra.causes.slice(0, 3)) { const chip = el("span", undefined, `bo-cause${cause.label === "retry" ? " is-soft" : ""}`); chip.append(cause.label, el("b", String(cause.value))); cell.append(chip); }
|
||||
if (extra.causes.length > 3) cell.append(el("small", `+${extra.causes.length - 3}`));
|
||||
const wrap = el("div", undefined, "bo-causes-content");
|
||||
for (const cause of extra.causes.slice(0, 3)) { const chip = el("span", undefined, `bo-cause${cause.label === "retry" ? " is-soft" : ""}`); chip.append(cause.label, el("b", String(cause.value))); wrap.append(chip); }
|
||||
if (extra.causes.length > 3) wrap.append(el("small", `+${extra.causes.length - 3}`));
|
||||
cell.append(wrap);
|
||||
},
|
||||
protocol(cell, extra) {
|
||||
cell.className = "bo-pair"; cell.title = `H1 ${extra.h1} · H2 ${extra.h2}`;
|
||||
@@ -520,7 +532,8 @@ function applyBackendOverviewView() {
|
||||
top.append(el("span", String(item.errors), item.errors ? "" : "is-zero"), el("small", item.errors ? (pct < 0.1 ? "<0.1%" : `${pct.toFixed(pct < 10 ? 1 : 0)}%`) : "0%"));
|
||||
fill.style.width = `${item.errors ? Math.min(100, Math.max(4, pct)) : 0}%`; if (pct >= 5) fill.className = "is-high"; track.append(fill); cell.className = "bo-errors"; cell.append(top, track);
|
||||
} else if (id === "latency") {
|
||||
cell.className = "bo-latency"; cell.append(el("span", item.latency > 0 ? `${item.latency.toFixed(1)} ms` : "-", item.latency > 0 ? "" : "is-zero"), boSparkline(boSeriesOf(item).latency, item.latency));
|
||||
cell.className = "bo-latency"; const wrap = el("div", undefined, "bo-latency-content");
|
||||
wrap.append(el("span", item.latency > 0 ? `${item.latency.toFixed(1)} ms` : "-", item.latency > 0 ? "" : "is-zero"), boSparkline(boSeriesOf(item).latency, item.latency)); cell.append(wrap);
|
||||
} else if (id === "traffic") {
|
||||
cell.className = "bo-traffic"; const wrap = el("div", undefined, "bo-chartcell"), text = el("div", undefined, "bo-traffic-text"); wrap.title = `${rateBytes(item.traffic)}/s`;
|
||||
const line = (kind, label, value) => { const row = el("div", undefined, `bo-${kind}`); row.append(el("span", label), el("b", `${rateBytes(value)}/s`, value > 0 ? "" : "is-zero")); return row; };
|
||||
|
||||
Reference in new issue
Block a user