From da0565472df73e4387dbea553587872cf0dd5d78 Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Sat, 20 Sep 2025 16:21:50 +0200 Subject: [PATCH] feat: enhance settings and backup functionality - Updated status descriptions in `SettingsIndexPageClient` to reflect current functionality. - Added a new backup management section in settings for better user access. - Modified `BackupService` to include backup type in filenames, improving clarity and organization. - Enhanced backup file parsing to support both new and old filename formats, ensuring backward compatibility. --- .../settings/SettingsIndexPageClient.tsx | 13 +++++++--- services/backup.ts | 26 ++++++++++++++----- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/components/settings/SettingsIndexPageClient.tsx b/components/settings/SettingsIndexPageClient.tsx index b462482..e6519f4 100644 --- a/components/settings/SettingsIndexPageClient.tsx +++ b/components/settings/SettingsIndexPageClient.tsx @@ -17,7 +17,7 @@ export function SettingsIndexPageClient({ initialPreferences }: SettingsIndexPag icon: '⚙️', title: 'Paramètres généraux', description: 'Interface, thème, préférences d\'affichage', - status: 'En développement' + status: 'Fonctionnel' }, { href: '/settings/integrations', @@ -26,12 +26,19 @@ export function SettingsIndexPageClient({ initialPreferences }: SettingsIndexPag description: 'Jira, GitHub, Slack et autres services externes', status: 'Fonctionnel' }, + { + href: '/settings/backup', + icon: '💾', + title: 'Sauvegardes', + description: 'Gestion des sauvegardes automatiques et manuelles', + status: 'Fonctionnel' + }, { href: '/settings/advanced', icon: '🛠️', title: 'Paramètres avancés', - description: 'Sauvegarde, logs, debug et maintenance', - status: 'Prochainement' + description: 'Logs, debug et maintenance système', + status: 'Fonctionnel' } ]; diff --git a/services/backup.ts b/services/backup.ts index c51b05e..4e81b92 100644 --- a/services/backup.ts +++ b/services/backup.ts @@ -111,7 +111,7 @@ export class BackupService { async createBackup(type: 'manual' | 'automatic' = 'manual'): Promise { const backupId = `backup_${Date.now()}`; const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); - const filename = `towercontrol_${timestamp}.db`; + const filename = `towercontrol_${type}_${timestamp}.db`; const backupPath = path.join(this.getCurrentBackupPath(), filename); console.log(`🔄 Starting ${type} backup: ${filename}`); @@ -332,14 +332,28 @@ export class BackupService { const filePath = path.join(currentBackupPath, file); const stats = await fs.stat(filePath); - // Extraire la date du nom de fichier - const dateMatch = file.match(/towercontrol_(\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-\d{3}Z)/); + // Extraire le type et la date du nom de fichier + // Nouveau format: towercontrol_manual_2025-09-18T14-12-05-737Z.db + // Ancien format: towercontrol_2025-09-18T14-12-05-737Z.db (considéré comme automatic) + let type: 'manual' | 'automatic' = 'automatic'; + let dateMatch = file.match(/towercontrol_(manual|automatic)_(\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-\d{3}Z)/); + + if (!dateMatch) { + // Format ancien sans type - considérer comme automatic + dateMatch = file.match(/towercontrol_(\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-\d{3}Z)/); + if (dateMatch) { + dateMatch = [dateMatch[0], 'automatic', dateMatch[1]]; // Restructurer pour compatibilité + } + } else { + type = dateMatch[1] as 'manual' | 'automatic'; + } + let createdAt = stats.birthtime; - if (dateMatch) { + if (dateMatch && dateMatch[2]) { // Convertir le format de fichier vers ISO string valide // Format: 2025-09-18T14-12-05-737Z -> 2025-09-18T14:12:05.737Z - const isoString = dateMatch[1] + const isoString = dateMatch[2] .replace(/T(\d{2})-(\d{2})-(\d{2})-(\d{3})Z/, 'T$1:$2:$3.$4Z'); createdAt = new Date(isoString); } @@ -349,7 +363,7 @@ export class BackupService { filename: file, size: stats.size, createdAt, - type: 'automatic', // On ne peut pas déterminer le type depuis le nom + type, status: 'success', }); }