Skip to content

Commit

Permalink
Single Container View: truncate ID
Browse files Browse the repository at this point in the history
Truncation Id inside of NewSingle() doesn't work.
It even doesn't have any effect.
Instead truncate the ID inside of NewMeta() call
  • Loading branch information
stokito committed Nov 3, 2020
1 parent ecc7bf4 commit 2bcfc36
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion container/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions cwidgets/single/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
7 changes: 2 additions & 5 deletions cwidgets/single/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion grid.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 2bcfc36

Please sign in to comment.