- Gesendet-Status pro Bild: Upload-Historie (FTP + Immich) mit Ziel und Zeit, grünes Abzeichen im Kontaktabzug, Anzeige in Lupe und IPTC-Fenster, Filter Gesendet/Nicht gesendet, bereits gesendete beim Upload überspringen, 'Als nicht gesendet markieren' - Agentur-Check vor dem FTP-Upload: Pflichtfelder, offene Variablen und Codes, Datum aus alter Vorlage, IIM-Längen, offene Trikot-Vorschläge, Mindestgröße; Prüffenster mit Bearbeiten/Erneut prüfen/ Nur fehlerfreie senden; Einstellungsseite und Schalter pro Server - Rückgängig/Wiederholen (⌘Z/⇧⌘Z) für Sterne, Farben, Tags, IPTC und Vorlagen, Schreibvorgänge serialisiert, in Textfeldern bleibt ⌘Z beim Text - Spieltag-Assistent (⌘⇧N, auch im Ingest und in der Matchday-Ansicht): Teams, Wettbewerbe und Muster werden gespeichert; erzeugt Vorlage im Aufbau der Basis-Vorlage, Ingest-Ordner, Trikot-Teams und aktive Code-Teams; Trikotfarben aus der Erkennung fließen ins Team zurück; Matchday nimmt die Teams aus dem Ereignis des Bildes - Tests für Spieltag-Generator, Agentur-Check und Gesendet-Log, README ergänzt Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
191 lines
8.2 KiB
Swift
191 lines
8.2 KiB
Swift
import SwiftUI
|
||
import LichtkastenCore
|
||
|
||
/// Agentur-Check: shown before an upload when something is wrong or photos were sent before.
|
||
/// Errors (red) are excluded by "Nur fehlerfreie senden", warnings (amber) don't block.
|
||
struct PreflightWindow: View {
|
||
@EnvironmentObject var state: AppState
|
||
@Environment(\.dismissWindow) private var dismissWindow
|
||
@State private var skipSent = true
|
||
@State private var showOK = false
|
||
|
||
var body: some View {
|
||
Group {
|
||
if let p = state.pendingUpload {
|
||
content(p)
|
||
} else {
|
||
VStack(spacing: 12) {
|
||
Image(systemName: "checkmark.shield").font(.system(size: 40)).foregroundStyle(LK.green)
|
||
Text("Kein Upload wartet auf eine Prüfung.").foregroundStyle(LK.text2)
|
||
Button("Schließen") { dismissWindow(id: "check") }.buttonStyle(LKButtonStyle())
|
||
}
|
||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||
}
|
||
}
|
||
.frame(minWidth: 760, minHeight: 520)
|
||
.background(LK.ground)
|
||
}
|
||
|
||
// MARK: Content
|
||
|
||
private func content(_ p: PendingUpload) -> some View {
|
||
let problem = p.items.filter { !(p.issues[$0.id] ?? []).isEmpty || p.alreadySent.contains($0.id) }
|
||
let ok = p.items.filter { (p.issues[$0.id] ?? []).isEmpty && !p.alreadySent.contains($0.id) }
|
||
let sendable = toSend(p, errorFree: true)
|
||
let all = toSend(p, errorFree: false)
|
||
|
||
return VStack(spacing: 0) {
|
||
// header
|
||
HStack(spacing: 14) {
|
||
Image(systemName: p.errorItems > 0 ? "exclamationmark.shield.fill" : "checkmark.shield.fill")
|
||
.font(.system(size: 22))
|
||
.foregroundStyle(p.errorItems > 0 ? LK.red : LK.amber)
|
||
.frame(width: 44, height: 44)
|
||
.background(RoundedRectangle(cornerRadius: 11).fill(LK.raised))
|
||
VStack(alignment: .leading, spacing: 3) {
|
||
Text("Agentur-Check · \(p.targetName)").font(.system(size: 18, weight: .bold)).foregroundStyle(LK.text)
|
||
HStack(spacing: 12) {
|
||
chip("\(p.items.count) Bild(er)", LK.text2)
|
||
if p.errorItems > 0 { chip("\(p.errorItems) mit Fehlern", LK.red) }
|
||
if p.warningItems > 0 { chip("\(p.warningItems) mit Hinweisen", LK.amber) }
|
||
if !p.alreadySent.isEmpty { chip("\(p.alreadySent.count) schon gesendet", LK.green) }
|
||
}
|
||
}
|
||
Spacer()
|
||
Button("Erneut prüfen") { state.recheckPendingUpload() }
|
||
.buttonStyle(LKButtonStyle(compact: true))
|
||
.help("Nach Korrekturen im IPTC-Fenster neu prüfen")
|
||
}
|
||
.padding(20)
|
||
|
||
Rectangle().fill(LK.border).frame(height: 1)
|
||
|
||
ScrollView {
|
||
VStack(alignment: .leading, spacing: 10) {
|
||
if !p.alreadySent.isEmpty {
|
||
Toggle(isOn: $skipSent) {
|
||
Text("Bereits an \(p.targetName) gesendete Bilder überspringen (\(p.alreadySent.count))")
|
||
.font(.system(size: 13, weight: .semibold))
|
||
}
|
||
.toggleStyle(.checkbox)
|
||
.padding(.bottom, 4)
|
||
}
|
||
ForEach(problem) { item in row(item, p) }
|
||
if !ok.isEmpty {
|
||
DisclosureGroup(isExpanded: $showOK) {
|
||
VStack(alignment: .leading, spacing: 6) {
|
||
ForEach(ok) { item in
|
||
Text(item.filename).font(LK.mono(12)).foregroundStyle(LK.text2)
|
||
}
|
||
}
|
||
.padding(.top, 6)
|
||
} label: {
|
||
Label("\(ok.count) Bild(er) ohne Befund", systemImage: "checkmark.circle.fill")
|
||
.font(.system(size: 13, weight: .semibold))
|
||
.foregroundStyle(LK.green)
|
||
}
|
||
.padding(12)
|
||
.background(RoundedRectangle(cornerRadius: 10).fill(LK.card))
|
||
}
|
||
}
|
||
.padding(20)
|
||
}
|
||
|
||
Rectangle().fill(LK.border).frame(height: 1)
|
||
HStack(spacing: 10) {
|
||
Button("Abbrechen") {
|
||
state.pendingUpload = nil
|
||
dismissWindow(id: "check")
|
||
}
|
||
.buttonStyle(LKButtonStyle())
|
||
.keyboardShortcut(.cancelAction)
|
||
Spacer()
|
||
if all.count != sendable.count {
|
||
Button("Alle senden (\(all.count))") { send(all) }
|
||
.buttonStyle(LKButtonStyle())
|
||
.disabled(all.isEmpty)
|
||
.help("Auch Bilder mit Fehlern senden")
|
||
}
|
||
Button(p.errorItems > 0 ? "Nur fehlerfreie senden (\(sendable.count))" : "Senden (\(sendable.count))") { send(sendable) }
|
||
.buttonStyle(LKButtonStyle(primary: true))
|
||
.keyboardShortcut(.defaultAction)
|
||
.disabled(sendable.isEmpty)
|
||
}
|
||
.padding(16)
|
||
}
|
||
}
|
||
|
||
private func toSend(_ p: PendingUpload, errorFree: Bool) -> [PhotoItem] {
|
||
p.items.filter { item in
|
||
if skipSent && p.alreadySent.contains(item.id) { return false }
|
||
if errorFree && p.hasError(item.id) { return false }
|
||
return true
|
||
}
|
||
}
|
||
|
||
private func send(_ items: [PhotoItem]) {
|
||
state.confirmPendingUpload(items)
|
||
state.openWindow("tasks")
|
||
dismissWindow(id: "check")
|
||
}
|
||
|
||
// MARK: Row per photo
|
||
|
||
private func row(_ item: PhotoItem, _ p: PendingUpload) -> some View {
|
||
let issues = p.issues[item.id] ?? []
|
||
return HStack(alignment: .top, spacing: 12) {
|
||
PreflightThumb(url: state.previewURL(for: item))
|
||
VStack(alignment: .leading, spacing: 5) {
|
||
HStack {
|
||
Text(item.filename).font(LK.mono(12, .semibold)).foregroundStyle(LK.text)
|
||
if p.alreadySent.contains(item.id), let s = state.sentSummary(for: item) {
|
||
Label(s.tooltip, systemImage: "paperplane.fill")
|
||
.font(.system(size: 11)).foregroundStyle(LK.green).lineLimit(1)
|
||
}
|
||
}
|
||
ForEach(issues) { i in
|
||
HStack(alignment: .top, spacing: 6) {
|
||
Image(systemName: i.severity == .error ? "xmark.octagon.fill" : "exclamationmark.triangle.fill")
|
||
.font(.system(size: 11))
|
||
.foregroundStyle(i.severity == .error ? LK.red : LK.amber)
|
||
Text(i.message).font(.system(size: 12)).foregroundStyle(LK.text)
|
||
}
|
||
}
|
||
}
|
||
Spacer()
|
||
Button("Bearbeiten") {
|
||
state.cursorID = item.id
|
||
state.selection = [item.id]
|
||
state.openWindow("iptc")
|
||
}
|
||
.buttonStyle(LKButtonStyle(compact: true))
|
||
.help("Im IPTC-Fenster öffnen – danach „Erneut prüfen“")
|
||
}
|
||
.padding(12)
|
||
.background(RoundedRectangle(cornerRadius: 10).fill(LK.card))
|
||
.overlay(RoundedRectangle(cornerRadius: 10).stroke(p.hasError(item.id) ? LK.red.opacity(0.5) : LK.border))
|
||
}
|
||
|
||
private func chip(_ text: String, _ color: Color) -> some View {
|
||
Text(text).font(.system(size: 11, weight: .bold)).foregroundStyle(color)
|
||
}
|
||
}
|
||
|
||
struct PreflightThumb: View {
|
||
let url: URL
|
||
@State private var image: NSImage?
|
||
|
||
var body: some View {
|
||
ZStack {
|
||
RoundedRectangle(cornerRadius: 6).fill(LK.deep)
|
||
if let image { Image(nsImage: image).resizable().scaledToFill() }
|
||
}
|
||
.frame(width: 84, height: 56)
|
||
.clipShape(RoundedRectangle(cornerRadius: 6))
|
||
.task(id: url) {
|
||
image = ImageLoader.shared.cachedThumbnail(url)
|
||
if image == nil { image = await ImageLoader.shared.thumbnail(for: url) }
|
||
}
|
||
}
|
||
}
|