Added a toggle to press h to hide/show hidden indexes

This commit is contained in:
Dionysus 2024-11-29 12:08:23 -05:00
parent 12b106cda5
commit 7d2187ae85
Signed by: acidvegas
GPG Key ID: EF4B922DB85DC9DE
2 changed files with 55 additions and 49 deletions

BIN
elastop

Binary file not shown.

View File

@ -211,6 +211,7 @@ var (
showRoles = true
showIndices = true
showMetrics = true
showHiddenIndices = false
)
var (
@ -700,7 +701,7 @@ func main() {
clusterStats.Nodes.Total,
clusterStats.Nodes.Successful,
clusterStats.Nodes.Failed)
fmt.Fprintf(header, "[#666666]Press 2-5 to toggle panels, 'q' to quit[white]\n")
fmt.Fprintf(header, "[#666666]Press 2-5 to toggle panels, 'h' to toggle hidden indices, 'q' to quit[white]\n")
// Update nodes panel with dynamic width
nodesPanel.Clear()
@ -792,8 +793,10 @@ func main() {
// Collect index information
for _, index := range indicesStats {
// Skip hidden indices
if !strings.HasPrefix(index.Index, ".") && index.DocsCount != "0" {
// Skip hidden indices unless showHiddenIndices is true
if (!showHiddenIndices && strings.HasPrefix(index.Index, ".")) || index.DocsCount == "0" {
continue
}
docs := 0
fmt.Sscanf(index.DocsCount, "%d", &docs)
totalDocs += docs
@ -834,7 +837,6 @@ func main() {
indexingRate: indexingRate,
})
}
}
// Calculate total size
for _, node := range nodesStats.Nodes {
@ -1068,6 +1070,9 @@ func main() {
case '5':
showMetrics = !showMetrics
updateGridLayout(grid, showRoles, showIndices, showMetrics)
case 'h':
showHiddenIndices = !showHiddenIndices
// Don't call update() directly, just let the periodic update handle it
}
}
return event
@ -1123,14 +1128,15 @@ func getMaxLengths(nodesInfo NodesInfo, indicesStats IndexStats) (int, int) {
// Get max index name length
for _, index := range indicesStats {
if !strings.HasPrefix(index.Index, ".") && // Skip hidden indices
// Consider hidden indices in max length calculation if they're shown
if (showHiddenIndices || !strings.HasPrefix(index.Index, ".")) &&
len(index.Index) > maxIndexNameLen {
maxIndexNameLen = len(index.Index)
}
}
maxNodeNameLen += 2
maxIndexNameLen += 2
maxNodeNameLen += 2 // Add padding
maxIndexNameLen += 2 // Add padding
return maxNodeNameLen, maxIndexNameLen
}