feat(tui): responsive table layout for all tabs
Extract shared computeTableLayout() into table_helpers.go — takes column definitions with short/full headers, min/max widths, and a flex column that absorbs surplus space. All tabs now use it: - Alerts: CONFIG column is flex, NAME/TYPE/SENT expand with width - Maint: TITLE column is flex, TYPE/MONITORS/STATUS/dates expand - Nodes: NAME column is flex, REGION/LAST SEEN/VERSION expand - Users: PUBLIC KEY column is flex, USERNAME expands - Sites: uses same colDef type (keeps special dual-flex for NAME+HISTORY) Headers auto-switch short/full based on available width across all tabs.
This commit is contained in:
@@ -10,16 +10,24 @@ func (m Model) viewNodesTab() string {
|
||||
return "\n No probe nodes connected."
|
||||
}
|
||||
|
||||
colWidths := []int{0, 12, 20, 10, 8}
|
||||
cols := []colDef{
|
||||
{"NAME", "NAME", 12, 24, true},
|
||||
{"REGION", "REGION", 8, 14, false},
|
||||
{"SEEN", "LAST SEEN", 8, 20, false},
|
||||
{"VER", "VERSION", 8, 12, false},
|
||||
{"STATUS", "STATUS", 8, 10, false},
|
||||
}
|
||||
headers, widths := m.computeTableLayout(cols, 0)
|
||||
nameW := widths[0]
|
||||
|
||||
return m.renderTable(
|
||||
[]string{"NAME", "REGION", "LAST SEEN", "VERSION", "STATUS"},
|
||||
headers,
|
||||
len(m.nodes),
|
||||
func(start, end int) [][]string {
|
||||
var rows [][]string
|
||||
for i := start; i < end; i++ {
|
||||
node := m.nodes[i]
|
||||
name := limitStr(node.Name, 20)
|
||||
name := limitStr(node.Name, nameW-2)
|
||||
if name == "" {
|
||||
name = node.ID
|
||||
}
|
||||
@@ -37,7 +45,7 @@ func (m Model) viewNodesTab() string {
|
||||
}
|
||||
return rows
|
||||
},
|
||||
colWidths,
|
||||
widths,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user