diff --git a/apps/storage/apps/web/src/lib/api/client.ts b/apps/storage/apps/web/src/lib/api/client.ts index 11ea1d7f0..71cb8ecde 100644 --- a/apps/storage/apps/web/src/lib/api/client.ts +++ b/apps/storage/apps/web/src/lib/api/client.ts @@ -148,6 +148,13 @@ export interface Tag { createdAt: string; } +export interface StorageStats { + totalFiles: number; + totalSize: number; + favoriteCount: number; + recentFiles: StorageFile[]; +} + // Files API export const filesApi = { list: (folderId?: string) => @@ -155,6 +162,8 @@ export const filesApi = { get: (id: string) => request(`/files/${id}`), + stats: () => request('/files/stats'), + upload: async (file: File, folderId?: string): Promise> => { const formData = new FormData(); formData.append('file', file); diff --git a/apps/storage/apps/web/src/routes/settings/+page.svelte b/apps/storage/apps/web/src/routes/settings/+page.svelte index 596d6e50c..db4cf7f73 100644 --- a/apps/storage/apps/web/src/routes/settings/+page.svelte +++ b/apps/storage/apps/web/src/routes/settings/+page.svelte @@ -4,6 +4,8 @@ import { userSettings } from '$lib/stores/user-settings.svelte'; import { THEME_DEFINITIONS } from '@manacore/shared-theme'; import { APP_VERSION } from '$lib/version'; + import { filesApi } from '$lib/api/client'; + import type { StorageStats } from '$lib/api/client'; import { SettingsPage, SettingsSection, @@ -12,8 +14,23 @@ GlobalSettingsSection, } from '@manacore/shared-ui'; + let stats = $state(null); + let maxStorage = 10 * 1024 * 1024 * 1024; // 10 GB + + let usagePercent = $derived(stats ? Math.min(100, (stats.totalSize / maxStorage) * 100) : 0); + + function formatSize(bytes: number): string { + if (bytes === 0) return '0 B'; + const k = 1024; + const sizes = ['B', 'KB', 'MB', 'GB']; + const i = Math.floor(Math.log(bytes) / Math.log(k)); + return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i]; + } + onMount(async () => { await userSettings.load(); + const result = await filesApi.stats(); + if (result.data) stats = result.data; }); @@ -92,11 +109,20 @@

Speicherplatz

-

Dein genutzter Speicherplatz

+

+ {stats + ? `${stats.totalFiles} Dateien, ${stats.favoriteCount} Favoriten` + : 'Wird geladen...'} +

-
+
-

2.5 GB von 10 GB verwendet

+

+ {stats ? formatSize(stats.totalSize) : '...'} von {formatSize(maxStorage)} verwendet +