macOS: Manage tunnels: Export tunnels pulldown menu implementation
This commit is contained in:
parent
ae991167f2
commit
fde0d67dda
|
@ -146,8 +146,27 @@ class TunnelsListTableViewController: NSViewController {
|
||||||
@objc func exportLogClicked() {
|
@objc func exportLogClicked() {
|
||||||
print("exportLogClicked")
|
print("exportLogClicked")
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func exportTunnelsClicked() {
|
@objc func exportTunnelsClicked() {
|
||||||
print("exportTunnelsClicked")
|
guard let window = view.window else { return }
|
||||||
|
let savePanel = NSSavePanel()
|
||||||
|
savePanel.allowedFileTypes = ["zip"]
|
||||||
|
savePanel.prompt = "Save"
|
||||||
|
savePanel.nameFieldLabel = "Export tunnels to"
|
||||||
|
savePanel.nameFieldStringValue = "wireguard-export.zip"
|
||||||
|
savePanel.beginSheetModal(for: window) { [weak tunnelsManager] response in
|
||||||
|
guard let tunnelsManager = tunnelsManager else { return }
|
||||||
|
guard response == .OK else { return }
|
||||||
|
guard let destinationURL = savePanel.url else { return }
|
||||||
|
let count = tunnelsManager.numberOfTunnels()
|
||||||
|
let tunnelConfigurations = (0 ..< count).compactMap { tunnelsManager.tunnel(at: $0).tunnelConfiguration }
|
||||||
|
ZipExporter.exportConfigFiles(tunnelConfigurations: tunnelConfigurations, to: destinationURL) { [weak self] error in
|
||||||
|
if let error = error {
|
||||||
|
ErrorPresenter.showErrorAlert(error: error, from: self)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
|
|
Loading…
Reference in New Issue