mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
36 lines
639 B
Go
36 lines
639 B
Go
package expanded
|
|
|
|
import (
|
|
ui "github.com/gizak/termui"
|
|
)
|
|
|
|
var displayInfo = []string{"id", "name", "image", "ports", "state"}
|
|
|
|
type Info struct {
|
|
*ui.Table
|
|
data map[string]string
|
|
}
|
|
|
|
func NewInfo(id string) *Info {
|
|
p := ui.NewTable()
|
|
p.Height = 4
|
|
p.Width = colWidth[0]
|
|
p.FgColor = ui.ThemeAttr("par.text.fg")
|
|
p.Separator = false
|
|
i := &Info{p, make(map[string]string)}
|
|
i.Set("id", id)
|
|
return i
|
|
}
|
|
|
|
func (w *Info) Set(k, v string) {
|
|
w.data[k] = v
|
|
// rebuild rows
|
|
w.Rows = [][]string{}
|
|
for _, k := range displayInfo {
|
|
if v, ok := w.data[k]; ok {
|
|
w.Rows = append(w.Rows, []string{k, v})
|
|
}
|
|
}
|
|
w.Height = len(w.Rows) + 2
|
|
}
|