mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2026-04-03 01:50:09 +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")
|
@available(*, deprecated, message: "Use a more specific method instead")
|
||||||
static func loadHomebrewServices() {
|
static func loadHomebrewServices() {
|
||||||
print(self.shared)
|
print(self.shared)
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ struct ServicesView: View {
|
|||||||
HStack {
|
HStack {
|
||||||
Circle()
|
Circle()
|
||||||
.frame(width: 12, height: 12)
|
.frame(width: 12, height: 12)
|
||||||
.foregroundColor(.yellow)
|
.foregroundColor(self.manager.statusColor)
|
||||||
Text("Determining services status...")
|
Text(self.manager.statusMessage)
|
||||||
.font(.system(size: 12))
|
.font(.system(size: 12))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user