Sorting nodes by name now, dynamic padding for indexes based on if hidden indexes are toggled, fixed width for the node roles panel
This commit is contained in:
parent
7d2187ae85
commit
29ea00fb73
122
elastop.go
122
elastop.go
@ -456,28 +456,15 @@ func updateGridLayout(grid *tview.Grid, showRoles, showIndices, showMetrics bool
|
|||||||
// Start with clean grid
|
// Start with clean grid
|
||||||
grid.Clear()
|
grid.Clear()
|
||||||
|
|
||||||
visiblePanels := make([]struct {
|
visiblePanels := 0
|
||||||
panel *tview.TextView
|
|
||||||
show bool
|
|
||||||
}, 0)
|
|
||||||
|
|
||||||
if showRoles {
|
if showRoles {
|
||||||
visiblePanels = append(visiblePanels, struct {
|
visiblePanels++
|
||||||
panel *tview.TextView
|
|
||||||
show bool
|
|
||||||
}{rolesPanel, true})
|
|
||||||
}
|
}
|
||||||
if showIndices {
|
if showIndices {
|
||||||
visiblePanels = append(visiblePanels, struct {
|
visiblePanels++
|
||||||
panel *tview.TextView
|
|
||||||
show bool
|
|
||||||
}{indicesPanel, true})
|
|
||||||
}
|
}
|
||||||
if showMetrics {
|
if showMetrics {
|
||||||
visiblePanels = append(visiblePanels, struct {
|
visiblePanels++
|
||||||
panel *tview.TextView
|
|
||||||
show bool
|
|
||||||
}{metricsPanel, true})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust row configuration based on whether nodes panel is shown
|
// Adjust row configuration based on whether nodes panel is shown
|
||||||
@ -487,32 +474,54 @@ func updateGridLayout(grid *tview.Grid, showRoles, showIndices, showMetrics bool
|
|||||||
grid.SetRows(3, 0) // Just header and bottom panels
|
grid.SetRows(3, 0) // Just header and bottom panels
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up columns based on number of visible panels
|
// Configure columns based on visible panels
|
||||||
switch len(visiblePanels) {
|
switch {
|
||||||
case 3:
|
case visiblePanels == 3:
|
||||||
grid.SetColumns(-1, -2, -1) // 1:2:1 ratio
|
if showRoles {
|
||||||
case 2:
|
grid.SetColumns(30, -2, -1) // Changed from 20 to 30 for roles panel width
|
||||||
grid.SetColumns(-1, -1) // Two equal columns
|
}
|
||||||
case 1:
|
case visiblePanels == 2:
|
||||||
grid.SetColumns(-1) // Single column
|
if showRoles {
|
||||||
|
grid.SetColumns(30, 0) // Changed from 20 to 30 for roles panel width
|
||||||
|
} else {
|
||||||
|
grid.SetColumns(-1, -1) // Equal split between two panels
|
||||||
|
}
|
||||||
|
case visiblePanels == 1:
|
||||||
|
grid.SetColumns(0) // Single column takes full width
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always show header at top spanning all columns
|
// Always show header at top spanning all columns
|
||||||
grid.AddItem(header, 0, 0, 1, len(visiblePanels), 0, 0, false)
|
grid.AddItem(header, 0, 0, 1, visiblePanels, 0, 0, false)
|
||||||
|
|
||||||
// Add nodes panel if visible, spanning all columns
|
// Add nodes panel if visible, spanning all columns
|
||||||
if showNodes {
|
if showNodes {
|
||||||
grid.AddItem(nodesPanel, 1, 0, 1, len(visiblePanels), 0, 0, false)
|
grid.AddItem(nodesPanel, 1, 0, 1, visiblePanels, 0, 0, false)
|
||||||
|
}
|
||||||
|
|
||||||
// Add bottom panels
|
// Add bottom panels in their respective positions
|
||||||
for i, panel := range visiblePanels {
|
col := 0
|
||||||
grid.AddItem(panel.panel, 2, i, 1, 1, 0, 0, false)
|
if showRoles {
|
||||||
|
row := 1
|
||||||
|
if showNodes {
|
||||||
|
row = 2
|
||||||
}
|
}
|
||||||
} else {
|
grid.AddItem(rolesPanel, row, col, 1, 1, 0, 0, false)
|
||||||
// Add bottom panels starting from row 1
|
col++
|
||||||
for i, panel := range visiblePanels {
|
}
|
||||||
grid.AddItem(panel.panel, 1, i, 1, 1, 0, 0, false)
|
if showIndices {
|
||||||
|
row := 1
|
||||||
|
if showNodes {
|
||||||
|
row = 2
|
||||||
}
|
}
|
||||||
|
grid.AddItem(indicesPanel, row, col, 1, 1, 0, 0, false)
|
||||||
|
col++
|
||||||
|
}
|
||||||
|
if showMetrics {
|
||||||
|
row := 1
|
||||||
|
if showNodes {
|
||||||
|
row = 2
|
||||||
|
}
|
||||||
|
grid.AddItem(metricsPanel, row, col, 1, 1, 0, 0, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,7 +554,7 @@ func main() {
|
|||||||
|
|
||||||
app := tview.NewApplication()
|
app := tview.NewApplication()
|
||||||
|
|
||||||
// Update the grid layout to use three columns for the bottom section
|
// Update the grid layout to use proportional columns
|
||||||
grid := tview.NewGrid().
|
grid := tview.NewGrid().
|
||||||
SetRows(3, 0, 0). // Three rows: header, nodes, bottom panels
|
SetRows(3, 0, 0). // Three rows: header, nodes, bottom panels
|
||||||
SetColumns(-1, -2, -1). // Three columns for bottom row: roles (1), indices (2), metrics (1)
|
SetColumns(-1, -2, -1). // Three columns for bottom row: roles (1), indices (2), metrics (1)
|
||||||
@ -708,8 +717,18 @@ func main() {
|
|||||||
fmt.Fprintf(nodesPanel, "[::b][#00ffff][[#ff5555]2[#00ffff]] Nodes Information[::-]\n\n")
|
fmt.Fprintf(nodesPanel, "[::b][#00ffff][[#ff5555]2[#00ffff]] Nodes Information[::-]\n\n")
|
||||||
fmt.Fprint(nodesPanel, getNodesPanelHeader(maxNodeNameLen))
|
fmt.Fprint(nodesPanel, getNodesPanelHeader(maxNodeNameLen))
|
||||||
|
|
||||||
|
// Create a sorted slice of node IDs based on node names
|
||||||
|
var nodeIDs []string
|
||||||
|
for id := range nodesInfo.Nodes {
|
||||||
|
nodeIDs = append(nodeIDs, id)
|
||||||
|
}
|
||||||
|
sort.Slice(nodeIDs, func(i, j int) bool {
|
||||||
|
return nodesInfo.Nodes[nodeIDs[i]].Name < nodesInfo.Nodes[nodeIDs[j]].Name
|
||||||
|
})
|
||||||
|
|
||||||
// Update node entries with dynamic width
|
// Update node entries with dynamic width
|
||||||
for id, nodeInfo := range nodesInfo.Nodes {
|
for _, id := range nodeIDs {
|
||||||
|
nodeInfo := nodesInfo.Nodes[id]
|
||||||
nodeStats, exists := nodesStats.Nodes[id]
|
nodeStats, exists := nodesStats.Nodes[id]
|
||||||
if !exists {
|
if !exists {
|
||||||
continue
|
continue
|
||||||
@ -850,7 +869,6 @@ func main() {
|
|||||||
|
|
||||||
// Update index entries with dynamic width
|
// Update index entries with dynamic width
|
||||||
for _, idx := range indices {
|
for _, idx := range indices {
|
||||||
// Only show purple dot if there's actual indexing happening
|
|
||||||
writeIcon := "[#444444]⚪"
|
writeIcon := "[#444444]⚪"
|
||||||
if idx.indexingRate > 0 {
|
if idx.indexingRate > 0 {
|
||||||
writeIcon = "[#5555ff]⚫"
|
writeIcon = "[#5555ff]⚫"
|
||||||
@ -861,9 +879,11 @@ func main() {
|
|||||||
ingestedStr := ""
|
ingestedStr := ""
|
||||||
if activity != nil && activity.InitialDocsCount < idx.docs {
|
if activity != nil && activity.InitialDocsCount < idx.docs {
|
||||||
docChange := idx.docs - activity.InitialDocsCount
|
docChange := idx.docs - activity.InitialDocsCount
|
||||||
ingestedStr = fmt.Sprintf("[green]+%-11s", formatNumber(docChange))
|
// Pad the ingested string to 12 characters
|
||||||
|
ingestedStr = fmt.Sprintf("[green]%-12s", fmt.Sprintf("+%s", formatNumber(docChange)))
|
||||||
} else {
|
} else {
|
||||||
ingestedStr = fmt.Sprintf("%-12s", "") // Empty space if no changes
|
// When there's no ingestion, still pad with 12 spaces
|
||||||
|
ingestedStr = fmt.Sprintf("%-12s", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format indexing rate
|
// Format indexing rate
|
||||||
@ -881,7 +901,7 @@ func main() {
|
|||||||
// Convert the size format before display
|
// Convert the size format before display
|
||||||
sizeStr := convertSizeFormat(idx.storeSize)
|
sizeStr := convertSizeFormat(idx.storeSize)
|
||||||
|
|
||||||
fmt.Fprintf(indicesPanel, "%s [%s]%-*s [white][#444444]│[white] %15s [#444444]│[white] %12s [#444444]│[white] %8s [#444444]│[white] %8s [#444444]│[white] %s [#444444]│[white] %-10s\n",
|
fmt.Fprintf(indicesPanel, "%s [%s]%-*s[white] [#444444]│[white] %15s [#444444]│[white] %12s [#444444]│[white] %8s [#444444]│[white] %8s [#444444]│[white] %s [#444444]│[white] %-8s\n",
|
||||||
writeIcon,
|
writeIcon,
|
||||||
getHealthColor(idx.health),
|
getHealthColor(idx.health),
|
||||||
maxIndexNameLen,
|
maxIndexNameLen,
|
||||||
@ -890,7 +910,7 @@ func main() {
|
|||||||
sizeStr,
|
sizeStr,
|
||||||
idx.priShards,
|
idx.priShards,
|
||||||
idx.replicas,
|
idx.replicas,
|
||||||
ingestedStr,
|
ingestedStr, // Now properly padded
|
||||||
rateStr)
|
rateStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1072,7 +1092,7 @@ func main() {
|
|||||||
updateGridLayout(grid, showRoles, showIndices, showMetrics)
|
updateGridLayout(grid, showRoles, showIndices, showMetrics)
|
||||||
case 'h':
|
case 'h':
|
||||||
showHiddenIndices = !showHiddenIndices
|
showHiddenIndices = !showHiddenIndices
|
||||||
// Don't call update() directly, just let the periodic update handle it
|
// Let the regular update cycle handle it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return event
|
return event
|
||||||
@ -1126,17 +1146,19 @@ func getMaxLengths(nodesInfo NodesInfo, indicesStats IndexStats) (int, int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get max index name length
|
// Get max index name length only for visible indices
|
||||||
for _, index := range indicesStats {
|
for _, index := range indicesStats {
|
||||||
// Consider hidden indices in max length calculation if they're shown
|
// Only consider indices that should be visible based on showHiddenIndices
|
||||||
if (showHiddenIndices || !strings.HasPrefix(index.Index, ".")) &&
|
if (showHiddenIndices || !strings.HasPrefix(index.Index, ".")) && index.DocsCount != "0" {
|
||||||
len(index.Index) > maxIndexNameLen {
|
if len(index.Index) > maxIndexNameLen {
|
||||||
maxIndexNameLen = len(index.Index)
|
maxIndexNameLen = len(index.Index)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
maxNodeNameLen += 2 // Add padding
|
// Add padding
|
||||||
maxIndexNameLen += 2 // Add padding
|
maxNodeNameLen += 2
|
||||||
|
maxIndexNameLen += 1 // Single space before separator
|
||||||
|
|
||||||
return maxNodeNameLen, maxIndexNameLen
|
return maxNodeNameLen, maxIndexNameLen
|
||||||
}
|
}
|
||||||
@ -1157,7 +1179,7 @@ func getNodesPanelHeader(maxNodeNameLen int) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getIndicesPanelHeader(maxIndexNameLen int) string {
|
func getIndicesPanelHeader(maxIndexNameLen int) string {
|
||||||
return fmt.Sprintf(" [::b]%-*s [#444444]│[#00ffff] %15s [#444444]│[#00ffff] %12s [#444444]│[#00ffff] %8s [#444444]│[#00ffff] %8s [#444444]│[#00ffff] %-12s [#444444]│[#00ffff] %-10s[white]\n",
|
return fmt.Sprintf(" [::b]%-*s [#444444]│[#00ffff] %15s [#444444]│[#00ffff] %12s [#444444]│[#00ffff] %8s [#444444]│[#00ffff] %8s [#444444]│[#00ffff] %-12s [#444444]│[#00ffff] %-8s[white]\n",
|
||||||
maxIndexNameLen,
|
maxIndexNameLen,
|
||||||
"Index Name",
|
"Index Name",
|
||||||
"Documents",
|
"Documents",
|
||||||
|
Loading…
Reference in New Issue
Block a user