feat: unify chart range controls

This commit is contained in:
Developer
2026-07-14 17:00:32 +00:00
parent a541a4fd16
commit 03aece02b8
8 changed files with 235 additions and 96 deletions
@@ -1,6 +1,7 @@
import { Alert, AlertDescription } from "@/components/ui/alert";
import { Skeleton } from "@/components/ui/skeleton";
import { LineSeriesChart } from "../components/LineSeriesChart";
import { chartRangesThrough } from "../components/chartRanges";
import type { ChartSeries } from "../components/LineSeriesChart";
import type { MetricScale, MetricUnit } from "../lib/metricFormat";
import { SectionCard } from "../components/SectionCard";
@@ -23,6 +24,7 @@ export function QbittorrentSpeedWidget({
// Source returns raw bytes/sec; default to bytes/sec + auto scale (MB/s, …).
const unit = (widget.config.unit as MetricUnit) || "bytes_per_sec";
const scale = (widget.config.scale as MetricScale) || "auto";
const maxRangeSeconds = Number(widget.config.window_seconds) || 1800;
return (
<SectionCard title={widget.title} description={description}>
@@ -38,6 +40,8 @@ export function QbittorrentSpeedWidget({
unit={unit}
scale={scale}
height={220}
rangeOptions={chartRangesThrough(maxRangeSeconds)}
defaultRangeSeconds={maxRangeSeconds}
/>
) : (
<Alert>