improve health check visibility

This commit is contained in:
Bradley Cicenas
2019-06-22 18:42:48 +00:00
parent c8ac331652
commit 4c4f041b40
2 changed files with 14 additions and 16 deletions

View File

@@ -5,8 +5,8 @@ import (
) )
const ( const (
mark = string('\u25C9') mark = "◉"
healthMark = string('\u207A') healthMark = "✚"
vBar = string('\u25AE') + string('\u25AE') vBar = string('\u25AE') + string('\u25AE')
) )
@@ -18,7 +18,10 @@ type Status struct {
} }
func NewStatus() *Status { func NewStatus() *Status {
s := &Status{Block: ui.NewBlock()} s := &Status{
Block: ui.NewBlock(),
health: []ui.Cell{{Ch: ' '}},
}
s.Height = 1 s.Height = 1
s.Border = false s.Border = false
s.Set("") s.Set("")
@@ -28,11 +31,12 @@ func NewStatus() *Status {
func (s *Status) Buffer() ui.Buffer { func (s *Status) Buffer() ui.Buffer {
buf := s.Block.Buffer() buf := s.Block.Buffer()
x := 0 x := 0
for _, c := range s.status { for _, c := range s.health {
buf.Set(s.InnerX()+x, s.InnerY(), c) buf.Set(s.InnerX()+x, s.InnerY(), c)
x += c.Width() x += c.Width()
} }
for _, c := range s.health { x += 1
for _, c := range s.status {
buf.Set(s.InnerX()+x, s.InnerY(), c) buf.Set(s.InnerX()+x, s.InnerY(), c)
x += c.Width() x += c.Width()
} }
@@ -53,18 +57,16 @@ func (s *Status) Set(val string) {
text = vBar text = vBar
} }
var cells []ui.Cell s.status = ui.TextCells(text, color, ui.ColorDefault)
for _, ch := range text {
cells = append(cells, ui.Cell{Ch: ch, Fg: color})
}
s.status = cells
} }
func (s *Status) SetHealth(val string) { func (s *Status) SetHealth(val string) {
if val == "" { if val == "" {
return return
} }
color := ui.ColorDefault color := ui.ColorDefault
mark := healthMark
switch val { switch val {
case "healthy": case "healthy":
@@ -75,9 +77,5 @@ func (s *Status) SetHealth(val string) {
color = ui.ThemeAttr("status.warn") color = ui.ThemeAttr("status.warn")
} }
var cells []ui.Cell s.health = ui.TextCells(mark, color, ui.ColorDefault)
for _, ch := range healthMark {
cells = append(cells, ui.Cell{Ch: ch, Fg: color})
}
s.health = cells
} }

View File

@@ -12,7 +12,7 @@ const colSpacing = 1
// per-column width. 0 == auto width // per-column width. 0 == auto width
var colWidths = []int{ var colWidths = []int{
3, // status 5, // status
0, // name 0, // name
0, // cid 0, // cid
0, // cpu 0, // cpu