2024-02-17 22:39:22 -07:00
|
|
|
import SwiftUI
|
|
|
|
|
import CoreData
|
|
|
|
|
|
|
|
|
|
struct ConfigHeader<T>: View {
|
|
|
|
|
@EnvironmentObject var bleManager: BLEManager
|
|
|
|
|
|
|
|
|
|
let title: String
|
|
|
|
|
let config: KeyPath<NodeInfoEntity, T?>
|
|
|
|
|
let node: NodeInfoEntity?
|
|
|
|
|
let onAppear: () -> Void
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
|
if node != nil && node?.metadata == nil && node?.num ?? 0 != bleManager.connectedPeripheral?.num ?? 0 {
|
|
|
|
|
Text("There has been no response to a request for device metadata over the admin channel for this node.")
|
|
|
|
|
.font(.callout)
|
|
|
|
|
.foregroundColor(.orange)
|
|
|
|
|
|
|
|
|
|
} else if node != nil && node?.num ?? 0 != bleManager.connectedPeripheral?.num ?? 0 {
|
|
|
|
|
// Let users know what is going on if they are using remote admin and don't have the config yet
|
2024-09-04 10:06:34 -07:00
|
|
|
let expiration = node?.sessionExpiration ?? Date()
|
|
|
|
|
if node?[keyPath: config] == nil || expiration < node?.sessionExpiration ?? Date() {
|
|
|
|
|
Text("\(title) config data was requested over the admin channel but no response has been returned from the remote node.")
|
2024-02-17 22:39:22 -07:00
|
|
|
.font(.callout)
|
|
|
|
|
.foregroundColor(.orange)
|
|
|
|
|
} else {
|
|
|
|
|
Text("Remote administration for: \(node?.user?.longName ?? "Unknown")")
|
2024-08-14 03:10:12 -07:00
|
|
|
.onFirstAppear(onAppear)
|
2024-08-11 09:07:22 -07:00
|
|
|
.font(.title3)
|
2024-02-17 22:39:22 -07:00
|
|
|
}
|
|
|
|
|
} else if node != nil && node?.num ?? 0 == bleManager.connectedPeripheral?.num ?? -1 {
|
|
|
|
|
Text("Configuration for: \(node?.user?.longName ?? "Unknown")")
|
2024-08-14 03:10:12 -07:00
|
|
|
.onFirstAppear(onAppear)
|
2024-02-17 22:39:22 -07:00
|
|
|
} else {
|
|
|
|
|
Text("Please connect to a radio to configure settings.")
|
|
|
|
|
.font(.callout)
|
|
|
|
|
.foregroundColor(.orange)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|