mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
🏗 WIP: Services manager main status
Please note that these are computed properties. They should be computed when a service status is modified, and should be `Published`.
This commit is contained in:
@ -21,6 +21,36 @@ class ServicesManager: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
public var statusMessage: String {
|
||||
let statuses = self.services[0...2].map { $0.status }
|
||||
if statuses.contains(.loading) {
|
||||
return "Determining Valet status..."
|
||||
}
|
||||
if statuses.contains(.missing) {
|
||||
return "A key service is not installed."
|
||||
}
|
||||
if statuses.contains(.inactive) {
|
||||
return "A key service is not running."
|
||||
}
|
||||
|
||||
return "All Valet services are OK."
|
||||
}
|
||||
|
||||
public var statusColor: Color {
|
||||
let statuses = self.services[0...2].map { $0.status }
|
||||
if statuses.contains(.loading) {
|
||||
return .orange
|
||||
}
|
||||
if statuses.contains(.missing) {
|
||||
return .red
|
||||
}
|
||||
if statuses.contains(.inactive) {
|
||||
return .red
|
||||
}
|
||||
|
||||
return .green
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "Use a more specific method instead")
|
||||
static func loadHomebrewServices() {
|
||||
print(self.shared)
|
||||
|
@ -65,8 +65,8 @@ struct ServicesView: View {
|
||||
HStack {
|
||||
Circle()
|
||||
.frame(width: 12, height: 12)
|
||||
.foregroundColor(.yellow)
|
||||
Text("Determining services status...")
|
||||
.foregroundColor(self.manager.statusColor)
|
||||
Text(self.manager.statusMessage)
|
||||
.font(.system(size: 12))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user