Files
mirror-3x-ui/frontend/src/pages/index/OverviewRangeSelect.tsx
T
Mr Cortex 05e8f17268 feat(dashboard): choose the time range of the overview charts (#7139)
Every overview chart gets the same range selector: 2m, 5m, 30m, 1h, 6h and 12h. The 2m default is the live trend the page already drew, one point per status poll, so nothing changes until a longer range is picked. A longer range is read from the server's stored rollups through the new GET /panel/api/server/overviewHistory/:bucket, which returns all eight overview series in one response, and is refreshed once per point, at most once a minute.

A metric the host cannot report stays empty in a ranged window instead of drawing zeros, a range change clears the chart rather than showing the old range under the new label, and avg/peak labels keep their number order in RTL locales.
2026-11-25 01:04:29 +03:30

35 lines
896 B
TypeScript

import { Select } from 'antd';
import { useTranslation } from 'react-i18next';
export const OVERVIEW_RANGES = [2, 5, 30, 60, 360, 720] as const;
export type OverviewRange = (typeof OVERVIEW_RANGES)[number];
interface OverviewRangeSelectProps {
value: OverviewRange;
onChange: (value: OverviewRange) => void;
}
const OPTIONS = [
{ value: 2, label: '2m' },
{ value: 5, label: '5m' },
{ value: 30, label: '30m' },
{ value: 60, label: '1h' },
{ value: 360, label: '6h' },
{ value: 720, label: '12h' },
];
export default function OverviewRangeSelect({ value, onChange }: OverviewRangeSelectProps) {
const { t } = useTranslation();
return (
<Select
aria-label={t('pages.index.timeRange')}
className="ov-range-select"
size="small"
value={value}
options={OPTIONS}
onChange={(next: number) => onChange(next as OverviewRange)}
/>
);
}