on-demand: macOS: Tunnel detail: Show SSID info
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
574d8433b3
commit
0ae8d25134
|
@ -312,6 +312,7 @@
|
||||||
|
|
||||||
"macFieldKey (%@)" = "%@:";
|
"macFieldKey (%@)" = "%@:";
|
||||||
"macFieldOnDemand" = "On-Demand:";
|
"macFieldOnDemand" = "On-Demand:";
|
||||||
|
"macFieldOnDemandSSIDs" = "SSIDs:";
|
||||||
|
|
||||||
// Mac status display
|
// Mac status display
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,15 @@ class TunnelDetailTableViewController: NSViewController {
|
||||||
case interfaceFieldRow(TunnelViewModel.InterfaceField)
|
case interfaceFieldRow(TunnelViewModel.InterfaceField)
|
||||||
case peerFieldRow(peer: TunnelViewModel.PeerData, field: TunnelViewModel.PeerField)
|
case peerFieldRow(peer: TunnelViewModel.PeerData, field: TunnelViewModel.PeerField)
|
||||||
case onDemandRow
|
case onDemandRow
|
||||||
|
case onDemandSSIDRow
|
||||||
case spacerRow
|
case spacerRow
|
||||||
|
|
||||||
func localizedSectionKeyString() -> String {
|
func localizedSectionKeyString() -> String {
|
||||||
switch self {
|
switch self {
|
||||||
case .interfaceFieldRow: return tr("tunnelSectionTitleInterface")
|
case .interfaceFieldRow: return tr("tunnelSectionTitleInterface")
|
||||||
case .peerFieldRow: return tr("tunnelSectionTitlePeer")
|
case .peerFieldRow: return tr("tunnelSectionTitlePeer")
|
||||||
case .onDemandRow: return ""
|
case .onDemandRow: return tr("macFieldOnDemand")
|
||||||
|
case .onDemandSSIDRow: return ""
|
||||||
case .spacerRow: return ""
|
case .spacerRow: return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +27,7 @@ class TunnelDetailTableViewController: NSViewController {
|
||||||
case .interfaceFieldRow(let field): return field == .name
|
case .interfaceFieldRow(let field): return field == .name
|
||||||
case .peerFieldRow(_, let field): return field == .publicKey
|
case .peerFieldRow(_, let field): return field == .publicKey
|
||||||
case .onDemandRow: return true
|
case .onDemandRow: return true
|
||||||
|
case .onDemandSSIDRow: return false
|
||||||
case .spacerRow: return false
|
case .spacerRow: return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +44,10 @@ class TunnelDetailTableViewController: NSViewController {
|
||||||
.rxBytes, .txBytes, .lastHandshakeTime
|
.rxBytes, .txBytes, .lastHandshakeTime
|
||||||
]
|
]
|
||||||
|
|
||||||
|
static let onDemandFields: [ActivateOnDemandViewModel.OnDemandField] = [
|
||||||
|
.onDemand, .ssid
|
||||||
|
]
|
||||||
|
|
||||||
let tableView: NSTableView = {
|
let tableView: NSTableView = {
|
||||||
let tableView = NSTableView()
|
let tableView = NSTableView()
|
||||||
tableView.addTableColumn(NSTableColumn(identifier: NSUserInterfaceItemIdentifier("TunnelDetail")))
|
tableView.addTableColumn(NSTableColumn(identifier: NSUserInterfaceItemIdentifier("TunnelDetail")))
|
||||||
|
@ -76,6 +83,9 @@ class TunnelDetailTableViewController: NSViewController {
|
||||||
updateTableViewModelRows()
|
updateTableViewModelRows()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var onDemandViewModel: ActivateOnDemandViewModel
|
||||||
|
|
||||||
private var tableViewModelRowsBySection = [[(isVisible: Bool, modelRow: TableViewModelRow)]]()
|
private var tableViewModelRowsBySection = [[(isVisible: Bool, modelRow: TableViewModelRow)]]()
|
||||||
private var tableViewModelRows = [TableViewModelRow]()
|
private var tableViewModelRows = [TableViewModelRow]()
|
||||||
|
|
||||||
|
@ -87,6 +97,7 @@ class TunnelDetailTableViewController: NSViewController {
|
||||||
self.tunnelsManager = tunnelsManager
|
self.tunnelsManager = tunnelsManager
|
||||||
self.tunnel = tunnel
|
self.tunnel = tunnel
|
||||||
tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelConfiguration)
|
tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelConfiguration)
|
||||||
|
onDemandViewModel = ActivateOnDemandViewModel(setting: tunnel.activateOnDemandSetting)
|
||||||
super.init(nibName: nil, bundle: nil)
|
super.init(nibName: nil, bundle: nil)
|
||||||
updateTableViewModelRowsBySection()
|
updateTableViewModelRowsBySection()
|
||||||
updateTableViewModelRows()
|
updateTableViewModelRows()
|
||||||
|
@ -177,6 +188,9 @@ class TunnelDetailTableViewController: NSViewController {
|
||||||
|
|
||||||
var onDemandSection = [(isVisible: Bool, modelRow: TableViewModelRow)]()
|
var onDemandSection = [(isVisible: Bool, modelRow: TableViewModelRow)]()
|
||||||
onDemandSection.append((isVisible: true, modelRow: .onDemandRow))
|
onDemandSection.append((isVisible: true, modelRow: .onDemandRow))
|
||||||
|
if onDemandViewModel.isWiFiInterfaceEnabled {
|
||||||
|
onDemandSection.append((isVisible: true, modelRow: .onDemandSSIDRow))
|
||||||
|
}
|
||||||
modelRowsBySection.append(onDemandSection)
|
modelRowsBySection.append(onDemandSection)
|
||||||
|
|
||||||
tableViewModelRowsBySection = modelRowsBySection
|
tableViewModelRowsBySection = modelRowsBySection
|
||||||
|
@ -382,10 +396,16 @@ extension TunnelDetailTableViewController: NSTableViewDelegate {
|
||||||
return NSView()
|
return NSView()
|
||||||
case .onDemandRow:
|
case .onDemandRow:
|
||||||
let cell: KeyValueRow = tableView.dequeueReusableCell()
|
let cell: KeyValueRow = tableView.dequeueReusableCell()
|
||||||
cell.key = tr("macFieldOnDemand")
|
cell.key = modelRow.localizedSectionKeyString()
|
||||||
cell.value = TunnelViewModel.activateOnDemandDetailText(for: tunnel.activateOnDemandSetting)
|
cell.value = onDemandViewModel.localizedInterfaceDescription
|
||||||
cell.isKeyInBold = true
|
cell.isKeyInBold = true
|
||||||
return cell
|
return cell
|
||||||
|
case .onDemandSSIDRow:
|
||||||
|
let cell: KeyValueRow = tableView.dequeueReusableCell()
|
||||||
|
cell.key = tr("macFieldOnDemandSSIDs")
|
||||||
|
cell.value = onDemandViewModel.ssidOption.localizedUIString
|
||||||
|
cell.isKeyInBold = false
|
||||||
|
return cell
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,6 +492,7 @@ extension TunnelDetailTableViewController: NSTableViewDelegate {
|
||||||
extension TunnelDetailTableViewController: TunnelEditViewControllerDelegate {
|
extension TunnelDetailTableViewController: TunnelEditViewControllerDelegate {
|
||||||
func tunnelSaved(tunnel: TunnelContainer) {
|
func tunnelSaved(tunnel: TunnelContainer) {
|
||||||
tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelConfiguration)
|
tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelConfiguration)
|
||||||
|
onDemandViewModel = ActivateOnDemandViewModel(setting: tunnel.activateOnDemandSetting)
|
||||||
updateTableViewModelRowsBySection()
|
updateTableViewModelRowsBySection()
|
||||||
updateTableViewModelRows()
|
updateTableViewModelRows()
|
||||||
updateStatus()
|
updateStatus()
|
||||||
|
|
Loading…
Reference in New Issue