48 lines
1.7 KiB
Swift
Executable File
48 lines
1.7 KiB
Swift
Executable File
import SwiftUI
|
|
|
|
struct RunLogView: View {
|
|
let run: SyncRun
|
|
|
|
var body: some View {
|
|
ScrollView {
|
|
VStack(alignment: .leading, spacing: 20) {
|
|
HStack {
|
|
VStack(alignment: .leading) {
|
|
Text(run.jobName).font(.title.bold())
|
|
Text(run.startedAt.formatted(date: .abbreviated, time: .standard))
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
Spacer()
|
|
StatusBadge(run: run)
|
|
}
|
|
|
|
if let duration = run.duration {
|
|
LabeledContent("Duration", value: Duration.seconds(duration).formatted(.units(allowed: [.minutes, .seconds], width: .abbreviated)))
|
|
}
|
|
if let exitCode = run.exitCode {
|
|
LabeledContent("Exit code", value: String(exitCode))
|
|
}
|
|
LabeledContent("Mode", value: run.wasDryRun ? "Dry Run" : "Live Run")
|
|
|
|
console(title: "Command", text: run.command)
|
|
if !run.output.isEmpty { console(title: "Output", text: run.output) }
|
|
if !run.errorOutput.isEmpty { console(title: "Errors", text: run.errorOutput) }
|
|
}
|
|
.padding(28)
|
|
}
|
|
.navigationTitle("Run Log")
|
|
}
|
|
|
|
private func console(title: String, text: String) -> some View {
|
|
GroupBox(title) {
|
|
ScrollView(.horizontal) {
|
|
Text(text)
|
|
.font(.system(.caption, design: .monospaced))
|
|
.textSelection(.enabled)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
}
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
}
|
|
}
|
|
}
|