updates
This commit is contained in:
@@ -35,7 +35,12 @@ struct MonitorMenuView: View {
|
||||
Spacer()
|
||||
if monitor.results[server.id]?.refreshing == true { ProgressView().controlSize(.mini) }
|
||||
else if let report = monitor.results[server.id]?.report {
|
||||
Text("\(report.counts.ok) OK").font(.caption2).foregroundStyle(.secondary)
|
||||
VStack(alignment: .trailing, spacing: 2) {
|
||||
Text("\(report.counts.ok) OK").font(.caption2)
|
||||
if let uptime = report.uptimeLabel {
|
||||
Text("Up \(uptime)").font(.caption2)
|
||||
}
|
||||
}.foregroundStyle(.secondary)
|
||||
}
|
||||
if server.id == monitor.selectedID { Image(systemName: "checkmark") }
|
||||
}.padding(.horizontal, 14).padding(.vertical, 8)
|
||||
@@ -55,6 +60,17 @@ struct MonitorMenuView: View {
|
||||
ScrollView {
|
||||
LazyVStack(alignment: .leading, spacing: 0) {
|
||||
if let report = monitor.report {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "clock.arrow.circlepath")
|
||||
.foregroundStyle(.secondary)
|
||||
Text("Uptime").font(.system(size: 12, weight: .medium))
|
||||
Spacer()
|
||||
Text(report.uptimeLabel ?? "Not available")
|
||||
.font(.system(size: 12, weight: .medium, design: .monospaced))
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
.padding(.horizontal, 14).padding(.vertical, 10)
|
||||
Divider()
|
||||
if !monitor.selectedServices.isEmpty {
|
||||
Text("SERVICES")
|
||||
.font(.caption.bold()).foregroundStyle(.secondary)
|
||||
|
||||
@@ -15,6 +15,16 @@ struct HealthReport: Codable {
|
||||
let schema: Int
|
||||
let host: String?
|
||||
let generatedAt: String?
|
||||
let uptimeSeconds: Int?
|
||||
var uptimeLabel: String? {
|
||||
guard let uptimeSeconds, uptimeSeconds >= 0 else { return nil }
|
||||
let days = uptimeSeconds / 86400
|
||||
let hours = (uptimeSeconds % 86400) / 3600
|
||||
let minutes = (uptimeSeconds % 3600) / 60
|
||||
if days > 0 { return "\(days)d \(hours)h \(minutes)m" }
|
||||
if hours > 0 { return "\(hours)h \(minutes)m" }
|
||||
return "\(minutes)m"
|
||||
}
|
||||
let overall: HealthStatus
|
||||
let counts: HealthCounts
|
||||
let groups: [HealthGroup]
|
||||
@@ -190,7 +200,7 @@ final class ServerMonitor: ObservableObject {
|
||||
let checks = report.checks + extra
|
||||
let counts = HealthCounts(ok: report.counts.ok, warn: report.counts.warn, fail: report.counts.fail + extra.count)
|
||||
let groups = report.groups + [HealthGroup(name: "Required services", status: .fail, missing: extra.map(\.name))]
|
||||
return HealthReport(schema: report.schema, host: report.host, generatedAt: report.generatedAt, overall: .fail,
|
||||
return HealthReport(schema: report.schema, host: report.host, generatedAt: report.generatedAt, uptimeSeconds: report.uptimeSeconds, overall: .fail,
|
||||
counts: counts, groups: groups, checks: checks, diagnostics: report.diagnostics, services: report.services)
|
||||
}
|
||||
var status: HealthStatus {
|
||||
|
||||
Reference in New Issue
Block a user