Skip to content

Commit

Permalink
containers ui
Browse files Browse the repository at this point in the history
  • Loading branch information
togettoyou committed Dec 1, 2021
1 parent 51fb62c commit 956c464
Showing 1 changed file with 44 additions and 12 deletions.
56 changes: 44 additions & 12 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type tabPage struct {
contents *tview.Flex
infos *tview.TextView
events *tview.Table
containers *tview.List
logs *tview.TextView
}

Expand Down Expand Up @@ -175,29 +176,58 @@ func (u *ui) initTabPages() {
SetWordWrap(true).
SetBorder(true).
SetTitle(content[0])
infos.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
switch event.Key() {
case tcell.KeyBackspace2:
u.app.SetFocus(u.tabPage.tabs)
case tcell.KeyEnter:
u.app.SetFocus(u.namespaces)
}
return event
})

events := tview.NewTable()
events.SetBorders(true)
events.SetTitle(content[1]).
SetBorder(true)
events.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
switch event.Key() {
case tcell.KeyBackspace2:
u.app.SetFocus(u.tabPage.tabs)
case tcell.KeyEnter:
u.app.SetFocus(u.namespaces)
}
return event
})

containers := tview.NewList()
containers.SetBorder(true).SetTitle("Containers")
containers.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
switch event.Key() {
case tcell.KeyBackspace2:
u.app.SetFocus(u.tabPage.tabs)
case tcell.KeyEnter:
u.app.SetFocus(u.tabPage.logs)
}
return event
})

logs := tview.NewTextView()
logs.SetWordWrap(true).
SetBorder(true).
SetTitle(content[2])

contents.AddItem(infos, 0, 1, true)

contents.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
logs.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
switch event.Key() {
case tcell.KeyBackspace2:
u.app.SetFocus(u.tabPage.tabs)
u.app.SetFocus(u.tabPage.containers)
case tcell.KeyEnter:
u.app.SetFocus(u.namespaces)
}
return event
})

contents.AddItem(infos, 0, 1, true)

tabs := tview.NewTextView().
SetTextAlign(tview.AlignCenter).
SetDynamicColors(true).
Expand All @@ -220,7 +250,8 @@ func (u *ui) initTabPages() {
case 1:
u.tabPage.contents.AddItem(u.tabPage.events, 0, 1, true)
case 2:
u.tabPage.contents.AddItem(u.tabPage.logs, 0, 1, true)
u.tabPage.contents.AddItem(u.tabPage.containers, 0, 1, true)
u.tabPage.contents.AddItem(u.tabPage.logs, 0, 3, false)
}
u.updateTabPageContents()
})
Expand Down Expand Up @@ -259,12 +290,13 @@ func (u *ui) initTabPages() {
})

u.tabPage = &tabPage{
tab: content[0],
tabs: tabs,
infos: infos,
events: events,
logs: logs,
contents: contents,
tab: content[0],
tabs: tabs,
infos: infos,
events: events,
containers: containers,
logs: logs,
contents: contents,
}
}

Expand Down

0 comments on commit 956c464

Please sign in to comment.