Single Container View: truncate ID

Truncation Id inside of NewSingle() doesn't work.
It even doesn't have any effect.
Instead truncate the ID inside of NewMeta() call
This commit is contained in:
Sergey Ponomarev 2020-11-03 14:11:58 +02:00
parent ecc7bf4081
commit 2bcfc365f7
4 changed files with 5 additions and 9 deletions

View File

@ -34,7 +34,7 @@ func New(id string, collector collector.Collector, manager manager.Manager) *Con
return &Container{
Metrics: models.NewMetrics(),
Id: id,
Meta: models.NewMeta("id", id),
Meta: models.NewMeta("id", id[:12]),
Widgets: widgets,
updater: widgets,
collector: collector,

View File

@ -13,14 +13,13 @@ type Info struct {
data map[string]string
}
func NewInfo(id string) *Info {
func NewInfo() *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
}

View File

@ -23,12 +23,9 @@ type Single struct {
Width int
}
func NewSingle(id string) *Single {
if len(id) > 12 {
id = id[:12]
}
func NewSingle() *Single {
return &Single{
Info: NewInfo(id),
Info: NewInfo(),
Net: NewNet(),
Cpu: NewCpu(),
Mem: NewMem(),

View File

@ -83,7 +83,7 @@ func SingleView() MenuFn {
ui.DefaultEvtStream.ResetHandlers()
defer ui.DefaultEvtStream.ResetHandlers()
ex := single.NewSingle(c.Id)
ex := single.NewSingle()
c.SetUpdater(ex)
ex.Align()