650e6c4b16
- Click Alerts/Nodes/Users sub-tabs in settings to switch sections - Click STATUS/NAME/LATENCY column headers to sort (click again to reverse direction) - Logs panel show/hide: [l] toggles sidebar visibility, click focused panel to hide. Monitors expand to full width when hidden. - Logs full-screen: Enter when focused on logs opens scrollable full-screen log view with severity tags, filter toggle [f], and live updates
63 lines
1.1 KiB
Go
63 lines
1.1 KiB
Go
package tui
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/charmbracelet/lipgloss"
|
|
)
|
|
|
|
func (m Model) viewSettingsTab() string {
|
|
maxSections := 2
|
|
if m.isAdmin {
|
|
maxSections = 3
|
|
}
|
|
|
|
sections := []string{"Alerts", "Nodes"}
|
|
if m.isAdmin {
|
|
sections = append(sections, "Users")
|
|
}
|
|
_ = maxSections
|
|
|
|
var tabs []string
|
|
for i, name := range sections {
|
|
var rendered string
|
|
if i == m.settingsSection {
|
|
rendered = m.st.activeTab.Render(name)
|
|
} else {
|
|
rendered = m.st.inactiveTab.Render(name)
|
|
}
|
|
tabs = append(tabs, m.zones.Mark(fmt.Sprintf("section-%d", i), rendered))
|
|
}
|
|
header := lipgloss.JoinHorizontal(lipgloss.Top, tabs...)
|
|
|
|
var content string
|
|
switch m.settingsSection {
|
|
case sectionAlerts:
|
|
content = m.viewAlertsTab()
|
|
case sectionNodes:
|
|
content = m.viewNodesTab()
|
|
case sectionUsers:
|
|
if m.isAdmin {
|
|
content = m.viewUsersTab()
|
|
}
|
|
}
|
|
|
|
return header + "\n" + content
|
|
}
|
|
|
|
func (m *Model) switchSettingsSection(idx int) {
|
|
max := 1
|
|
if m.isAdmin {
|
|
max = 2
|
|
}
|
|
if idx > max {
|
|
idx = 0
|
|
}
|
|
if idx < 0 {
|
|
idx = max
|
|
}
|
|
m.settingsSection = idx
|
|
m.cursor = 0
|
|
m.tableOffset = 0
|
|
}
|