From 1239ff524db7e1cd1a743a77481aba8e30b6c955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Mon, 16 Nov 2026 22:27:51 +0100 Subject: [PATCH] v0.38.6 --- CHANGELOG.md | 3 +- docs/API.md | 2 +- docs/DASHBOARD.md | 4 ++ langs/en_US.json | 3 + langs/pl_pl.json | 3 + src/admin/openapi.json | 5 ++ src/admin/preferences.rs | 3 + src/admin/preferences_tests.rs | 14 ++++ src/admin/tests.rs | 3 + src/admin/web/app/chart-scales.js | 102 +++++++++++++++++++++++----- src/admin/web/app/preferences.js | 23 +++++-- src/admin/web/app/runtime.js | 2 +- src/admin/web/css/30-overview.css | 87 ++++++++++++++++++------ src/admin/web/css/50-settings.css | 12 ++-- src/admin/web/css/60-monitoring.css | 19 +++++- src/admin/web/index.html | 5 ++ tests/panel_interface_contract.py | 5 ++ 17 files changed, 245 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11232b8..6c0d5f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,8 @@ Release history focused on **features, settings, default behavior, compatibility Panel-only release: no configuration, API or proxy behavior changes. -- **Chart crosshair:** with **Settings → Appearance → Show X/Y scales on charts** on, pointing at a chart (or touching it) shows dashed guide lines through the pointer with the Y value in the chart's unit and the X sample number; charts with one scale per series show each series' value. It follows the interface scale and corner style and is hidden when axes are off. +- **Value tooltips on charts (optional):** new **Settings → Appearance → Charts → Show values on hover** (off by default). Pointing at a chart (or touching it) shows a Grafana-style tooltip: a dashed vertical line snaps to the nearest sample, each series gets a dot, and the tooltip lists the sample number and every series' name, colour and value at that sample; with X/Y scales also on, a dashed horizontal line marks the Y value under the pointer. Values are read from the plotted lines with the chart's own scale. Preferences API: additive `chart_tooltips` boolean (default `false`). +- **Fix:** with a chart style other than the default (for example colour-blind), the legend colours of Requests per second, Connection activity, HIT / MISS / BYPASS and Transient RAM did not match their lines. - **Switches never share a row with fields:** in the vhost, stream, redirect and Web Service editors a switch that enables fields now takes its own row and a switch after fields starts a new row, so the fields below line up (for example HSTS, security headers, per-client IP rate limit, response identity and diagnostics, WebSocket, retries, keep-alive, passive health, .htaccess). **Override global TLS policy** has its own row above the TLS versions. - **Aligned fields:** fields in one row of an editor or settings form now start their inputs and drop-downs on the same line even when one caption wraps to more lines (for example Tinyauth URL / public login URL, passive health thresholds, Prometheus address / path); multi-line text areas take the whole row. Stacked switches no longer leave large gaps between them, most visible on phones. - **Server-Timing metric names:** the option for the pre-0.38.2 names is now labelled **Legacy (proxy, origin, cache)**; the stored value `legacy` is unchanged. diff --git a/docs/API.md b/docs/API.md index 9fb45b2..dc712a1 100644 --- a/docs/API.md +++ b/docs/API.md @@ -31,7 +31,7 @@ The current bundled `src/admin/openapi.json` declares these operations (among ot | `GET /api/certificates` · `POST /api/certificates/upload` | Certificate inventory/import. | | `POST /api/certificates/inspect` | Read DNS SAN coverage from a managed/external public PEM path for the editor; admin browser session only. | | `GET /api/acme` · `POST /api/acme/issue` · `POST /api/acme/renew` | Managed certificate jobs. | -| `GET/PUT /api/preferences` | Personal UI settings, including theme/layout, optional `interface_icons` and `logo_animation` (both default `false`), `stable_dialog_position` and `switch_controls` (both default `true`). | +| `GET/PUT /api/preferences` | Personal UI settings, including theme/layout, optional `interface_icons` and `logo_animation` (both default `false`), `stable_dialog_position` and `switch_controls` (both default `true`), optional `chart_tooltips` (default `false`). | | `GET /api/dashboard-presets` and named preset operations | Saved Overview presets. | | `GET /docs/openapi.json` | Protected machine-readable API specification. | diff --git a/docs/DASHBOARD.md b/docs/DASHBOARD.md index 37f0201..c23882c 100644 --- a/docs/DASHBOARD.md +++ b/docs/DASHBOARD.md @@ -126,6 +126,10 @@ Under **Settings → Appearance → Charts**, turn on **Show X/Y scales on chart If axis labels look crowded in a small card or on mobile, disable the setting; the default presentation is unchanged. +## Value tooltips on charts + +Under **Settings → Appearance → Charts**, **Show values on hover** is **off by default** and stored per administrator as `chart_tooltips: true|false` in `/api/preferences`. When it is on, pointing at a sampled line chart (or touching it) shows a dashed vertical line at the nearest sample, a dot on each series and a tooltip with the sample number and every series' name, colour and value at that sample, in the chart's unit. Values are read from the plotted lines with the chart's own scale. It works with or without **Show X/Y scales on charts**; with the scales on, a dashed horizontal line also marks the Y value under the pointer. + ## Interpreting charts - The **Cache hit ratio** donut shows cumulative `HIT / (HIT + MISS)`: BYPASS and requests outside cache are deliberately excluded from its denominator. diff --git a/langs/en_US.json b/langs/en_US.json index 017caa7..df976cc 100644 --- a/langs/en_US.json +++ b/langs/en_US.json @@ -2446,8 +2446,11 @@ "chartStyle": "Chart style", "chartAxes": "Show X/Y scales on charts", "chartAxesHelp": "Keep adaptive scaling and all existing chart lines. Y shows the plotted range; X shows sample indices, not elapsed time. Off by default.", + "chartTooltips": "Show values on hover", + "chartTooltipsHelp": "Pointing at a chart (or touching it) shows a dashed line at the nearest sample, a dot on each series and a tooltip with every series' value. Works with or without X/Y scales. Off by default.", "chartAxisSamples": "samples", "chartAxisSamplesHint": "X values are sample indices; gaps and aggregated buckets do not indicate elapsed time.", + "chartAxisSample": "Sample", "chartStyleDefault": "Default", "chartStyleSoft": "Soft", "chartStyleTechnical": "Technical", diff --git a/langs/pl_pl.json b/langs/pl_pl.json index 8a89389..30cee34 100644 --- a/langs/pl_pl.json +++ b/langs/pl_pl.json @@ -2446,8 +2446,11 @@ "chartStyle": "Styl wykresów", "chartAxes": "Pokaż skale X/Y na wykresach", "chartAxesHelp": "Zachowuje automatyczne skalowanie i przebieg linii. Y pokazuje zakres użyty do rysowania, X numer próbki, nie czas. Domyślnie wyłączone.", + "chartTooltips": "Pokazuj wartości po najechaniu", + "chartTooltipsHelp": "Po najechaniu na wykres (lub dotknięciu) pokazuje przerywaną linię przy najbliższej próbce, kropki na seriach i dymek z wartością każdej serii. Działa z osiami X/Y i bez nich. Domyślnie wyłączone.", "chartAxisSamples": "próbki", "chartAxisSamplesHint": "Oś X pokazuje indeksy próbek; przerwy i zagregowane okresy nie oznaczają czasu, jaki upłynął.", + "chartAxisSample": "Próbka", "chartStyleDefault": "Domyślny", "chartStyleSoft": "Łagodny", "chartStyleTechnical": "Techniczny", diff --git a/src/admin/openapi.json b/src/admin/openapi.json index 658f3b0..7b89f04 100644 --- a/src/admin/openapi.json +++ b/src/admin/openapi.json @@ -4159,6 +4159,11 @@ "default": false, "description": "Account-scoped optional X/Y scales on sampled time-series charts. Shows the same Y range used to draw each SVG and X sample indices rather than inferred elapsed time; does not change adaptive scaling." }, + "chart_tooltips": { + "type": "boolean", + "default": false, + "description": "Since 0.38.6. Account-scoped optional value tooltips on sampled time-series charts: pointing at a chart snaps a dashed line to the nearest sample and lists every series' value there. Independent of chart_axes; presentation only." + }, "interface_icons": { "type": "boolean", "default": false, diff --git a/src/admin/preferences.rs b/src/admin/preferences.rs index 10c53d6..c1e1f1e 100644 --- a/src/admin/preferences.rs +++ b/src/admin/preferences.rs @@ -158,6 +158,8 @@ struct AdminPreferences { #[serde(default)] chart_axes: bool, #[serde(default)] + chart_tooltips: bool, + #[serde(default)] interface_icons: bool, #[serde(default)] logo_animation: bool, @@ -237,6 +239,7 @@ impl Default for AdminPreferences { time_format: default_admin_time_format(), chart_style: default_admin_chart_style(), chart_axes: false, + chart_tooltips: false, interface_icons: false, logo_animation: false, stable_dialog_position: default_admin_stable_dialog_position(), diff --git a/src/admin/preferences_tests.rs b/src/admin/preferences_tests.rs index 6737ca5..8ca4e65 100644 --- a/src/admin/preferences_tests.rs +++ b/src/admin/preferences_tests.rs @@ -45,6 +45,7 @@ fn overview_factory_preset_matches_registry_and_operator_visibility() { assert!(hidden.iter().all(|id| order.contains(id))); assert!(validate_admin_preferences(&AdminPreferences::default()).is_ok()); assert!(!AdminPreferences::default().chart_axes); + assert!(!AdminPreferences::default().chart_tooltips); assert!(!AdminPreferences::default().interface_icons); assert!(!AdminPreferences::default().logo_animation); assert!(AdminPreferences::default().stable_dialog_position); @@ -105,6 +106,19 @@ fn optional_interface_icons_preference_is_backward_compatible_and_off_by_default assert!(recovered.interface_icons); } +#[test] +fn optional_chart_tooltips_preference_is_backward_compatible_and_off_by_default() { + let legacy: AdminPreferences = serde_json::from_str(r#"{"chart_axes":true}"#).unwrap(); + assert!(!legacy.chart_tooltips); + let mut enabled = legacy.clone(); + enabled.chart_tooltips = true; + assert!(validate_admin_preferences(&enabled).is_ok()); + let stored = serde_json::to_string(&enabled).unwrap(); + assert!(stored.contains("\"chart_tooltips\":true")); + let recovered: AdminPreferences = serde_json::from_str(&stored).unwrap(); + assert!(recovered.chart_tooltips); +} + #[test] fn optional_chart_axes_preference_is_backward_compatible() { let legacy: AdminPreferences = serde_json::from_str(r#"{"chart_style":"neon"}"#).unwrap(); diff --git a/src/admin/tests.rs b/src/admin/tests.rs index cae50b5..70178a2 100644 --- a/src/admin/tests.rs +++ b/src/admin/tests.rs @@ -2174,6 +2174,7 @@ mod tests { assert_eq!(initial["time_format"], "24h"); assert_eq!(initial["chart_style"], "default"); assert_eq!(initial["chart_axes"], false); + assert_eq!(initial["chart_tooltips"], false); assert_eq!(initial["interface_icons"], false); assert_eq!(initial["logo_animation"], false); assert_eq!(initial["stable_dialog_position"], true); @@ -2225,6 +2226,7 @@ mod tests { assert_eq!(legacy["time_format"], "24h"); assert_eq!(legacy["chart_style"], "default"); assert_eq!(legacy["chart_axes"], false); + assert_eq!(legacy["chart_tooltips"], false); assert_eq!(legacy["interface_icons"], false); assert_eq!(legacy["logo_animation"], false); assert_eq!(legacy["stable_dialog_position"], true); @@ -2251,6 +2253,7 @@ mod tests { "time_format":"12h", "chart_style":"neon", "chart_axes":true, + "chart_tooltips":true, "interface_icons":true, "logo_animation":true, "stable_dialog_position":false, diff --git a/src/admin/web/app/chart-scales.js b/src/admin/web/app/chart-scales.js index 4686ab8..b9e6447 100644 --- a/src/admin/web/app/chart-scales.js +++ b/src/admin/web/app/chart-scales.js @@ -50,25 +50,79 @@ window.rustProxyChartScale = (() => { } return `${format(n)}${unit === "percent" ? "%" : unit === "ms" ? " ms" : unit === "rate" ? "/s" : ""}`; } - // Crosshair: with axes enabled, dashed guide lines follow the pointer and - // label the Y value and X sample under it. Values come from the same - // axis data the overlay uses, so they match the drawn scale. + // Crosshair (Grafana-style): with value tooltips enabled, a dashed vertical line + // snaps to the nearest sample, each series gets a dot, and a tooltip lists + // every series' value at that sample; a dashed horizontal line marks the + // Y value under the pointer. Values are read back from the drawn lines + // with the chart's own axis scale, so they match what is plotted. + function lineSeries(svg) { + const box = svg.viewBox?.baseVal, height = box?.height || svg.clientHeight || 1; + return [...svg.querySelectorAll("polyline, path")].filter(node => !node.classList.contains("chart-grid") && !node.closest(".rp-chart-crosshair")).map(node => { + const style = getComputedStyle(node); + if (style.display === "none" || style.visibility === "hidden" || style.stroke === "none" || Number(style.strokeOpacity) === 0) return null; + const numbers = (node.getAttribute(node.tagName.toLowerCase() === "polyline" ? "points" : "d") || "").match(/-?\d*\.?\d+(?:e[-+]?\d+)?/gi) || []; + const points = []; for (let i = 0; i + 1 < numbers.length; i += 2) points.push([Number(numbers[i]), Number(numbers[i + 1])]); + return points.length ? { node, points, color: style.stroke, height } : null; + }).filter(Boolean); + } + function legendItems(svg) { + const card = svg.closest(".card, .stat, .mini-live-chart, .vhost-chart, .docker-service-metrics, article") || svg.parentElement?.parentElement; + if (!card) return []; + const swatch = item => { + const key = item.querySelector(":scope > i"); + for (const [node, pseudo] of [[key, null], [item, "::before"], [key, "::before"]]) { + if (!node) continue; + const style = getComputedStyle(node, pseudo), visible = value => value && value !== "rgba(0, 0, 0, 0)" && value !== "transparent"; + if (visible(style.backgroundColor)) return style.backgroundColor; + for (const side of ["Top", "Left", "Bottom"]) if (parseFloat(style[`border${side}Width`]) > 0 && visible(style[`border${side}Color`])) return style[`border${side}Color`]; + } + return ""; + }; + return [...card.querySelectorAll("[class*=legend] > span, [class*=legend] > *[class*=key], [class*=-key]")].filter(item => !item.closest("svg, .rp-chart-axis-host") && (item.querySelector(":scope > i") || /(^|\s)\S*(key|legend-)\S*/.test(item.className))).map(item => { + const label = [...item.childNodes].filter(node => node.nodeType === 3 || (node.nodeType === 1 && !["B", "STRONG", "I"].includes(node.tagName))).map(node => node.textContent).join(" ").replace(/\s+/g, " ").trim(); + return label ? { label, color: swatch(item) } : null; + }).filter(Boolean); + } + function seriesName(svg, series, index, legend, scales, total) { + if (total < 2) return ""; + if (scales?.[index]) return scales[index][0]; + const byColor = legend.filter(item => item.color === series.color); + if (byColor.length === 1) return byColor[0].label; + if (legend.length === total) return legend[index].label; + const token = `${series.node.id || ""} ${series.node.getAttribute("class") || ""}`.match(/(?:-|^)(h1|h2|h3|total|transform|hit|miss|bypass|open|exchange|rx|tx|[a-z0-9_]+?)-(?:line|sparkline)\b/i)?.[1]; + return token ? token.replace(/_/g, " ").toUpperCase() : ""; + } function crosshairValues(svg, event) { const data = svg.rustProxyAxisData, box = svg.getBoundingClientRect(); if (!data || !box.width || !box.height) return null; const fx = Math.min(1, Math.max(0, (event.clientX - box.left) / box.width)); const fy = Math.min(1, Math.max(0, (event.clientY - box.top) / box.height)); - const span = data.bottom - data.top || 1, ratio = Math.max(0, (data.bottom - fy) / span); - const sample = data.count > 1 ? Math.round(fx * (data.count - 1)) + 1 : data.count; + const span = data.bottom - data.top || 1, ratio = y => Math.max(0, (data.bottom - y) / span); const scales = Array.isArray(data.seriesScales) && data.seriesScales.length ? data.seriesScales : null; - const y = scales ? scales.map(([name, peak]) => `${name}: ${axisValue(peak * ratio, data.unit)}`).join(" · ") : `Y ${axisValue(data.peak * ratio, data.unit)}`; - return { box, fx, fy, y, x: data.count ? `X ${sample}/${data.count}` : "X –" }; + const series = lineSeries(svg), width = svg.viewBox?.baseVal?.width || box.width; + let snap = fx, sample = data.count > 1 ? Math.round(fx * (data.count - 1)) + 1 : data.count; + const rows = []; + if (series.length) { + const xs = series[0].points.map(([x]) => x), target = fx * width; + let index = 0; for (let i = 1; i < xs.length; i++) if (Math.abs(xs[i] - target) < Math.abs(xs[index] - target)) index = i; + snap = xs[index] / width; + sample = data.count ? Math.min(data.count, Math.max(1, data.count - (xs.length - 1 - index))) : index + 1; + const legend = legendItems(svg); + series.forEach((line, i) => { + const point = line.points.reduce((best, current) => Math.abs(current[0] - xs[index]) < Math.abs(best[0] - xs[index]) ? current : best, line.points[0]); + const peak = scales?.[i]?.[1] ?? data.peak, fraction = point[1] / line.height; + rows.push({ name: seriesName(svg, line, i, legend, scales, series.length), color: line.color, value: axisValue(peak * ratio(fraction), data.unit), fy: fraction }); + }); + } + const y = scales ? "" : `Y ${axisValue(data.peak * ratio(fy), data.unit)}`; + return { box, fx, fy, snap, y, sample, count: data.count, rows }; } + let activeCrosshair = null; function attachCrosshair(host, svg) { const cross = document.createElement("div"); cross.className = "rp-chart-crosshair"; cross.hidden = true; cross.setAttribute("aria-hidden", "true"); - const vertical = document.createElement("i"), horizontal = document.createElement("i"), yLabel = document.createElement("span"), xLabel = document.createElement("span"); - vertical.className = "rp-chart-crosshair-v"; horizontal.className = "rp-chart-crosshair-h"; yLabel.className = "rp-chart-crosshair-y"; xLabel.className = "rp-chart-crosshair-x"; - cross.append(vertical, horizontal, yLabel, xLabel); host.append(cross); + const vertical = document.createElement("i"), horizontal = document.createElement("i"), yLabel = document.createElement("span"), dots = document.createElement("div"), tip = document.createElement("div"); + vertical.className = "rp-chart-crosshair-v"; horizontal.className = "rp-chart-crosshair-h"; yLabel.className = "rp-chart-crosshair-y"; dots.className = "rp-chart-crosshair-dots"; tip.className = "rp-chart-tooltip"; + cross.append(vertical, horizontal, yLabel, dots, tip); host.append(cross); let frame = 0, last = null; const draw = () => { frame = 0; if (!last || !host.isConnected) return; @@ -77,14 +131,24 @@ window.rustProxyChartScale = (() => { // overlay is positioned in the host's own (unscaled) pixels. const hostBox = host.getBoundingClientRect(), scale = host.offsetWidth ? hostBox.width / host.offsetWidth : 1; const left = (values.box.left - hostBox.left) / scale, top = (values.box.top - hostBox.top) / scale, width = values.box.width / scale, height = values.box.height / scale; - const x = left + values.fx * width, y = top + values.fy * height; + const x = left + values.snap * width, y = top + values.fy * height, pointerX = left + values.fx * width; cross.style.setProperty("--rp-cross-left", `${left}px`); cross.style.setProperty("--rp-cross-top", `${top}px`); cross.style.setProperty("--rp-cross-width", `${width}px`); cross.style.setProperty("--rp-cross-height", `${height}px`); cross.style.setProperty("--rp-cross-x", `${x}px`); cross.style.setProperty("--rp-cross-y", `${y}px`); - cross.classList.toggle("is-right", values.fx > .6); cross.classList.toggle("is-low", values.fy > .7); - yLabel.textContent = values.y; xLabel.textContent = values.x; cross.hidden = false; + yLabel.textContent = values.y; yLabel.hidden = !values.y; + dots.replaceChildren(...values.rows.map(row => { const dot = document.createElement("i"); dot.style.left = `${x}px`; dot.style.top = `${top + row.fy * height}px`; dot.style.background = row.color; return dot; })); + const head = document.createElement("b"); head.textContent = values.count ? `${t("chartAxisSample")} ${values.sample}/${values.count}` : "–"; + tip.replaceChildren(head, ...values.rows.map(row => { + const line = document.createElement("span"), key = document.createElement("i"), name = document.createElement("span"), value = document.createElement("strong"); + key.style.background = row.color; name.textContent = row.name; value.textContent = row.value; line.append(key, name, value); return line; + })); + tip.hidden = !values.rows.length; cross.hidden = false; + if (activeCrosshair && activeCrosshair !== cross) activeCrosshair.hidden = true; activeCrosshair = cross; + const hostWidth = host.offsetWidth, tipWidth = tip.offsetWidth || 160, tipHeight = tip.offsetHeight || 40; + const tipLeft = pointerX + 14 + tipWidth > hostWidth ? Math.max(0, pointerX - 14 - tipWidth) : pointerX + 14; + tip.style.left = `${tipLeft}px`; tip.style.top = `${Math.max(0, Math.min(top + height - tipHeight, y - tipHeight / 2))}px`; }; - const move = event => { if (event.target.closest?.(".rp-chart-axis-x, .rp-chart-axis-series")) { cross.hidden = true; return; } last = event; if (!frame) frame = requestAnimationFrame(draw); }; + const move = event => { if (!tooltipsOn() || event.target.closest?.(".rp-chart-axis-x, .rp-chart-axis-series")) { cross.hidden = true; return; } last = event; if (!frame) frame = requestAnimationFrame(draw); }; const leave = () => { last = null; cross.hidden = true; }; host.addEventListener("pointermove", move); host.addEventListener("pointerdown", move); host.addEventListener("pointerleave", leave); host.addEventListener("pointercancel", leave); @@ -92,6 +156,11 @@ window.rustProxyChartScale = (() => { function setAxisText(node, value) { if (node.textContent !== value) node.textContent = value; } + // The overlay host is needed for X/Y scales and for value tooltips; each + // is a separate appearance preference, both off by default. + const axesOn = () => document.documentElement.dataset.chartAxes === "true"; + const tooltipsOn = () => document.documentElement.dataset.chartTooltips === "true"; + const axesWanted = () => axesOn() || tooltipsOn(); function renderAxes(svg) { if (!svg?.isConnected || !svg.rustProxyAxisData) return; let host = svg.parentElement; @@ -123,6 +192,7 @@ window.rustProxyChartScale = (() => { attachCrosshair(host, svg); } const { peak: maximum, unit, count, top, bottom, clipped, seriesScales } = svg.rustProxyAxisData; + host.classList.toggle("rp-chart-axis-off", !axesOn()); const compact = svg.closest(".stat-chart") !== null; host.classList.toggle("rp-chart-axis-compact", compact); const multi = Array.isArray(seriesScales) && seriesScales.length > 0; @@ -163,10 +233,10 @@ window.rustProxyChartScale = (() => { seriesScales: Array.isArray(seriesScales) ? seriesScales.filter(row => Array.isArray(row) && typeof row[0] === "string" && Number.isFinite(row[1]) && row[1] >= 0) : null, }; - if (document.documentElement.dataset.chartAxes === "true") renderAxes(svg); + if (axesWanted()) renderAxes(svg); } function refreshAxes() { - const show = document.documentElement.dataset.chartAxes === "true"; + const show = axesWanted(); for (const svg of document.querySelectorAll("svg:not(.ui-icon)")) { if (show && svg.rustProxyAxisData) renderAxes(svg); else if (!show && svg.parentElement?.classList.contains("rp-chart-axis-host")) { diff --git a/src/admin/web/app/preferences.js b/src/admin/web/app/preferences.js index a8ca21f..d5efbbe 100644 --- a/src/admin/web/app/preferences.js +++ b/src/admin/web/app/preferences.js @@ -13,7 +13,7 @@ const ADMIN_DEFAULT_HIDDEN_WIDGETS = Object.freeze([...new Set([ ])]); const ADMIN_APPEARANCE_DEFAULTS = Object.freeze({ theme: "dark", language: "auto", ui_scale: 100, time_format: "24h", chart_style: "default", - chart_axes: false, interface_icons: false, logo_animation: false, stable_dialog_position: true, switch_controls: true, + chart_axes: false, chart_tooltips: false, interface_icons: false, logo_animation: false, stable_dialog_position: true, switch_controls: true, button_style: "normal", corner_style: "default", table_density: "normal", dashboard_density: ADMIN_DASHBOARD_DEFAULTS.dashboard_density, dashboard_widgets: [...ADMIN_DASHBOARD_WIDGETS], dashboard_hidden_widgets: [...ADMIN_DEFAULT_HIDDEN_WIDGETS], dashboard_widget_sizes: null, dashboard_widget_heights: null, dashboard_widget_positions: null, dashboard_auto_fit: true, sidebar_collapsed: false, }); const CHART_STYLE_KEYS = Object.freeze({ default: "chartStyleDefault", soft: "chartStyleSoft", technical: "chartStyleTechnical", high_contrast: "chartStyleHighContrast", neon: "chartStyleNeon", monochrome: "chartStyleMonochrome", warm: "chartStyleWarm", cool: "chartStyleCool", sunset: "chartStyleSunset", aurora: "chartStyleAurora", ocean: "chartStyleOcean", forest: "chartStyleForest", pastel: "chartStylePastel", terminal: "chartStyleTerminal", blueprint: "chartStyleBlueprint", colorblind: "chartStyleColorblind" }); @@ -137,6 +137,13 @@ function applyAdminChartStyle(value) { const style = normalizeAdminChartStyle(value); document.documentElement.dataset.chartStyle = style; const select = $("ui-chart-style"); if (select) select.value = style; refreshChartStylePalette(style); return style; } +function applyAdminChartTooltips(value) { + const enabled = value === true; + document.documentElement.dataset.chartTooltips = String(enabled); + const input = $("ui-chart-tooltips"); if (input) input.checked = enabled; + window.rustProxyChartScale?.refreshAxes?.(); + return enabled; +} function applyAdminChartAxes(value) { const enabled = value === true; document.documentElement.dataset.chartAxes = String(enabled); @@ -337,7 +344,7 @@ function applyAdminPreferences(value, cache = true) { ...value, refresh: normalizeRefreshPreferences(value.refresh), theme: applyAdminTheme(value.theme, cache), language: applyAdminLanguage(value.language, cache, false), ui_scale: applyAdminUiScale(value.ui_scale, cache), - time_format: applyAdminTimeFormat(value.time_format), chart_style: applyAdminChartStyle(value.chart_style), chart_axes: applyAdminChartAxes(value.chart_axes), interface_icons: applyAdminInterfaceIcons(value.interface_icons), logo_animation: applyAdminLogoAnimation(value.logo_animation), stable_dialog_position: applyAdminStableDialogPosition(value.stable_dialog_position), switch_controls: applyAdminSwitchControls(value.switch_controls), button_style: applyAdminButtonStyle(value.button_style), corner_style: applyAdminCornerStyle(value.corner_style, cache), table_density: applyAdminTableDensity(value.table_density), + time_format: applyAdminTimeFormat(value.time_format), chart_style: applyAdminChartStyle(value.chart_style), chart_axes: applyAdminChartAxes(value.chart_axes), chart_tooltips: applyAdminChartTooltips(value.chart_tooltips), interface_icons: applyAdminInterfaceIcons(value.interface_icons), logo_animation: applyAdminLogoAnimation(value.logo_animation), stable_dialog_position: applyAdminStableDialogPosition(value.stable_dialog_position), switch_controls: applyAdminSwitchControls(value.switch_controls), button_style: applyAdminButtonStyle(value.button_style), corner_style: applyAdminCornerStyle(value.corner_style, cache), table_density: applyAdminTableDensity(value.table_density), dashboard_density: applyAdminDashboardDensity(value.dashboard_density), dashboard_widgets: savedOrder, dashboard_hidden_widgets: savedHidden, dashboard_widget_sizes: savedSizes, dashboard_widget_heights: savedHeights, dashboard_widget_positions: savedPositions, dashboard_auto_fit: savedAutoFit, }; adminPreferences = normalized; @@ -389,7 +396,7 @@ function updateAdminPreferences(patch) { const next = { ...current, ...patch }; next.refresh = normalizeRefreshPreferences(next.refresh); next.theme = normalizeAdminTheme(next.theme); next.language = normalizeAdminLanguage(next.language); next.ui_scale = normalizeAdminUiScale(next.ui_scale); - next.time_format = normalizeAdminTimeFormat(next.time_format); next.chart_style = normalizeAdminChartStyle(next.chart_style); next.chart_axes = next.chart_axes === true; next.interface_icons = next.interface_icons === true; next.logo_animation = next.logo_animation === true; next.stable_dialog_position = next.stable_dialog_position !== false; next.switch_controls = next.switch_controls !== false; next.button_style = normalizeAdminButtonStyle(next.button_style); next.corner_style = normalizeAdminCornerStyle(next.corner_style); next.table_density = normalizeAdminDensity(next.table_density); + next.time_format = normalizeAdminTimeFormat(next.time_format); next.chart_style = normalizeAdminChartStyle(next.chart_style); next.chart_axes = next.chart_axes === true; next.chart_tooltips = next.chart_tooltips === true; next.interface_icons = next.interface_icons === true; next.logo_animation = next.logo_animation === true; next.stable_dialog_position = next.stable_dialog_position !== false; next.switch_controls = next.switch_controls !== false; next.button_style = normalizeAdminButtonStyle(next.button_style); next.corner_style = normalizeAdminCornerStyle(next.corner_style); next.table_density = normalizeAdminDensity(next.table_density); next.dashboard_density = normalizeAdminDensity(next.dashboard_density, "compact"); next.dashboard_widgets = normalizeDashboardWidgets(next.dashboard_widgets); next.dashboard_hidden_widgets = normalizeHiddenDashboardWidgets(next.dashboard_hidden_widgets); next.dashboard_widget_sizes = normalizeDashboardWidgetSizes(next.dashboard_widget_sizes); next.dashboard_widget_heights = normalizeDashboardWidgetHeights(next.dashboard_widget_heights); next.dashboard_widget_positions = normalizeDashboardWidgetPositions(next.dashboard_widget_positions); next.dashboard_auto_fit = next.dashboard_auto_fit !== false; next.sidebar_collapsed = next.sidebar_collapsed === true; const saved = await api("/api/preferences", { method: "PUT", body: JSON.stringify(next) }); if (!authenticated || epoch !== authEpoch) return adminPreferences; @@ -473,6 +480,14 @@ $("ui-chart-axes")?.addEventListener("change", () => { applyAdminChartAxes(previous); }); }); +$("ui-chart-tooltips")?.addEventListener("change", () => { + const control = $("ui-chart-tooltips"), previous = adminPreferences?.chart_tooltips === true, next = control.checked; + applyAdminChartTooltips(next); if (adminPreferences) adminPreferences.chart_tooltips = next; + void saveAppearancePreference({ chart_tooltips: next }, control, () => { + if (adminPreferences) adminPreferences.chart_tooltips = previous; + applyAdminChartTooltips(previous); + }); +}); $("ui-interface-icons")?.addEventListener("change", () => { const control = $("ui-interface-icons"), previous = adminPreferences?.interface_icons === true, next = control.checked; applyAdminInterfaceIcons(next); if (adminPreferences) adminPreferences.interface_icons = next; @@ -536,7 +551,7 @@ async function resetAppearancePatch(patch, control, messageKey = "appearanceSect } document.querySelectorAll("[data-appearance-reset]").forEach(control => control.addEventListener("click", () => { const patches = { - interface: { theme: "dark", language: "auto", ui_scale: 100, time_format: "24h", interface_icons: false, logo_animation: false, stable_dialog_position: true, switch_controls: true, button_style: "normal", corner_style: "default" }, charts: { chart_style: "default", chart_axes: false }, tables: { table_density: "normal" }, + interface: { theme: "dark", language: "auto", ui_scale: 100, time_format: "24h", interface_icons: false, logo_animation: false, stable_dialog_position: true, switch_controls: true, button_style: "normal", corner_style: "default" }, charts: { chart_style: "default", chart_axes: false, chart_tooltips: false }, tables: { table_density: "normal" }, dashboard: { dashboard_density: ADMIN_DASHBOARD_DEFAULTS.dashboard_density, dashboard_widgets: [...ADMIN_DASHBOARD_WIDGETS], dashboard_hidden_widgets: [...ADMIN_APPEARANCE_DEFAULTS.dashboard_hidden_widgets], dashboard_widget_sizes: null, dashboard_widget_heights: null, dashboard_auto_fit: true }, }; void resetAppearancePatch(patches[control.dataset.appearanceReset] || {}, control); diff --git a/src/admin/web/app/runtime.js b/src/admin/web/app/runtime.js index 2b9ac0f..6ae6cf2 100644 --- a/src/admin/web/app/runtime.js +++ b/src/admin/web/app/runtime.js @@ -456,7 +456,7 @@ function renderNetworkInterfaceCharts(interfaces, appendSample) { if (children.length !== target.children.length || children.some((node, index) => node !== target.children[index])) { target.replaceChildren(...children); - if (document.documentElement.dataset.chartAxes === "true") window.rustProxyChartScale.refreshAxes(); + if (document.documentElement.dataset.chartAxes === "true" || document.documentElement.dataset.chartTooltips === "true") window.rustProxyChartScale.refreshAxes(); } } diff --git a/src/admin/web/css/30-overview.css b/src/admin/web/css/30-overview.css index 846972f..244685c 100644 --- a/src/admin/web/css/30-overview.css +++ b/src/admin/web/css/30-overview.css @@ -169,6 +169,11 @@ html[data-theme=cream] :is(.card, .stat, dialog) { gap: 2px; } +/* Value tooltips without X/Y scales: keep the host for the crosshair only. */ +.rp-chart-axis-off :is(.rp-chart-axis-y, .rp-chart-axis-x, .rp-chart-axis-series, .rp-chart-crosshair-h, .rp-chart-crosshair-y) { + display: none; +} + .rp-chart-crosshair { position: absolute; inset: 0; @@ -203,9 +208,11 @@ html[data-theme=cream] :is(.card, .stat, dialog) { border-top-width: 1px; } -.rp-chart-crosshair-y, -.rp-chart-crosshair-x { +.rp-chart-crosshair-y { position: absolute; + top: var(--rp-cross-y); + left: calc(var(--rp-cross-left) + 3px); + transform: translateY(-120%); padding: 1px 4px; border: 1px solid var(--line); border-radius: min(3px, var(--rp-radius-control, 3px)); @@ -214,24 +221,62 @@ html[data-theme=cream] :is(.card, .stat, dialog) { white-space: nowrap; } -.rp-chart-crosshair-y { - top: var(--rp-cross-y); - left: calc(var(--rp-cross-left) + 3px); - transform: translateY(-120%); +.rp-chart-crosshair-y[hidden] { + display: none; } -.rp-chart-crosshair.is-low .rp-chart-crosshair-y { - transform: translateY(20%); +.rp-chart-crosshair-dots>i { + position: absolute; + width: 7px; + height: 7px; + margin: -3.5px 0 0 -3.5px; + border: 1px solid var(--panel); + border-radius: 50%; } -.rp-chart-crosshair-x { - top: calc(var(--rp-cross-top) + var(--rp-cross-height) - 2px); - left: var(--rp-cross-x); - transform: translate(6px, -100%); +.rp-chart-tooltip { + position: absolute; + display: grid; + gap: 2px; + min-width: 120px; + max-width: min(280px, 90%); + padding: 5px 7px; + border: 1px solid var(--line); + border-radius: min(6px, var(--rp-radius-surface, 6px)); + background: color-mix(in srgb, var(--panel) 94%, transparent); + box-shadow: 0 4px 14px var(--shadow-mid); + color: var(--text); + font: 10px/1.35 var(--mono); + font-variant-numeric: tabular-nums; } -.rp-chart-crosshair.is-right .rp-chart-crosshair-x { - transform: translate(calc(-100% - 6px), -100%); +.rp-chart-tooltip[hidden] { + display: none; +} + +.rp-chart-tooltip>b { + color: var(--muted); + font-weight: 500; +} + +.rp-chart-tooltip>span { + display: grid; + grid-template-columns: 8px minmax(0, 1fr) auto; + align-items: center; + gap: 6px; +} + +.rp-chart-tooltip>span>i { + width: 8px; + height: 3px; + border-radius: 2px; +} + +.rp-chart-tooltip>span>span { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + color: var(--muted); } .rp-chart-axis-series { @@ -582,23 +627,23 @@ html[data-theme=cream] :is(.card, .stat, dialog) { width: 12px; height: 2px; display: inline-block; - background: var(--muted); + background: var(--chart-septenary); } .traffic-protocol-legend .legend-h1 i { - background: var(--accent); + background: var(--chart-accent); } .traffic-protocol-legend .legend-h2 i { - background: var(--green); + background: var(--chart-secondary); } .traffic-protocol-legend .legend-h3 i { - background: var(--blue); + background: var(--chart-tertiary); } .traffic-protocol-legend .legend-transform i { - background: var(--transform-chart); + background: var(--chart-quaternary); } .traffic-protocol-legend b { @@ -1027,11 +1072,11 @@ html[data-dashboard-density=ultra] #panel-overview .stat-cache-outcomes .cache-m } .connection-open-key { - color: var(--accent) !important; + color: var(--chart-accent) !important; } .connection-exchange-key { - color: var(--green) !important; + color: var(--chart-secondary) !important; } .dashboard-widget-setting-label { diff --git a/src/admin/web/css/50-settings.css b/src/admin/web/css/50-settings.css index 84821c6..1103b38 100644 --- a/src/admin/web/css/50-settings.css +++ b/src/admin/web/css/50-settings.css @@ -83,7 +83,8 @@ .appearance-logo-animation-setting, .appearance-stable-dialog-position-setting, .appearance-switch-controls-setting, -.appearance-chart-axes-setting { +.appearance-chart-axes-setting, +.appearance-chart-tooltips-setting { align-self: center; min-width: 0; } @@ -92,17 +93,20 @@ .appearance-logo-animation-setting>span, .appearance-stable-dialog-position-setting>span, .appearance-switch-controls-setting>span, -.appearance-chart-axes-setting>span { +.appearance-chart-axes-setting>span, +.appearance-chart-tooltips-setting>span { display: grid; gap: 4px; min-width: 0; } -.appearance-chart-axes-setting>span b { +.appearance-chart-axes-setting>span b, +.appearance-chart-tooltips-setting>span b { font-weight: 600; } -.appearance-chart-axes-setting>span small { +.appearance-chart-axes-setting>span small, +.appearance-chart-tooltips-setting>span small { color: var(--muted); font-size: 10px; line-height: 1.45; diff --git a/src/admin/web/css/60-monitoring.css b/src/admin/web/css/60-monitoring.css index de64dbb..f728277 100644 --- a/src/admin/web/css/60-monitoring.css +++ b/src/admin/web/css/60-monitoring.css @@ -487,11 +487,26 @@ html[data-dashboard-density] #panel-overview .dashboard-overview-grid>.card.pool } .cache-queue-key { - color: var(--blue); + color: var(--chart-tertiary); } .cache-io-key { - color: var(--transform-chart); + color: var(--chart-quaternary); +} + +/* Legend keys use the same chart palette variables as their lines, so they + still match when a chart style (for example colour-blind) is selected. */ +.cache-hit-key, +.cache-fill-key { + color: var(--chart-secondary); +} + +.cache-miss-key { + color: var(--chart-accent); +} + +.cache-bypass-key { + color: var(--chart-tertiary); } .config-history-dialog { diff --git a/src/admin/web/index.html b/src/admin/web/index.html index 62db646..eb02af2 100644 --- a/src/admin/web/index.html +++ b/src/admin/web/index.html @@ -2206,6 +2206,11 @@ chartsKeep automatic scaling; show Y values and sample indices on X (not elapsed time). +