feat: wire Cloud card on Home to real FileBrowser data

Add getUsage() method to filebrowser-client that fetches root directory
and returns total size and folder count. Home.vue Cloud card now shows
real storage used and folder count instead of hardcoded values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-05 07:05:14 +00:00
co-authored by Claude Opus 4.6
parent dfe96cdb6f
commit 37105e6be6
3 changed files with 51 additions and 4 deletions
+17
View File
@@ -104,6 +104,23 @@ class FileBrowserClient {
if (!res.ok) throw new Error(`Delete failed: ${res.status}`)
}
async getUsage(): Promise<{ totalSize: number; folderCount: number; fileCount: number }> {
if (!this.isAuthenticated) {
const ok = await this.login()
if (!ok) return { totalSize: 0, folderCount: 0, fileCount: 0 }
}
const res = await fetch(`${this.baseUrl}/api/resources/`, {
headers: this.headers(),
})
if (!res.ok) return { totalSize: 0, folderCount: 0, fileCount: 0 }
const data: FileBrowserListResponse = await res.json()
const items = data.items || []
const folderCount = items.filter(i => i.isDir).length
const fileCount = items.filter(i => !i.isDir).length
const totalSize = items.reduce((sum, i) => sum + (i.size || 0), 0)
return { totalSize, folderCount, fileCount }
}
async rename(oldPath: string, newName: string): Promise<void> {
const safePath = oldPath.startsWith('/') ? oldPath : `/${oldPath}`
const dir = safePath.substring(0, safePath.lastIndexOf('/') + 1)