2017-03-06 08:51:50 +00:00
|
|
|
package expanded
|
|
|
|
|
|
|
|
import (
|
|
|
|
ui "github.com/gizak/termui"
|
|
|
|
)
|
|
|
|
|
2017-05-15 04:52:38 +00:00
|
|
|
var displayInfo = []string{"id", "name", "image", "ports", "state"}
|
2017-03-06 22:05:04 +00:00
|
|
|
|
2017-03-06 08:51:50 +00:00
|
|
|
type Info struct {
|
|
|
|
*ui.Table
|
|
|
|
data map[string]string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewInfo(id string) *Info {
|
|
|
|
p := ui.NewTable()
|
|
|
|
p.Height = 4
|
2017-03-06 22:05:04 +00:00
|
|
|
p.Width = colWidth[0]
|
2017-03-07 23:40:03 +00:00
|
|
|
p.FgColor = ui.ThemeAttr("par.text.fg")
|
2017-03-10 00:16:40 +00:00
|
|
|
p.Separator = false
|
2017-03-06 08:51:50 +00:00
|
|
|
i := &Info{p, make(map[string]string)}
|
2017-03-06 22:05:04 +00:00
|
|
|
i.Set("id", id)
|
2017-03-06 08:51:50 +00:00
|
|
|
return i
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Info) Set(k, v string) {
|
|
|
|
w.data[k] = v
|
|
|
|
// rebuild rows
|
|
|
|
w.Rows = [][]string{}
|
2017-03-06 22:05:04 +00:00
|
|
|
for _, k := range displayInfo {
|
|
|
|
if v, ok := w.data[k]; ok {
|
|
|
|
w.Rows = append(w.Rows, []string{k, v})
|
|
|
|
}
|
2017-03-06 08:51:50 +00:00
|
|
|
}
|
2017-03-06 22:05:04 +00:00
|
|
|
w.Height = len(w.Rows) + 2
|
2017-03-06 08:51:50 +00:00
|
|
|
}
|