Extract MetaCol

This commit is contained in:
Sergey Ponomarev
2020-12-11 20:59:35 +02:00
parent cdcb8b6d99
commit 9545dfba31

View File

@@ -9,34 +9,28 @@ import (
ui "github.com/gizak/termui" ui "github.com/gizak/termui"
) )
type NameCol struct { // Column that shows container's meta property i.e. name, id, image tc.
type MetaCol struct {
*TextCol *TextCol
metaName string
}
func (w *MetaCol) SetMeta(m models.Meta) {
w.setText(m.Get(w.metaName))
} }
func NewNameCol() CompactCol { func NewNameCol() CompactCol {
c := &NameCol{NewTextCol("NAME")} c := &MetaCol{NewTextCol("NAME"), "name"}
c.fWidth = 30 c.fWidth = 30
return c return c
} }
func (w *NameCol) SetMeta(m models.Meta) {
w.setText(m.Get("name"))
}
type CIDCol struct {
*TextCol
}
func NewCIDCol() CompactCol { func NewCIDCol() CompactCol {
c := &CIDCol{NewTextCol("CID")} c := &MetaCol{NewTextCol("CID"), "id"}
c.fWidth = 12 c.fWidth = 12
return c return c
} }
func (w *CIDCol) SetMeta(m models.Meta) {
w.setText(m.Get("id"))
}
type NetCol struct { type NetCol struct {
*TextCol *TextCol
} }