mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
Extract MetaCol
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user