mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
rename expanded -> single view
This commit is contained in:
parent
3ed9912bcb
commit
27e272c58f
@ -9,7 +9,7 @@ Top-like interface for container metrics
|
|||||||
`ctop` provides a concise and condensed overview of real-time metrics for multiple containers:
|
`ctop` provides a concise and condensed overview of real-time metrics for multiple containers:
|
||||||
<p align="center"><img src="_docs/img/grid.gif" alt="ctop"/></p>
|
<p align="center"><img src="_docs/img/grid.gif" alt="ctop"/></p>
|
||||||
|
|
||||||
as well as an [expanded view][expanded_view] for inspecting a specific container.
|
as well as an [single container view][single_view] for inspecting a specific container.
|
||||||
|
|
||||||
`ctop` comes with built-in support for Docker and runC; connectors for other container and cluster systems are planned for future releases.
|
`ctop` comes with built-in support for Docker and runC; connectors for other container and cluster systems are planned for future releases.
|
||||||
|
|
||||||
@ -80,6 +80,6 @@ q | Quit ctop
|
|||||||
|
|
||||||
[build]: _docs/build.md
|
[build]: _docs/build.md
|
||||||
[connectors]: _docs/connectors.md
|
[connectors]: _docs/connectors.md
|
||||||
[expanded_view]: _docs/expanded.md
|
[single_view]: _docs/single.md
|
||||||
[release]: https://img.shields.io/github/release/bcicen/ctop.svg "ctop"
|
[release]: https://img.shields.io/github/release/bcicen/ctop.svg "ctop"
|
||||||
[homebrew]: https://img.shields.io/homebrew/v/ctop.svg "ctop"
|
[homebrew]: https://img.shields.io/homebrew/v/ctop.svg "ctop"
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
# Expanded View
|
|
||||||
|
|
||||||
ctop provides an expanded, rolling view for following container metrics
|
|
||||||
<p align="center"><img width="80%" src="img/expanded.gif" alt="ctop"/></p>
|
|
Before Width: | Height: | Size: 549 KiB After Width: | Height: | Size: 549 KiB |
4
_docs/single.md
Normal file
4
_docs/single.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Single Container View
|
||||||
|
|
||||||
|
ctop provides a rolling, single container view for following metrics
|
||||||
|
<p align="center"><img width="80%" src="img/single.gif" alt="ctop"/></p>
|
@ -1,4 +1,4 @@
|
|||||||
package expanded
|
package single
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ui "github.com/gizak/termui"
|
ui "github.com/gizak/termui"
|
@ -1,4 +1,4 @@
|
|||||||
package expanded
|
package single
|
||||||
|
|
||||||
type IntHist struct {
|
type IntHist struct {
|
||||||
Val int // most current data point
|
Val int // most current data point
|
@ -1,4 +1,4 @@
|
|||||||
package expanded
|
package single
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
@ -1,4 +1,4 @@
|
|||||||
package expanded
|
package single
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package expanded
|
package single
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
@ -1,4 +1,4 @@
|
|||||||
package expanded
|
package single
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bcicen/ctop/logging"
|
"github.com/bcicen/ctop/logging"
|
||||||
@ -12,7 +12,7 @@ var (
|
|||||||
colWidth = [2]int{65, 0} // left,right column width
|
colWidth = [2]int{65, 0} // left,right column width
|
||||||
)
|
)
|
||||||
|
|
||||||
type Expanded struct {
|
type Single struct {
|
||||||
Info *Info
|
Info *Info
|
||||||
Net *Net
|
Net *Net
|
||||||
Cpu *Cpu
|
Cpu *Cpu
|
||||||
@ -22,11 +22,11 @@ type Expanded struct {
|
|||||||
Width int
|
Width int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewExpanded(id string) *Expanded {
|
func NewSingle(id string) *Single {
|
||||||
if len(id) > 12 {
|
if len(id) > 12 {
|
||||||
id = id[:12]
|
id = id[:12]
|
||||||
}
|
}
|
||||||
return &Expanded{
|
return &Single{
|
||||||
Info: NewInfo(id),
|
Info: NewInfo(id),
|
||||||
Net: NewNet(),
|
Net: NewNet(),
|
||||||
Cpu: NewCpu(),
|
Cpu: NewCpu(),
|
||||||
@ -36,7 +36,7 @@ func NewExpanded(id string) *Expanded {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Expanded) Up() {
|
func (e *Single) Up() {
|
||||||
if e.Y < 0 {
|
if e.Y < 0 {
|
||||||
e.Y++
|
e.Y++
|
||||||
e.Align()
|
e.Align()
|
||||||
@ -44,7 +44,7 @@ func (e *Expanded) Up() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Expanded) Down() {
|
func (e *Single) Down() {
|
||||||
if e.Y > (ui.TermHeight() - e.GetHeight()) {
|
if e.Y > (ui.TermHeight() - e.GetHeight()) {
|
||||||
e.Y--
|
e.Y--
|
||||||
e.Align()
|
e.Align()
|
||||||
@ -52,10 +52,10 @@ func (e *Expanded) Down() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Expanded) SetWidth(w int) { e.Width = w }
|
func (e *Single) SetWidth(w int) { e.Width = w }
|
||||||
func (e *Expanded) SetMeta(k, v string) { e.Info.Set(k, v) }
|
func (e *Single) SetMeta(k, v string) { e.Info.Set(k, v) }
|
||||||
|
|
||||||
func (e *Expanded) SetMetrics(m models.Metrics) {
|
func (e *Single) SetMetrics(m models.Metrics) {
|
||||||
e.Cpu.Update(m.CPUUtil)
|
e.Cpu.Update(m.CPUUtil)
|
||||||
e.Net.Update(m.NetRx, m.NetTx)
|
e.Net.Update(m.NetRx, m.NetTx)
|
||||||
e.Mem.Update(int(m.MemUsage), int(m.MemLimit))
|
e.Mem.Update(int(m.MemUsage), int(m.MemLimit))
|
||||||
@ -63,7 +63,7 @@ func (e *Expanded) SetMetrics(m models.Metrics) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return total column height
|
// Return total column height
|
||||||
func (e *Expanded) GetHeight() (h int) {
|
func (e *Single) GetHeight() (h int) {
|
||||||
h += e.Info.Height
|
h += e.Info.Height
|
||||||
h += e.Net.Height
|
h += e.Net.Height
|
||||||
h += e.Cpu.Height
|
h += e.Cpu.Height
|
||||||
@ -72,7 +72,7 @@ func (e *Expanded) GetHeight() (h int) {
|
|||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Expanded) Align() {
|
func (e *Single) Align() {
|
||||||
// reset offset if needed
|
// reset offset if needed
|
||||||
if e.GetHeight() <= ui.TermHeight() {
|
if e.GetHeight() <= ui.TermHeight() {
|
||||||
e.Y = 0
|
e.Y = 0
|
||||||
@ -94,7 +94,7 @@ func (e *Expanded) Align() {
|
|||||||
func calcWidth(w int) {
|
func calcWidth(w int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Expanded) Buffer() ui.Buffer {
|
func (e *Single) Buffer() ui.Buffer {
|
||||||
buf := ui.NewBuffer()
|
buf := ui.NewBuffer()
|
||||||
if e.Width < (colWidth[0] + colWidth[1]) {
|
if e.Width < (colWidth[0] + colWidth[1]) {
|
||||||
ui.Clear()
|
ui.Clear()
|
||||||
@ -109,7 +109,7 @@ func (e *Expanded) Buffer() ui.Buffer {
|
|||||||
return buf
|
return buf
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Expanded) all() []ui.GridBufferer {
|
func (e *Single) all() []ui.GridBufferer {
|
||||||
return []ui.GridBufferer{
|
return []ui.GridBufferer{
|
||||||
e.Info,
|
e.Info,
|
||||||
e.Cpu,
|
e.Cpu,
|
@ -1,4 +1,4 @@
|
|||||||
package expanded
|
package single
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package expanded
|
package single
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
14
grid.go
14
grid.go
@ -3,7 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"github.com/bcicen/ctop/config"
|
"github.com/bcicen/ctop/config"
|
||||||
"github.com/bcicen/ctop/container"
|
"github.com/bcicen/ctop/container"
|
||||||
"github.com/bcicen/ctop/cwidgets/expanded"
|
"github.com/bcicen/ctop/cwidgets/single"
|
||||||
ui "github.com/gizak/termui"
|
ui "github.com/gizak/termui"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,12 +35,12 @@ func RedrawRows(clr bool) {
|
|||||||
ui.Render(cGrid)
|
ui.Render(cGrid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExpandView(c *container.Container) {
|
func SingleView(c *container.Container) {
|
||||||
ui.Clear()
|
ui.Clear()
|
||||||
ui.DefaultEvtStream.ResetHandlers()
|
ui.DefaultEvtStream.ResetHandlers()
|
||||||
defer ui.DefaultEvtStream.ResetHandlers()
|
defer ui.DefaultEvtStream.ResetHandlers()
|
||||||
|
|
||||||
ex := expanded.NewExpanded(c.Id)
|
ex := single.NewSingle(c.Id)
|
||||||
c.SetUpdater(ex)
|
c.SetUpdater(ex)
|
||||||
|
|
||||||
ex.Align()
|
ex.Align()
|
||||||
@ -71,7 +71,7 @@ func RefreshDisplay() {
|
|||||||
|
|
||||||
func Display() bool {
|
func Display() bool {
|
||||||
var menu func()
|
var menu func()
|
||||||
var expand bool
|
var single bool
|
||||||
|
|
||||||
cGrid.SetWidth(ui.TermWidth())
|
cGrid.SetWidth(ui.TermWidth())
|
||||||
ui.DefaultEvtStream.Hook(logEvent)
|
ui.DefaultEvtStream.Hook(logEvent)
|
||||||
@ -94,7 +94,7 @@ func Display() bool {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ui.Handle("/sys/kbd/<enter>", func(ui.Event) {
|
ui.Handle("/sys/kbd/<enter>", func(ui.Event) {
|
||||||
expand = true
|
single = true
|
||||||
ui.StopLoop()
|
ui.StopLoop()
|
||||||
})
|
})
|
||||||
ui.Handle("/sys/kbd/a", func(ui.Event) {
|
ui.Handle("/sys/kbd/a", func(ui.Event) {
|
||||||
@ -137,10 +137,10 @@ func Display() bool {
|
|||||||
menu()
|
menu()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if expand {
|
if single {
|
||||||
c := cursor.Selected()
|
c := cursor.Selected()
|
||||||
if c != nil {
|
if c != nil {
|
||||||
ExpandView(c)
|
SingleView(c)
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user