Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions changelog/unreleased/overview-today-window.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### English

- Overview time switcher gains a **Today** option (calendar day since local midnight → now), placed before 1h.
- Overview now defaults to the Today window on load (was 24h).

### 中文

- 概览页顶部时间切换新增「今天」选项(按本地零点到当前的日历日统计),排在「1小时」之前。
- 概览页默认时间窗口改为「今天」(原为 24 小时)。
2 changes: 2 additions & 0 deletions frontend/src/i18n/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ export const messages: Record<Lang, Dict> = {
statsWindow7d: '7d',
statsWindow30d: '30d',
statsWindowCustom: 'Custom',
statsWindowToday: 'Today',
statsRefreshPause: 'Pause auto-refresh',
statsRefreshResume: 'Resume auto-refresh',
statsRefreshAuto: 'Refreshing every 30s · click to pause',
Expand Down Expand Up @@ -1087,6 +1088,7 @@ export const messages: Record<Lang, Dict> = {
statsWindow7d: '7天',
statsWindow30d: '30天',
statsWindowCustom: '自定义',
statsWindowToday: '今天',
statsRefreshPause: '暂停自动刷新',
statsRefreshResume: '恢复自动刷新',
statsRefreshAuto: '每 30 秒刷新 · 点击暂停',
Expand Down
15 changes: 13 additions & 2 deletions frontend/src/lib/statsWindow.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
import { dateValueToISO, type DateRangeValue } from '@/components/ui/TimeRangePicker'

export type StatsWindow = '1' | '24' | '168' | '720' | 'custom'
export type StatsWindow = 'today' | '1' | '24' | '168' | '720' | 'custom'

export const STATS_WINDOW_LABEL: Record<StatsWindow, string> = {
today: 'statsWindowToday',
'1': 'statsWindow1h',
'24': 'statsWindow24h',
'168': 'statsWindow7d',
'720': 'statsWindow30d',
custom: 'statsWindowCustom',
}

/** Stats query for a window. 30d and custom go through from/to: the backend only accepts hours=1|24|168. */
/**
* Stats query for a window. 30d, today and custom go through from/to: the
* backend only accepts hours=1|24|168. "today" is a calendar range — local
* midnight -> now — so it is sent as an explicit `from` (the backend defaults
* `to` to now and derives the window from the pair).
*/
export function statsQuery(window: StatsWindow, custom: DateRangeValue | null) {
if (window === 'today') {
const start = new Date()
start.setHours(0, 0, 0, 0)
return { from: start.toISOString() }
}
if (window === 'custom') {
const from = dateValueToISO(custom?.start)
const to = dateValueToISO(custom?.end, true)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/OverviewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function quotaTone(percentage?: number, exceeded?: boolean) {
export function OverviewPage() {
const { lang, t } = useI18n()
const { overview, loading, error } = useOverview()
const [statsWindow, setStatsWindow] = useState<StatsWindow>('24')
const [statsWindow, setStatsWindow] = useState<StatsWindow>('today')
const [customRange, setCustomRange] = useState<DateRangeValue | null>(null)
const [paused, setPaused] = useState(false)
const navigate = useNavigate()
Expand Down

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/webui/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<meta name="twitter:title" content="CLI2API" />
<meta name="twitter:description" content="Qoder CLI → OpenAI-compatible API. Self-hosted gateway." />
<meta name="twitter:image" content="/og-card.svg" />
<script type="module" crossorigin src="/assets/index-CfCVWXqQ.js"></script>
<script type="module" crossorigin src="/assets/index-Bzj5tctq.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-wLKkm4Gy.css">
</head>
<body>
Expand Down
Loading