Files
RouterOS/RouterOSAssistant/Features/Backup/BackupViewModel.swift
T
KayandClaude Sonnet 5 9d1aecc452 Tooltips für alle Konfigurationsfelder + wählbarer Backup-Ordner
.help(...)-Tooltips auf jedem Eingabefeld/Picker/Toggle in Connect-
sowie allen Einrichten-Schritten (WAN/LAN/VLAN/WLAN/Firewall) --
kurze Erklärung was der Wert bedeutet und welche Auswirkung er hat,
passend zum Laien-Anspruch der App.

Sicherungen-Tab: Speicherort jetzt änderbar (Ordner wählen über
nativen macOS-Dialog, Zurücksetzen auf Standard). BackupService hält
den gewählten Pfad in UserDefaults (BackupService.customDirectoryURL),
fällt ohne Auswahl weiter auf ~/Library/Application Support/... zurück.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HReLXMbmPvtQ23p1iWiJNW
2026-09-12 20:30:22 +02:00

43 lines
1.2 KiB
Swift

import Foundation
@MainActor
final class BackupViewModel: ObservableObject {
@Published private(set) var backups: [BackupRecord] = []
@Published private(set) var isCreatingBackup = false
@Published var errorMessage: String?
@Published private(set) var backupDirectoryPath: String = BackupService.customDirectoryURL?.path
?? BackupService.defaultDirectoryURL.path
private let backupService = BackupService()
func load() {
backups = backupService.listBackups()
}
func setBackupDirectory(_ url: URL) {
BackupService.customDirectoryURL = url
backupDirectoryPath = url.path
load()
}
func resetBackupDirectoryToDefault() {
BackupService.customDirectoryURL = nil
backupDirectoryPath = BackupService.defaultDirectoryURL.path
load()
}
func createBackup(for credentials: RouterOSCredentials) {
isCreatingBackup = true
errorMessage = nil
Task {
do {
_ = try await backupService.createBackup(for: credentials)
load()
} catch {
errorMessage = error.localizedDescription
}
isCreatingBackup = false
}
}
}