45 lines
1.8 KiB
Swift
45 lines
1.8 KiB
Swift
import SwiftUI
|
|
|
|
struct SettingsView: View {
|
|
@ObservedObject var monitor: ServerMonitor
|
|
@Environment(\.dismiss) private var dismiss
|
|
@AppStorage("server.host") private var host = "192.168.1.2"
|
|
@AppStorage("server.user") private var user = "mag"
|
|
@AppStorage("server.port") private var port = "22"
|
|
@AppStorage("server.keyFile") private var keyFile = ""
|
|
@AppStorage("monitor.intervalMinutes") private var intervalMinutes = 5
|
|
@AppStorage("monitor.notifications") private var notifications = true
|
|
|
|
var body: some View {
|
|
Form {
|
|
TextField("Host", text: $host)
|
|
TextField("SSH user", text: $user)
|
|
TextField("SSH port", text: $port)
|
|
TextField("SSH key path (optional)", text: $keyFile)
|
|
.help("Leave blank to use your SSH agent or ~/.ssh/config")
|
|
Picker("Refresh interval", selection: $intervalMinutes) {
|
|
Text("1 minute").tag(1)
|
|
Text("5 minutes").tag(5)
|
|
Text("10 minutes").tag(10)
|
|
Text("15 minutes").tag(15)
|
|
Text("30 minutes").tag(30)
|
|
}
|
|
Toggle("Notify when server becomes unhealthy", isOn: $notifications)
|
|
HStack {
|
|
Button("Close") {
|
|
dismiss()
|
|
}
|
|
Spacer()
|
|
Button("Apply and Refresh") {
|
|
monitor.configureTimer()
|
|
Task { await monitor.refresh() }
|
|
}
|
|
}
|
|
Text("SSH must authenticate without prompts. Server requires /usr/local/bin/pegasus-health-json accessible via sudo -n. Host keys are verified using your existing SSH known_hosts file.")
|
|
.font(.caption)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
.padding(20)
|
|
}
|
|
}
|