diff --git a/Sources/Lichtkasten/Services/AppState.swift b/Sources/Lichtkasten/Services/AppState.swift index a6dc521..d86f05e 100644 --- a/Sources/Lichtkasten/Services/AppState.swift +++ b/Sources/Lichtkasten/Services/AppState.swift @@ -1384,6 +1384,7 @@ final class AppState: ObservableObject { /// e.g. "{event}" → "DFB-Pokal Frauen: VfL Wolfsburg - TSG 1899 Hoffenheim". /// Unresolved variables are dropped; if nothing is left the fallback pattern is used. func immichAlbum(for item: PhotoItem) -> String { + guard settings.immich.useAlbum else { return "" } // "ohne Album": library only func resolve(_ pattern: String) -> String { guard !pattern.isEmpty else { return "" } var ctx = VariableContext.make(fileURL: item.primary, exif: item.exif, iptc: item.iptc, dateFormat: settings.dateFormat) diff --git a/Sources/Lichtkasten/Views/SettingsView.swift b/Sources/Lichtkasten/Views/SettingsView.swift index de972f0..dc18bc7 100644 --- a/Sources/Lichtkasten/Views/SettingsView.swift +++ b/Sources/Lichtkasten/Views/SettingsView.swift @@ -225,8 +225,12 @@ struct ImmichSettingsView: View { TextField("Server-URL", text: $state.settings.immich.serverURL, prompt: Text("https://immich.example.de")) SecureField("API-Schlüssel (Schlüsselbund)", text: $apiKey) .onChange(of: apiKey) { _, k in Keychain.set(k, account: ImmichSettings.keychainAccount); state.uploads.resetImmich() } + Toggle("Bilder in ein Album einsortieren", isOn: $state.settings.immich.useAlbum) + .help("Aus: Bilder landen nur in der Immich-Bibliothek, ohne Album") TextField("Album", text: $state.settings.immich.albumName, prompt: Text("{event}")) + .disabled(!state.settings.immich.useAlbum) TextField("Album, wenn kein Ereignis im IPTC", text: $state.settings.immich.albumFallback, prompt: Text("{isodate} {city}")) + .disabled(!state.settings.immich.useAlbum) Text("Variablen aus IPTC/EXIF pro Bild, z. B. {event}, {headline}, {city}, {sublocation}, {isodate}, {date}, {year4}, {creator}. Vereine: {vereina} - {vereinb} (= {home}/{away}, kurz {homeshort}/{awayshort}), dazu {competition}, {round}, {season} – aus dem Spieltag oder dem Ereignis. Beispiel: {vereina} - {vereinb} | {date}. Fehlende Alben werden angelegt, leer = kein Album.") .font(.caption).foregroundStyle(.secondary) if let first = state.selectedItems.first { diff --git a/Sources/Lichtkasten/Views/UploadWindow.swift b/Sources/Lichtkasten/Views/UploadWindow.swift index 3930c3a..c4b9d54 100644 --- a/Sources/Lichtkasten/Views/UploadWindow.swift +++ b/Sources/Lichtkasten/Views/UploadWindow.swift @@ -96,8 +96,15 @@ struct UploadWindow: View { } else if target == "immich" { LKSectionLabel(title: "Optionen").padding(.top, 4) VStack(spacing: 0) { - optionRow("Album-Muster") { - TextField("{event}", text: $state.settings.immich.albumName).textFieldStyle(.plain).lkField() + optionRow("Album") { + LKSegmented(options: [(true, "In Album einsortieren"), (false, "Ohne Album")], + selection: $state.settings.immich.useAlbum) + } + if state.settings.immich.useAlbum { + divider + optionRow("Album-Muster") { + TextField("{event}", text: $state.settings.immich.albumName).textFieldStyle(.plain).lkField() + } } divider optionRow("Dateien") { @@ -163,6 +170,7 @@ struct UploadWindow: View { } private var albumPreview: String { + guard state.settings.immich.useAlbum else { return "ohne Album" } let albums = Set(state.selectedItems.map { state.immichAlbum(for: $0) }.filter { !$0.isEmpty }) return albums.isEmpty ? "kein Album" : "Album: " + albums.sorted().joined(separator: ", ") } diff --git a/Sources/LichtkastenCore/Upload/ImmichClient.swift b/Sources/LichtkastenCore/Upload/ImmichClient.swift index cada5b7..0e01407 100644 --- a/Sources/LichtkastenCore/Upload/ImmichClient.swift +++ b/Sources/LichtkastenCore/Upload/ImmichClient.swift @@ -12,6 +12,8 @@ public struct ImmichSettings: Codable, Hashable, Sendable { public var albumFallback: String = "{isodate} {city}" public var variant: UploadVariant public var enabled: Bool + /// Off = photos are uploaded into the library only, without any album (patterns stay saved). + public var useAlbum: Bool = true public init(serverURL: String = "", albumName: String = "", variant: UploadVariant = .jpeg, enabled: Bool = false) { self.serverURL = serverURL; self.albumName = albumName; self.variant = variant; self.enabled = enabled @@ -19,7 +21,7 @@ public struct ImmichSettings: Codable, Hashable, Sendable { public static let keychainAccount = "immich-api-key" - enum CodingKeys: String, CodingKey { case serverURL, albumName, albumFallback, variant, enabled } + enum CodingKeys: String, CodingKey { case serverURL, albumName, albumFallback, variant, enabled, useAlbum } public init(from decoder: Decoder) throws { let c = try decoder.container(keyedBy: CodingKeys.self) @@ -28,6 +30,7 @@ public struct ImmichSettings: Codable, Hashable, Sendable { albumFallback = (try? c.decode(String.self, forKey: .albumFallback)) ?? "{isodate} {city}" variant = (try? c.decode(UploadVariant.self, forKey: .variant)) ?? .jpeg enabled = (try? c.decode(Bool.self, forKey: .enabled)) ?? false + useAlbum = (try? c.decode(Bool.self, forKey: .useAlbum)) ?? true } }