mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Clean up admin drop down
This commit is contained in:
parent
e44003907c
commit
9b50626ebe
3 changed files with 22 additions and 3 deletions
|
|
@ -58,6 +58,15 @@ extension NodeInfoEntity {
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var canRemoteAdmin: Bool {
|
||||
if !(securityConfig?.adminKey?.isEmpty ?? true) {
|
||||
return true
|
||||
} else {
|
||||
let adminChannel = myInfo?.channels?.filter { ($0 as AnyObject).name?.lowercased() == "admin" }
|
||||
return adminChannel?.count ?? 0 > 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func createNodeInfo(num: Int64, context: NSManagedObjectContext) -> NodeInfoEntity {
|
||||
|
|
|
|||
|
|
@ -120,6 +120,9 @@ struct SecurityConfig: View {
|
|||
.onChange(of: adminChannelEnabled) {
|
||||
if $0 != node?.securityConfig?.adminChannelEnabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: adminKey) { _ in
|
||||
hasChanges = true
|
||||
}
|
||||
|
||||
SaveConfigButton(node: node, hasChanges: $hasChanges) {
|
||||
guard let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral.num, context: context),
|
||||
|
|
|
|||
|
|
@ -348,13 +348,13 @@ struct Settings: View {
|
|||
if !(node?.deviceConfig?.isManaged ?? false) {
|
||||
if bleManager.connectedPeripheral != nil {
|
||||
Section("Configure") {
|
||||
if hasAdmin {
|
||||
if node?.canRemoteAdmin ?? false {
|
||||
Picker("Configuring Node", selection: $selectedNode) {
|
||||
if selectedNode == 0 {
|
||||
Text("Connect to a Node").tag(0)
|
||||
}
|
||||
|
||||
ForEach(nodes) { node in
|
||||
/// Connected Node
|
||||
if node.num == bleManager.connectedPeripheral?.num ?? 0 {
|
||||
Label {
|
||||
Text("BLE: \(node.user?.longName ?? "unknown".localized)")
|
||||
|
|
@ -362,7 +362,14 @@ struct Settings: View {
|
|||
Image(systemName: "antenna.radiowaves.left.and.right")
|
||||
}
|
||||
.tag(Int(node.num))
|
||||
} else if node.metadata != nil {
|
||||
} else if node.canRemoteAdmin { /// Nodes using the new PKI system
|
||||
Label {
|
||||
Text("Remote: \(node.user?.longName ?? "unknown".localized)")
|
||||
} icon: {
|
||||
Image(systemName: "av.remote")
|
||||
}
|
||||
.tag(Int(node.num))
|
||||
} else if node.metadata != nil { /// Nodes using the old admin system
|
||||
Label {
|
||||
Text("Remote: \(node.user?.longName ?? "unknown".localized)")
|
||||
} icon: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue