mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
add sorting by container state
This commit is contained in:
parent
9b483ba2f3
commit
a1fdd8fb49
2
grid.go
2
grid.go
@ -64,7 +64,7 @@ func (g *Grid) cursorUp() {
|
||||
func (g *Grid) cursorDown() {
|
||||
idx := g.cursorIdx()
|
||||
// increment if possible
|
||||
if idx > (len(g.containers) - 1) {
|
||||
if idx >= (len(g.containers) - 1) {
|
||||
return
|
||||
}
|
||||
if idx >= g.maxRows-1 {
|
||||
|
12
sort.go
12
sort.go
@ -16,6 +16,18 @@ var Sorters = map[string]sortMethod{
|
||||
"mem": func(c1, c2 *Container) bool { return c1.metrics.MemUsage < c2.metrics.MemUsage },
|
||||
"mem %": func(c1, c2 *Container) bool { return c1.metrics.MemPercent < c2.metrics.MemPercent },
|
||||
"net": func(c1, c2 *Container) bool { return sumNet(c1) < sumNet(c2) },
|
||||
"state": func(c1, c2 *Container) bool {
|
||||
if c1.state == "running" {
|
||||
return true
|
||||
}
|
||||
if c2.state == "running" {
|
||||
return false
|
||||
}
|
||||
if c2.state == "paused" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
}
|
||||
|
||||
func SortFields() (fields []string) {
|
||||
|
Loading…
Reference in New Issue
Block a user