Przeglądaj źródła

Fix TS error, add missing translation keys, fix fr locale, cleanup duplicated functions

Matteo Parenti 3 miesięcy temu
rodzic
commit
115f2617cf

+ 5 - 15
backend/app/api/routes/system.py

@@ -4,6 +4,7 @@ import asyncio
 import os
 import platform
 import time
+from collections.abc import Callable
 from datetime import datetime
 from pathlib import Path
 
@@ -116,13 +117,6 @@ def _get_data_dirs() -> list[Path]:
     ]
 
 
-def _get_storage_scan_roots() -> list[Path]:
-    roots = []
-    for path in _get_data_dirs():
-        roots.append(path)
-    return roots
-
-
 def _is_system_path(path: Path) -> bool:
     app_dir = _get_app_dir()
     if not _is_under(path, app_dir):
@@ -130,7 +124,7 @@ def _is_system_path(path: Path) -> bool:
     return all(not _is_under(path, data_dir) for data_dir in _get_data_dirs())
 
 
-def _get_storage_rules() -> list[tuple[str, str, callable]]:
+def _get_storage_rules() -> list[tuple[str, str, Callable]]:
     base_dir = settings.base_dir
     archive_dir = settings.archive_dir
     library_dir = archive_dir / "library"
@@ -213,7 +207,7 @@ def _get_storage_rules() -> list[tuple[str, str, callable]]:
     ]
 
 
-def _classify_file(path: Path, rules: list[tuple[str, str, callable]]) -> tuple[str, str]:
+def _classify_file(path: Path, rules: list[tuple[str, str, Callable]]) -> tuple[str, str]:
     for key, label, matcher in rules:
         try:
             if matcher(path):
@@ -236,11 +230,7 @@ def _get_other_bucket(path: Path, base_dir: Path) -> str:
         return path.parent.name or path.name
 
     parts = relative.parts
-    if len(parts) > 1:
-        return parts[0]
-    if parts:
-        return parts[0]
-    return path.name
+    return parts[0] if parts else path.name
 
 
 def _walk_files(roots: list[Path]) -> list[Path]:
@@ -269,7 +259,7 @@ def _scan_storage_usage() -> dict:
     base_dir = settings.base_dir
     rules = _get_storage_rules()
 
-    roots = _get_storage_scan_roots()
+    roots = _get_data_dirs()
 
     seen_roots = set()
     unique_roots = []

+ 6 - 0
frontend/src/i18n/locales/de.ts

@@ -1379,6 +1379,12 @@ export default {
     dataManagement: 'Datenverwaltung',
     storageUsage: 'Speichernutzung',
     storageUsageDescription: 'Aufschlüsselung der Datennutzung nach Kategorie',
+    storageUsageTotal: 'Gesamt',
+    storageUsageErrors: 'Fehler',
+    storageUsageOtherBreakdown: 'Sonstiges (enthält statische Assets, Skripte und Konfigurationsdateien)',
+    storageUsageSystem: 'System',
+    storageUsageData: 'Daten',
+    storageUsageUnavailable: 'Speichernutzungsinformationen nicht verfügbar',
     clearNotificationLogsDescription: 'Benachrichtigungsprotokolle älter als 30 Tage löschen',
     resetUiPreferencesDescription: 'Seitenleisten-Reihenfolge, Theme, Ansichtsmodi und Layout-Einstellungen zurücksetzen. Drucker, Archive und Einstellungen werden nicht beeinflusst.',
     enableHomeAssistant: 'Home Assistant aktivieren',

+ 6 - 0
frontend/src/i18n/locales/en.ts

@@ -1379,6 +1379,12 @@ export default {
     dataManagement: 'Data Management',
     storageUsage: 'Storage Usage',
     storageUsageDescription: 'Breakdown of data usage by category',
+    storageUsageTotal: 'Total',
+    storageUsageErrors: 'Errors',
+    storageUsageOtherBreakdown: 'Other (includes static assets, scripts, and configuration files)',
+    storageUsageSystem: 'System',
+    storageUsageData: 'Data',
+    storageUsageUnavailable: 'Storage usage information unavailable',
     clearNotificationLogsDescription: 'Delete notification logs older than 30 days',
     resetUiPreferencesDescription: 'Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected.',
     enableHomeAssistant: 'Enable Home Assistant',

+ 7 - 1
frontend/src/i18n/locales/fr.ts

@@ -1,4 +1,4 @@
-export default {
+export default {
   // Navigation
   nav: {
     printers: 'Imprimantes',
@@ -1375,6 +1375,12 @@ export default {
     dataManagement: 'Gestion des données',
     storageUsage: 'Utilisation du stockage',
     storageUsageDescription: 'Répartition de l’utilisation des données par catégorie',
+    storageUsageTotal: 'Total',
+    storageUsageErrors: 'Erreurs',
+    storageUsageOtherBreakdown: 'Autre (inclut ressources statiques, scripts et fichiers de configuration)',
+    storageUsageSystem: 'Système',
+    storageUsageData: 'Données',
+    storageUsageUnavailable: 'Informations d\'utilisation du stockage non disponibles',
     clearNotificationLogsDescription: 'Supprimer logs de plus de 30 jours',
     resetUiPreferencesDescription: 'Réinitialise thèmes et affichage sans toucher aux données.',
     enableHomeAssistant: 'Activer Home Assistant',

+ 6 - 0
frontend/src/i18n/locales/it.ts

@@ -1285,6 +1285,12 @@ export default {
     dataManagement: 'Gestione dati',
     storageUsage: 'Memoria utilizzata',
     storageUsageDescription: 'Ripartizione della memoria per categoria',
+    storageUsageTotal: 'Totale',
+    storageUsageErrors: 'Errori',
+    storageUsageOtherBreakdown: 'Altro (include risorse statiche, script e file di configurazione)',
+    storageUsageSystem: 'Sistema',
+    storageUsageData: 'Dati',
+    storageUsageUnavailable: 'Informazioni sull\'utilizzo della memoria non disponibili',
     clearNotificationLogsDescription: 'Elimina log notifiche più vecchi di 30 giorni',
     resetUiPreferencesDescription: 'Reimposta ordine barra laterale, tema, modalità vista e preferenze layout. Stampanti, archivi e impostazioni non vengono modificati.',
     enableHomeAssistant: 'Abilita Home Assistant',

+ 6 - 0
frontend/src/i18n/locales/ja.ts

@@ -1303,6 +1303,12 @@ export default {
     dataManagement: 'データ管理',
     storageUsage: 'ストレージ使用量',
     storageUsageDescription: 'カテゴリ別のデータ使用量の内訳',
+    storageUsageTotal: '合計',
+    storageUsageErrors: 'エラー',
+    storageUsageOtherBreakdown: 'その他(静的アセット、スクリプト、設定ファイルを含む)',
+    storageUsageSystem: 'システム',
+    storageUsageData: 'データ',
+    storageUsageUnavailable: 'ストレージ使用量情報は利用できません',
     enableMqtt: 'MQTTを有効化',
     useTls: 'TLSを使用',
     enableMetricsEndpoint: 'メトリクスエンドポイントを有効化',

+ 1 - 1
frontend/src/pages/SettingsPage.tsx

@@ -202,7 +202,7 @@ export function SettingsPage() {
     isFetching: storageUsageFetching,
   } = useQuery<StorageUsageResponse>({
     queryKey: ['storage-usage'],
-    queryFn: api.getStorageUsage,
+    queryFn: () => api.getStorageUsage(),
     enabled: activeTab === 'general',
     staleTime: Infinity,
     refetchInterval: false,