Add show-failing-only property to the monitor widget

This commit is contained in:
Svilen Markov
2024-08-29 21:14:50 +01:00
parent d7bd34531f
commit 725d0da15d
4 changed files with 29 additions and 6 deletions

View File

@ -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)