Mark phones in the Status chart and fit it to phone width
This commit is contained in:
@@ -3,6 +3,7 @@ import SwiftUI
|
||||
|
||||
typealias AgentProcess = Components.Schemas.AgentProcess
|
||||
typealias Zombie = Components.Schemas.Zombie
|
||||
typealias ConnectedClient = Components.Schemas.ConnectedClient
|
||||
typealias VendorUsage = Components.Schemas.Usage
|
||||
typealias UsageWindow = Components.Schemas.UsageWindow
|
||||
|
||||
@@ -440,28 +441,66 @@ private struct ClientTable: View {
|
||||
if status.clients.isEmpty {
|
||||
Text("No clients connected.").foregroundStyle(Palette.muted)
|
||||
} else {
|
||||
Grid(alignment: .leading, horizontalSpacing: 12, verticalSpacing: 2) {
|
||||
GridRow {
|
||||
ForEach(["Mac", "User", "Build", "Connected", "Last action", "iCloud"], id: \.self) { h in
|
||||
Text(h).font(Fonts.font(11)).foregroundStyle(Palette.muted)
|
||||
}
|
||||
}
|
||||
Divider().overlay(Palette.border)
|
||||
ForEach(Array(status.clients.enumerated()), id: \.offset) { _, c in
|
||||
GridRow {
|
||||
Text(c.host.isEmpty ? "—" : c.host)
|
||||
Text(c.login)
|
||||
Text(c.commit.isEmpty ? "—" : String(c.commit.prefix(8))).help(c.commit)
|
||||
Text(since(c.connectedAt))
|
||||
Text(c.lastActionAt.map(since) ?? "—")
|
||||
SyncCell(sync: c.sync)
|
||||
}
|
||||
.textSelection(.enabled)
|
||||
Divider().overlay(Palette.border)
|
||||
}
|
||||
ViewThatFits(in: .horizontal) {
|
||||
grid
|
||||
stacked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var grid: some View {
|
||||
Grid(alignment: .leading, horizontalSpacing: 12, verticalSpacing: 2) {
|
||||
GridRow {
|
||||
ForEach(["Name", "Device", "User", "Build", "Connected", "Last action", "iCloud"], id: \.self) { h in
|
||||
Text(h).font(Fonts.font(11)).foregroundStyle(Palette.muted)
|
||||
}
|
||||
}
|
||||
Divider().overlay(Palette.border)
|
||||
ForEach(Array(status.clients.enumerated()), id: \.offset) { _, c in
|
||||
GridRow {
|
||||
Text(c.host.isEmpty ? "—" : c.host).fixedSize()
|
||||
Text(c.device.isEmpty ? "—" : c.device).fixedSize()
|
||||
Text(c.login).fixedSize()
|
||||
Text(build(c)).help(c.commit).fixedSize()
|
||||
Text(ago(c.connectedAt)).fixedSize()
|
||||
Text(c.lastActionAt.map(since) ?? "—").fixedSize()
|
||||
SyncCell(sync: c.sync).fixedSize()
|
||||
}
|
||||
.textSelection(.enabled)
|
||||
Divider().overlay(Palette.border)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var stacked: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
Divider().overlay(Palette.border)
|
||||
ForEach(Array(status.clients.enumerated()), id: \.offset) { _, c in
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 8) {
|
||||
Text(c.host.isEmpty ? "—" : c.host)
|
||||
Text(c.device.isEmpty ? "—" : c.device).font(Fonts.font(11)).foregroundStyle(Palette.muted)
|
||||
Spacer(minLength: 0)
|
||||
Text("iCloud").font(Fonts.font(11)).foregroundStyle(Palette.muted)
|
||||
SyncCell(sync: c.sync)
|
||||
}
|
||||
Text("\(c.login) · build \(build(c))")
|
||||
.font(Fonts.font(11))
|
||||
.foregroundStyle(Palette.muted)
|
||||
Text("Connected \(ago(c.connectedAt)) ·last action \(c.lastActionAt.map(since) ?? "—")")
|
||||
.font(Fonts.font(11))
|
||||
.foregroundStyle(Palette.muted)
|
||||
}
|
||||
.textSelection(.enabled)
|
||||
.padding(.vertical, 6)
|
||||
Divider().overlay(Palette.border)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func build(_ c: ConnectedClient) -> String {
|
||||
c.commit.isEmpty ? "—" : String(c.commit.prefix(8))
|
||||
}
|
||||
}
|
||||
|
||||
private struct SyncCell: View {
|
||||
|
||||
Reference in New Issue
Block a user