Issue #5: Check server status on start.
This commit is contained in:
parent
603a23a1a8
commit
f7ac3d9aed
3 changed files with 90 additions and 38 deletions
|
|
@ -1,46 +1,11 @@
|
|||
|
||||
import SwiftUI
|
||||
|
||||
enum ServiceStatus {
|
||||
case pending
|
||||
case operational
|
||||
case degraded
|
||||
case outage
|
||||
|
||||
var description: String {
|
||||
switch self {
|
||||
case .pending:
|
||||
return "Fetching service status"
|
||||
case .operational:
|
||||
return "No issues detected"
|
||||
case .degraded:
|
||||
return "Performance degraded"
|
||||
case .outage:
|
||||
return "Service disruption"
|
||||
}
|
||||
}
|
||||
|
||||
var color: Color {
|
||||
switch self {
|
||||
case .pending:
|
||||
return .gray
|
||||
case .operational:
|
||||
return .green
|
||||
case .degraded:
|
||||
return .orange
|
||||
case .outage:
|
||||
return .red
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct HomeView: View {
|
||||
|
||||
@EnvironmentObject
|
||||
private var viewModel: ViewModel
|
||||
|
||||
@State private var serviceStatus: ServiceStatus = .operational
|
||||
|
||||
private let falsePositiveURL = URL(string: "https://www.sr2.uk/contact")!
|
||||
private let statusURL = URL(string:
|
||||
"https://status.sr2.uk/")!
|
||||
|
|
@ -166,13 +131,13 @@ struct HomeView: View {
|
|||
Link(destination: statusURL) {
|
||||
HStack(spacing: 12) {
|
||||
Circle()
|
||||
.fill(serviceStatus.color)
|
||||
.fill(viewModel.summaryStatus.color)
|
||||
.frame(width: 12, height: 12)
|
||||
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text("Service Status")
|
||||
.font(.headline)
|
||||
Text(serviceStatus.description)
|
||||
Text(viewModel.summaryStatus.description)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue