Skip to content

Commit 0e60c75

Browse files
committed
refac
1 parent 68a1e87 commit 0e60c75

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/lib/components/admin/Analytics/Dashboard.svelte

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
import ChevronDown from '$lib/components/icons/ChevronDown.svelte';
88
import ChartLine from './ChartLine.svelte';
99
import AnalyticsModelModal from './AnalyticsModelModal.svelte';
10+
import Tooltip from '$lib/components/common/Tooltip.svelte';
1011
import { WEBUI_API_BASE_URL } from '$lib/constants';
1112
import { formatNumber } from '$lib/utils';
1213
import { goto } from '$app/navigation';
1314
1415
const i18n = getContext('i18n');
1516
16-
// Time period
17-
let selectedPeriod = '7d';
17+
// Time period - persist in localStorage
18+
let selectedPeriod = (typeof localStorage !== 'undefined' && localStorage.getItem('analyticsPeriod')) || '7d';
1819
const periods = [
1920
{ value: '24h', label: 'Last 24 hours' },
2021
{ value: '7d', label: 'Last 7 days' },
@@ -145,6 +146,11 @@
145146
146147
$: totalModelMessages = modelStats.reduce((sum, m) => sum + m.count, 0);
147148
149+
// Persist period selection
150+
$: if (typeof localStorage !== 'undefined' && selectedPeriod) {
151+
localStorage.setItem('analyticsPeriod', selectedPeriod);
152+
}
153+
148154
onMount(loadDashboard);
149155
</script>
150156

@@ -175,7 +181,9 @@
175181
{#if !loading}
176182
<div class="flex gap-3 text-xs text-gray-500 dark:text-gray-400 px-0.5 pb-2">
177183
<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>
179187
<span><span class="font-medium text-gray-900 dark:text-gray-300">{summary.total_chats.toLocaleString()}</span> {$i18n.t('chats')}</span>
180188
<span><span class="font-medium text-gray-900 dark:text-gray-300">{summary.total_users}</span> {$i18n.t('users')}</span>
181189
</div>

0 commit comments

Comments
 (0)