From 1bf8a34a97cd03fa29cffa6c9bec16d971368605 Mon Sep 17 00:00:00 2001 From: Developer Date: Wed, 15 Jul 2026 19:15:06 +0000 Subject: [PATCH] fix(charting): remove duplicate range selector --- docs/REQUIREMENTS.md | 2 +- frontend/src/components/LineSeriesChart.tsx | 10 +++++++--- .../components/__tests__/LineSeriesChart.test.tsx | 7 +++++++ frontend/src/widgets/MetricChartWidget.tsx | 8 +------- frontend/src/widgets/QbittorrentSpeedWidget.tsx | 12 +----------- .../src/widgets/__tests__/MetricChartWidget.test.tsx | 3 +++ .../__tests__/QbittorrentSpeedWidget.test.tsx | 3 +++ 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/docs/REQUIREMENTS.md b/docs/REQUIREMENTS.md index e6e5f60..126780b 100644 --- a/docs/REQUIREMENTS.md +++ b/docs/REQUIREMENTS.md @@ -46,7 +46,7 @@ fully removed (web-ui-rework; see decision log 2026-06-17). ### Tables -- All in-app time-series widgets should use the shared range-aware `LineSeriesChart` component so range controls, filtering, and display formatting remain consistent across Prometheus and qBittorrent charts. The selector offers 5 minutes, 15 minutes, 30 minutes, 1 hour, 3 hours, 6 hours, 12 hours, 24 hours, 2 days, 7 days, 14 days, 30 days, and **All values**; sources with bounded local retention expose the finite windows they can retain plus all retained values. +- All in-app time-series widgets should use the shared range-aware `LineSeriesChart` component so filtering and display formatting remain consistent across Prometheus and qBittorrent charts. A dashboard widget's configured window is its single source of range selection and the card renders the complete configured response; the standalone qBittorrent service-history page retains an interactive selector with **All values** for all retained samples. - Tabular surfaces use **TanStack Table** (`@tanstack/react-table`) behind a `DataTable` wrapper (`components/ui/data-table.tsx`). diff --git a/frontend/src/components/LineSeriesChart.tsx b/frontend/src/components/LineSeriesChart.tsx index 6cc02ce..533f87e 100644 --- a/frontend/src/components/LineSeriesChart.tsx +++ b/frontend/src/components/LineSeriesChart.tsx @@ -76,6 +76,8 @@ interface LineSeriesChartProps { scale?: MetricScale; /** Available displayed time ranges. Defaults to the shared range choices. */ rangeOptions?: readonly ChartRangeOption[]; + /** Whether to render the interactive range selector. */ + showRangeSelector?: boolean; /** Initial uncontrolled range. Defaults to the largest numeric option. */ defaultRangeSeconds?: ChartRangeValue; /** Controlled range for consumers that refetch when the selection changes. */ @@ -90,6 +92,7 @@ export function LineSeriesChart({ unit = "none", scale = "auto", rangeOptions = DEFAULT_CHART_RANGES, + showRangeSelector = true, defaultRangeSeconds, rangeSeconds, onRangeChange, @@ -98,8 +101,9 @@ export function LineSeriesChart({ defaultRangeSeconds ?? [...rangeOptions].reverse().find((range) => typeof range.value === "number") ?.value; - const [localRangeSeconds, setLocalRangeSeconds] = - useState(initialRange); + const [localRangeSeconds, setLocalRangeSeconds] = useState< + ChartRangeValue | undefined + >(initialRange); const selectedRangeSeconds = rangeSeconds ?? localRangeSeconds; const latestTimestamp = series.reduce( (max, seriesItem) => @@ -140,7 +144,7 @@ export function LineSeriesChart({ return (
- {rangeOptions.length > 0 && ( + {showRangeSelector && rangeOptions.length > 0 && (