refactor dockersource container refresh into channel

This commit is contained in:
Bradley Cicenas
2017-03-05 06:46:41 +00:00
parent 8fb5c5de59
commit 3172f141f9
9 changed files with 85 additions and 100 deletions

11
grid.go
View File

@@ -23,11 +23,9 @@ type Grid struct {
}
func NewGrid() *Grid {
cs := NewDockerContainerSource()
g := &Grid{
cSource: cs,
containers: cs.All(),
header: widgets.NewCTopHeader(),
cSource: NewDockerContainerSource(),
header: widgets.NewCTopHeader(),
}
return g
}
@@ -169,6 +167,7 @@ func Display(g *Grid) bool {
ui.DefaultEvtStream.Hook(logEvent)
// initial draw
g.containers = g.cSource.All()
g.redrawRows()
ui.Handle("/sys/kbd/<up>", func(ui.Event) {
@@ -178,7 +177,9 @@ func Display(g *Grid) bool {
g.cursorDown()
})
ui.Handle("/sys/kbd/<enter>", func(ui.Event) {
ui.StopLoop()
//c := g.containers[g.cursorIdx()]
//c.Widgets.ToggleExpand()
g.redrawRows()
})
ui.Handle("/sys/kbd/a", func(ui.Event) {