Server setup in the app
This commit is contained in:
@@ -199,6 +199,7 @@ final class Connection {
|
||||
final class ConnectForm {
|
||||
var serverText = ""
|
||||
var problem: String?
|
||||
var missing: [Check] = []
|
||||
var connecting = false
|
||||
|
||||
func connect() async -> URL? {
|
||||
@@ -223,7 +224,14 @@ final class ConnectForm {
|
||||
func installHere() async -> URL? {
|
||||
connecting = true
|
||||
problem = nil
|
||||
missing = []
|
||||
do {
|
||||
let checks = try await Server.checks()
|
||||
if !checks.ready {
|
||||
missing = checks.checks.filter { !$0.ok }
|
||||
connecting = false
|
||||
return nil
|
||||
}
|
||||
let origin = try await Server.turnOn()
|
||||
serverText = origin.absoluteString
|
||||
try await waitForServer(origin)
|
||||
@@ -294,6 +302,16 @@ struct ConnectView: View {
|
||||
let connected: (URL) -> Void
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { g in
|
||||
ScrollView {
|
||||
fields
|
||||
.padding(.vertical, 24)
|
||||
.frame(maxWidth: .infinity, minHeight: g.size.height)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var fields: some View {
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
Text("Server URL")
|
||||
TextField("https://byre.example.ts.net", text: $form.serverText)
|
||||
@@ -310,9 +328,14 @@ struct ConnectView: View {
|
||||
.textSelection(.enabled)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
if !form.missing.isEmpty {
|
||||
Text("byre can't run on this Mac yet. Install what's missing, then click Run byre on this Mac again.")
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.padding(.top, 6)
|
||||
ChecksView(checks: form.missing)
|
||||
}
|
||||
}
|
||||
.frame(width: 460)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
|
||||
private func connect() {
|
||||
|
||||
Reference in New Issue
Block a user