2017-03-03 07:57:26 +00:00
|
|
|
package compact
|
|
|
|
|
|
|
|
import (
|
|
|
|
ui "github.com/gizak/termui"
|
|
|
|
)
|
|
|
|
|
|
|
|
type GaugeCol struct {
|
|
|
|
*ui.Gauge
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewGaugeCol() *GaugeCol {
|
|
|
|
g := ui.NewGauge()
|
|
|
|
g.Height = 1
|
|
|
|
g.Border = false
|
|
|
|
g.Percent = 0
|
|
|
|
g.PaddingBottom = 0
|
|
|
|
g.Label = "-"
|
|
|
|
return &GaugeCol{g}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *GaugeCol) Reset() {
|
|
|
|
w.Label = "-"
|
|
|
|
w.Percent = 0
|
|
|
|
}
|
2017-03-05 06:46:41 +00:00
|
|
|
|
|
|
|
func colorScale(n int) ui.Attribute {
|
|
|
|
if n > 70 {
|
2017-08-27 23:46:01 +00:00
|
|
|
return ui.ThemeAttr("status.danger")
|
2017-03-05 06:46:41 +00:00
|
|
|
}
|
|
|
|
if n > 30 {
|
2017-08-27 23:46:01 +00:00
|
|
|
return ui.ThemeAttr("status.warn")
|
2017-03-05 06:46:41 +00:00
|
|
|
}
|
2017-08-27 23:46:01 +00:00
|
|
|
return ui.ThemeAttr("status.ok")
|
2017-03-05 06:46:41 +00:00
|
|
|
}
|