add filter string to ctopheader

This commit is contained in:
Bradley Cicenas
2017-02-13 03:37:17 +00:00
parent 70974ee131
commit 97a561260a
2 changed files with 20 additions and 4 deletions

View File

@@ -8,14 +8,16 @@ import (
)
type CTopHeader struct {
Time *ui.Par
Count *ui.Par
Time *ui.Par
Count *ui.Par
Filter *ui.Par
}
func NewCTopHeader() *CTopHeader {
return &CTopHeader{
Time: headerPar(timeStr()),
Count: headerPar("-"),
Time: headerPar(timeStr()),
Count: headerPar("-"),
Filter: headerPar(""),
}
}
@@ -24,6 +26,7 @@ func (c *CTopHeader) Row() *ui.Row {
return ui.NewRow(
ui.NewCol(2, 0, c.Time),
ui.NewCol(2, 0, c.Count),
ui.NewCol(8, 0, c.Filter),
)
}
@@ -31,6 +34,14 @@ func (c *CTopHeader) SetCount(val int) {
c.Count.Text = fmt.Sprintf("%d containers", val)
}
func (c *CTopHeader) SetFilter(val string) {
if val == "" {
c.Filter.Text = ""
} else {
c.Filter.Text = fmt.Sprintf("filter: %s", val)
}
}
func timeStr() string {
return time.Now().Local().Format("15:04:05 MST")
}