|
7 | 7 | import ChevronDown from '$lib/components/icons/ChevronDown.svelte'; |
8 | 8 | import ChartLine from './ChartLine.svelte'; |
9 | 9 | import AnalyticsModelModal from './AnalyticsModelModal.svelte'; |
| 10 | + import Tooltip from '$lib/components/common/Tooltip.svelte'; |
10 | 11 | import { WEBUI_API_BASE_URL } from '$lib/constants'; |
11 | 12 | import { formatNumber } from '$lib/utils'; |
12 | 13 | import { goto } from '$app/navigation'; |
13 | 14 |
|
14 | 15 | const i18n = getContext('i18n'); |
15 | 16 |
|
16 | | - // Time period |
17 | | - let selectedPeriod = '7d'; |
| 17 | + // Time period - persist in localStorage |
| 18 | + let selectedPeriod = (typeof localStorage !== 'undefined' && localStorage.getItem('analyticsPeriod')) || '7d'; |
18 | 19 | const periods = [ |
19 | 20 | { value: '24h', label: 'Last 24 hours' }, |
20 | 21 | { value: '7d', label: 'Last 7 days' }, |
|
145 | 146 |
|
146 | 147 | $: totalModelMessages = modelStats.reduce((sum, m) => sum + m.count, 0); |
147 | 148 |
|
| 149 | + // Persist period selection |
| 150 | + $: if (typeof localStorage !== 'undefined' && selectedPeriod) { |
| 151 | + localStorage.setItem('analyticsPeriod', selectedPeriod); |
| 152 | + } |
| 153 | +
|
148 | 154 | onMount(loadDashboard); |
149 | 155 | </script> |
150 | 156 |
|
|
175 | 181 | {#if !loading} |
176 | 182 | <div class="flex gap-3 text-xs text-gray-500 dark:text-gray-400 px-0.5 pb-2"> |
177 | 183 | <span><span class="font-medium text-gray-900 dark:text-gray-300">{summary.total_messages.toLocaleString()}</span> {$i18n.t('messages')}</span> |
178 | | - <span><span class="font-medium text-gray-900 dark:text-gray-300">{formatNumber(totalTokens.total)}</span> {$i18n.t('tokens')}</span> |
| 184 | + <Tooltip content={$i18n.t('Token counts are estimates and may not reflect actual API usage')}> |
| 185 | + <span class="cursor-help"><span class="font-medium text-gray-900 dark:text-gray-300">{formatNumber(totalTokens.total)}</span> {$i18n.t('tokens')}</span> |
| 186 | + </Tooltip> |
179 | 187 | <span><span class="font-medium text-gray-900 dark:text-gray-300">{summary.total_chats.toLocaleString()}</span> {$i18n.t('chats')}</span> |
180 | 188 | <span><span class="font-medium text-gray-900 dark:text-gray-300">{summary.total_users}</span> {$i18n.t('users')}</span> |
181 | 189 | </div> |
|
0 commit comments