1856820c3e
Replace 3-tab navigation with a single monitoring dashboard. - Replace tab bar with minimal status line (pulse + counts + version) - Maintenance becomes a toggleable left sidebar (m key) - Compact list: active (●) and scheduled (○) windows - Enter opens full-screen detail with end/delete actions - Settings becomes a centered floating overlay (S key) - Alerts/Nodes/Users sub-sections with left/right navigation - Full CRUD support inside overlay with returnState tracking - Remove currentTab, switchTab, tab constants, tab click zones - Replace deleteTab with deleteKind string for cleaner dispatch - Separate settingsCursor/settingsOffset from main cursor - Panel focus: maint → monitors → logs → detail - Context-sensitive footer key hints per focused panel
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package tui
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/charmbracelet/lipgloss"
|
|
)
|
|
|
|
func (m Model) titledPanel(title, content string, width int, focused bool) string {
|
|
borderColor := m.theme.Border
|
|
titleColor := m.theme.Muted
|
|
if focused {
|
|
borderColor = m.theme.Accent
|
|
titleColor = m.theme.Accent
|
|
}
|
|
|
|
bc := lipgloss.NewStyle().Foreground(borderColor)
|
|
tc := lipgloss.NewStyle().Foreground(titleColor).Bold(true)
|
|
|
|
innerW := width - 2
|
|
if innerW < 10 {
|
|
innerW = 10
|
|
}
|
|
|
|
titleRendered := tc.Render(" " + title + " ")
|
|
titleLen := len([]rune(title)) + 2
|
|
fillLen := innerW - titleLen - 1
|
|
if fillLen < 0 {
|
|
fillLen = 0
|
|
}
|
|
|
|
top := bc.Render("╭─") + titleRendered + bc.Render(strings.Repeat("─", fillLen)+"╮")
|
|
|
|
contentStyle := lipgloss.NewStyle().Width(innerW).MaxWidth(innerW)
|
|
inner := contentStyle.Render(content)
|
|
|
|
var lines []string
|
|
lines = append(lines, top)
|
|
for _, line := range strings.Split(inner, "\n") {
|
|
lines = append(lines, bc.Render("│")+line+strings.Repeat(" ", max(0, innerW-lipgloss.Width(line)))+bc.Render("│"))
|
|
}
|
|
lines = append(lines, bc.Render("╰"+strings.Repeat("─", innerW)+"╯"))
|
|
|
|
return strings.Join(lines, "\n")
|
|
}
|
|
|
|
func max(a, b int) int {
|
|
if a > b {
|
|
return a
|
|
}
|
|
return b
|
|
}
|
|
|
|
func placeOverlay(fg string, termW, termH int) string {
|
|
return lipgloss.Place(termW, termH, lipgloss.Center, lipgloss.Center, fg)
|
|
}
|