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:
|
||||
<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.
|
||||
|
||||
@ -80,6 +80,6 @@ q | Quit ctop
|
||||
|
||||
[build]: _docs/build.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"
|
||||
[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 (
|
||||
ui "github.com/gizak/termui"
|
@ -1,4 +1,4 @@
|
||||
package expanded
|
||||
package single
|
||||
|
||||
type IntHist struct {
|
||||
Val int // most current data point
|
@ -1,4 +1,4 @@
|
||||
package expanded
|
||||
package single
|
||||
|
||||
import (
|
||||
"strings"
|
@ -1,4 +1,4 @@
|
||||
package expanded
|
||||
package single
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -1,4 +1,4 @@
|
||||
package expanded
|
||||
package single
|
||||
|
||||
import (
|
||||
"time"
|
@ -1,4 +1,4 @@
|
||||
package expanded
|
||||
package single
|
||||
|
||||
import (
|
||||
"github.com/bcicen/ctop/logging"
|
||||
@ -12,7 +12,7 @@ var (
|
||||
colWidth = [2]int{65, 0} // left,right column width
|
||||
)
|
||||
|
||||
type Expanded struct {
|
||||
type Single struct {
|
||||
Info *Info
|
||||
Net *Net
|
||||
Cpu *Cpu
|
||||
@ -22,11 +22,11 @@ type Expanded struct {
|
||||
Width int
|
||||
}
|
||||
|
||||
func NewExpanded(id string) *Expanded {
|
||||
func NewSingle(id string) *Single {
|
||||
if len(id) > 12 {
|
||||
id = id[:12]
|
||||
}
|
||||
return &Expanded{
|
||||
return &Single{
|
||||
Info: NewInfo(id),
|
||||
Net: NewNet(),
|
||||
Cpu: NewCpu(),
|
||||
@ -36,7 +36,7 @@ func NewExpanded(id string) *Expanded {
|
||||
}
|
||||
}
|
||||
|
||||
func (e *Expanded) Up() {
|
||||
func (e *Single) Up() {
|
||||
if e.Y < 0 {
|
||||
e.Y++
|
||||
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()) {
|
||||
e.Y--
|
||||
e.Align()
|
||||
@ -52,10 +52,10 @@ func (e *Expanded) Down() {
|
||||
}
|
||||
}
|
||||
|
||||
func (e *Expanded) SetWidth(w int) { e.Width = w }
|
||||
func (e *Expanded) SetMeta(k, v string) { e.Info.Set(k, v) }
|
||||
func (e *Single) SetWidth(w int) { e.Width = w }
|
||||
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.Net.Update(m.NetRx, m.NetTx)
|
||||
e.Mem.Update(int(m.MemUsage), int(m.MemLimit))
|
||||
@ -63,7 +63,7 @@ func (e *Expanded) SetMetrics(m models.Metrics) {
|
||||
}
|
||||
|
||||
// Return total column height
|
||||
func (e *Expanded) GetHeight() (h int) {
|
||||
func (e *Single) GetHeight() (h int) {
|
||||
h += e.Info.Height
|
||||
h += e.Net.Height
|
||||
h += e.Cpu.Height
|
||||
@ -72,7 +72,7 @@ func (e *Expanded) GetHeight() (h int) {
|
||||
return h
|
||||
}
|
||||
|
||||
func (e *Expanded) Align() {
|
||||
func (e *Single) Align() {
|
||||
// reset offset if needed
|
||||
if e.GetHeight() <= ui.TermHeight() {
|
||||
e.Y = 0
|
||||
@ -94,7 +94,7 @@ func (e *Expanded) Align() {
|
||||
func calcWidth(w int) {
|
||||
}
|
||||
|
||||
func (e *Expanded) Buffer() ui.Buffer {
|
||||
func (e *Single) Buffer() ui.Buffer {
|
||||
buf := ui.NewBuffer()
|
||||
if e.Width < (colWidth[0] + colWidth[1]) {
|
||||
ui.Clear()
|
||||
@ -109,7 +109,7 @@ func (e *Expanded) Buffer() ui.Buffer {
|
||||
return buf
|
||||
}
|
||||
|
||||
func (e *Expanded) all() []ui.GridBufferer {
|
||||
func (e *Single) all() []ui.GridBufferer {
|
||||
return []ui.GridBufferer{
|
||||
e.Info,
|
||||
e.Cpu,
|
@ -1,4 +1,4 @@
|
||||
package expanded
|
||||
package single
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -1,4 +1,4 @@
|
||||
package expanded
|
||||
package single
|
||||
|
||||
import (
|
||||
"fmt"
|
14
grid.go
14
grid.go
@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"github.com/bcicen/ctop/config"
|
||||
"github.com/bcicen/ctop/container"
|
||||
"github.com/bcicen/ctop/cwidgets/expanded"
|
||||
"github.com/bcicen/ctop/cwidgets/single"
|
||||
ui "github.com/gizak/termui"
|
||||
)
|
||||
|
||||
@ -35,12 +35,12 @@ func RedrawRows(clr bool) {
|
||||
ui.Render(cGrid)
|
||||
}
|
||||
|
||||
func ExpandView(c *container.Container) {
|
||||
func SingleView(c *container.Container) {
|
||||
ui.Clear()
|
||||
ui.DefaultEvtStream.ResetHandlers()
|
||||
defer ui.DefaultEvtStream.ResetHandlers()
|
||||
|
||||
ex := expanded.NewExpanded(c.Id)
|
||||
ex := single.NewSingle(c.Id)
|
||||
c.SetUpdater(ex)
|
||||
|
||||
ex.Align()
|
||||
@ -71,7 +71,7 @@ func RefreshDisplay() {
|
||||
|
||||
func Display() bool {
|
||||
var menu func()
|
||||
var expand bool
|
||||
var single bool
|
||||
|
||||
cGrid.SetWidth(ui.TermWidth())
|
||||
ui.DefaultEvtStream.Hook(logEvent)
|
||||
@ -94,7 +94,7 @@ func Display() bool {
|
||||
})
|
||||
|
||||
ui.Handle("/sys/kbd/<enter>", func(ui.Event) {
|
||||
expand = true
|
||||
single = true
|
||||
ui.StopLoop()
|
||||
})
|
||||
ui.Handle("/sys/kbd/a", func(ui.Event) {
|
||||
@ -137,10 +137,10 @@ func Display() bool {
|
||||
menu()
|
||||
return false
|
||||
}
|
||||
if expand {
|
||||
if single {
|
||||
c := cursor.Selected()
|
||||
if c != nil {
|
||||
ExpandView(c)
|
||||
SingleView(c)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user