This commit is contained in:
Mateusz Gruszczyński committed 2026-11-25 12:24:26 +01:00
1 parent f3ad1c9d35
commit c0fac56520
19 files changed
+250 -33

No files matched your search

+6 -1
View File
@@ -2,7 +2,7 @@
"openapi": "3.0.3",
"info": {
"title": "RustProxy Administration API",
"version": "0.41.3",
"version": "0.41.4",
"description": "Administration API for the active panel origin. Sign in through the panel; the same-origin HttpOnly cookie authenticates all private operations. Mutations also require the exact Origin, X-RustProxy-Request: 1 and a session-bound X-CSRF-Token. Loopback HTTP is the default; Settings can enable HTTPS before using a non-loopback administration bind. This document contains no live configuration or credentials. Object schemas marked extensible are summaries: full configuration validation is authoritative in Rust. The API also permits explicitly scoped GeneralApiBearer tokens on a narrow route allowlist, with RO/RW and source CIDR checks; API-token management and Prometheus-token management are browser-session-only."
},
"servers": [
@@ -4889,6 +4889,11 @@
"default": false,
"description": "Account-scoped sort direction for the Backends diagnostics table."
},
"backend_table_responsive_charts": {
"type": "boolean",
"default": false,
"description": "Account-scoped option to expand the Requests, Latency and Traffic mini charts to the available Backends table column width."
},
"vhost_list_sort": {
"type": "string",
"enum": [
+3
View File
@@ -201,6 +201,8 @@ struct AdminPreferences {
backend_table_sort: String,
#[serde(default)]
backend_table_descending: bool,
#[serde(default)]
backend_table_responsive_charts: bool,
#[serde(default = "default_vhost_list_sort")]
vhost_list_sort: String,
#[serde(default)]
@@ -261,6 +263,7 @@ impl Default for AdminPreferences {
backend_table_columns: default_backend_table_columns(),
backend_table_sort: default_backend_table_sort(),
backend_table_descending: false,
backend_table_responsive_charts: false,
vhost_list_sort: default_vhost_list_sort(),
vhost_list_descending: false,
docker_vhost_sort: default_docker_vhost_sort(),
+4 -1
View File
@@ -2201,6 +2201,7 @@ mod tests {
.any(|column| column == "probe"));
assert_eq!(initial["backend_table_sort"], "vhost");
assert_eq!(initial["backend_table_descending"], false);
assert_eq!(initial["backend_table_responsive_charts"], false);
assert!(store
.save_admin_preferences("owner", r#"{"live_log_columns":["time","status"]}"#)
@@ -2243,6 +2244,7 @@ mod tests {
);
assert_eq!(legacy["backend_table_sort"], "vhost");
assert_eq!(legacy["backend_table_descending"], false);
assert_eq!(legacy["backend_table_responsive_charts"], false);
let selected = json!({
"refresh":{"live_enabled":false,"overview_seconds":10,"traffic_seconds":0,"cache_seconds":3,"system_info_seconds":300},
@@ -2267,7 +2269,8 @@ mod tests {
"file_log_columns":["time","event","client_ip","record"],
"backend_table_columns":["vhost","backend","status","requests","latency"],
"backend_table_sort":"requests",
"backend_table_descending":true
"backend_table_descending":true,
"backend_table_responsive_charts":true
});
let normalized = serde_json::to_value(
serde_json::from_value::<AdminPreferences>(selected.clone()).unwrap(),
+39 -2
View File
@@ -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;
+7
View File
@@ -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;
+6 -1
View File
@@ -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>
+19 -6
View File
@@ -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; };