feat(tui): column sort with indicator on monitors table
Press < / > to cycle sort column (Status, Name, Latency). Press r to reverse direction. Sorted column shows ▲/▼ arrow in the header. Groups always float to top. Sort applies to ungrouped monitors and group children independently. Default: Status descending (DOWN first).
This commit is contained in:
@@ -106,6 +106,24 @@ func (m Model) computeLayout() tableLayout {
|
||||
}
|
||||
}
|
||||
|
||||
sortColMap := map[int]colKey{
|
||||
sortStatus: colStatus,
|
||||
sortName: colName,
|
||||
sortLatency: colLatency,
|
||||
}
|
||||
if sortedKey, ok := sortColMap[m.sortColumn]; ok {
|
||||
arrow := "▼"
|
||||
if m.sortAsc {
|
||||
arrow = "▲"
|
||||
}
|
||||
for i, k := range active {
|
||||
if k == sortedKey {
|
||||
headers[i] = headers[i] + arrow
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
numCols := len(headers)
|
||||
borderOverhead := 2 + (numCols - 1)
|
||||
avail := cw - chromePadH - 2 - borderOverhead - fixed
|
||||
|
||||
Reference in New Issue
Block a user