mirror of
https://github.com/glanceapp/glance.git
synced 2025-08-15 18:52:24 +02:00
Add show-failing-only property to the monitor widget
This commit is contained in:
@ -53,7 +53,9 @@ type Monitor struct {
|
||||
StatusText string `yaml:"-"`
|
||||
StatusStyle string `yaml:"-"`
|
||||
} `yaml:"sites"`
|
||||
Style string `yaml:"style"`
|
||||
Style string `yaml:"style"`
|
||||
ShowFailingOnly bool `yaml:"show-failing-only"`
|
||||
HasFailing bool `yaml:"-"`
|
||||
}
|
||||
|
||||
func (widget *Monitor) Initialize() error {
|
||||
@ -79,12 +81,17 @@ func (widget *Monitor) Update(ctx context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
widget.HasFailing = false
|
||||
|
||||
for i := range widget.Sites {
|
||||
site := &widget.Sites[i]
|
||||
status := &statuses[i]
|
||||
|
||||
site.Status = status
|
||||
|
||||
if status.Code >= 400 || status.TimedOut || status.Error != nil {
|
||||
widget.HasFailing = true
|
||||
}
|
||||
|
||||
if !status.TimedOut {
|
||||
site.StatusText = statusCodeToText(status.Code)
|
||||
site.StatusStyle = statusCodeToStyle(status.Code)
|
||||
|
Reference in New Issue
Block a user