import TerminalUI
import TerminalUICLI
import TerminalUICharts
@main
struct OpsDashboardApp: App {
var body: some Scene {
WindowGroup("Ops") {
OpsDashboard()
}
}
}
struct OpsDashboard: View {
let latency = [42, 38, 45, 51, 47, 44, 49, 53, 46, 43].map(Double.init)
var body: some View {
VStack(alignment: .leading, spacing: 1) {
Text("Production").bold()
HStack(alignment: .top, spacing: 2) {
VStack(alignment: .leading, spacing: 1) {
Meter("CPU", value: 73, total: 100, tone: .warning, barWidth: 16)
Sparkline("Latency", values: latency, tone: .info)
ThresholdGauge(
"SLO",
value: 99.92,
total: 100,
bands: [
ThresholdBand(upTo: 99.0, tone: .critical),
ThresholdBand(upTo: 99.9, tone: .warning),
ThresholdBand(upTo: 100, tone: .success),
],
barWidth: 16
)
}
BarChart(
"Queue",
entries: [
BarChartEntry("ingest", value: 82, tone: .warning),
BarChartEntry("index", value: 38, tone: .success),
BarChartEntry("email", value: 12, tone: .info),
],
barWidth: 14,
labelWidth: 7
)
}
Divider()
Timeline([
TimelineEntry("deploy started", detail: "api@1.4.0", tone: .info),
TimelineEntry("canary healthy", detail: "10% traffic", tone: .success),
TimelineEntry("queue elevated", detail: "watch ingest", tone: .warning),
])
Legend(
"Legend",
items: [
LegendItem("healthy", tone: .success),
LegendItem("watch", tone: .warning),
LegendItem("info", tone: .info),
]
)
}
.padding(.init(horizontal: 1, vertical: 0))
}
}