mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
add WidgetUpdater interface to container, replace struct fields with metamap
This commit is contained in:
@@ -46,6 +46,15 @@ func NewCompact(id string) *Compact {
|
||||
//}
|
||||
//}
|
||||
|
||||
func (row *Compact) SetMeta(k, v string) {
|
||||
switch k {
|
||||
case "name":
|
||||
row.Name.Set(v)
|
||||
case "state":
|
||||
row.Status.Set(v)
|
||||
}
|
||||
}
|
||||
|
||||
func (row *Compact) SetMetrics(m metrics.Metrics) {
|
||||
row.SetCPU(m.CPUUtil)
|
||||
row.SetNet(m.NetRx, m.NetTx)
|
||||
|
||||
@@ -2,19 +2,12 @@ package cwidgets
|
||||
|
||||
import (
|
||||
"github.com/bcicen/ctop/logging"
|
||||
ui "github.com/gizak/termui"
|
||||
"github.com/bcicen/ctop/metrics"
|
||||
)
|
||||
|
||||
var log = logging.Init()
|
||||
|
||||
type ContainerWidgets interface {
|
||||
Buffer() ui.Buffer
|
||||
Highlight()
|
||||
UnHighlight()
|
||||
SetY(int)
|
||||
SetWidth(int)
|
||||
SetStatus(string)
|
||||
SetCPU(int)
|
||||
SetNet(int64, int64)
|
||||
SetMem(int64, int64, int)
|
||||
type WidgetUpdater interface {
|
||||
SetMeta(string, string)
|
||||
SetMetrics(metrics.Metrics)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user