feat(tui): consolidate tabs 6→3, add log sidebar #145
@@ -82,8 +82,12 @@ func (m Model) computeLayout() tableLayout {
|
||||
var widths []int
|
||||
var fixed int
|
||||
|
||||
cw := m.contentWidth
|
||||
if cw == 0 {
|
||||
cw = m.termWidth
|
||||
}
|
||||
for _, c := range siteColumns {
|
||||
if c.minTerm > 0 && m.termWidth < c.minTerm {
|
||||
if c.minTerm > 0 && cw < c.minTerm {
|
||||
continue
|
||||
}
|
||||
active = append(active, c.key)
|
||||
@@ -104,7 +108,7 @@ func (m Model) computeLayout() tableLayout {
|
||||
|
||||
numCols := len(headers)
|
||||
borderOverhead := 2 + (numCols - 1)
|
||||
avail := m.termWidth - chromePadH - 2 - borderOverhead - fixed
|
||||
avail := cw - chromePadH - 2 - borderOverhead - fixed
|
||||
if avail < 20 {
|
||||
avail = 20
|
||||
}
|
||||
|
||||
@@ -13,7 +13,11 @@ const (
|
||||
)
|
||||
|
||||
func (m Model) isWide() bool {
|
||||
return m.termWidth >= wideBreakpoint
|
||||
w := m.contentWidth
|
||||
if w == 0 {
|
||||
w = m.termWidth
|
||||
}
|
||||
return w >= wideBreakpoint
|
||||
}
|
||||
|
||||
func (m Model) renderTable(headers []string, items int, buildRows func(start, end int) [][]string, colWidths []int, styleOverride StyleOverride) string {
|
||||
@@ -35,7 +39,11 @@ func (m Model) renderTable(headers []string, items int, buildRows func(start, en
|
||||
}
|
||||
borderOverhead := 2 + len(colWidths) - 1
|
||||
tableWidth := colTotal + borderOverhead
|
||||
maxWidth := m.termWidth - chromePadH - 2
|
||||
cw := m.contentWidth
|
||||
if cw == 0 {
|
||||
cw = m.termWidth
|
||||
}
|
||||
maxWidth := cw - chromePadH - 2
|
||||
if tableWidth > maxWidth {
|
||||
tableWidth = maxWidth
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@ type Model struct {
|
||||
maxTableRows int
|
||||
termWidth int
|
||||
termHeight int
|
||||
contentWidth int
|
||||
editID int
|
||||
editToken string
|
||||
|
||||
|
||||
@@ -152,21 +152,26 @@ func (m Model) viewDashboard() string {
|
||||
var content string
|
||||
switch m.currentTab {
|
||||
case tabMonitors:
|
||||
monitors := m.viewSitesTab()
|
||||
if m.termWidth >= wideBreakpoint {
|
||||
showSidebar := m.termWidth >= wideBreakpoint
|
||||
if showSidebar {
|
||||
availW := m.termWidth - chromePadH
|
||||
leftW := availW * 70 / 100
|
||||
rightW := availW - leftW
|
||||
m.contentWidth = leftW
|
||||
monitors := m.viewSitesTab()
|
||||
left := lipgloss.NewStyle().Width(leftW).Render(monitors)
|
||||
sidebar := m.viewLogsSidebar(rightW)
|
||||
right := lipgloss.NewStyle().Width(rightW).Render(sidebar)
|
||||
content = lipgloss.JoinHorizontal(lipgloss.Top, left, right)
|
||||
} else {
|
||||
content = monitors
|
||||
m.contentWidth = m.termWidth
|
||||
content = m.viewSitesTab()
|
||||
}
|
||||
case tabMaint:
|
||||
m.contentWidth = m.termWidth
|
||||
content = m.viewMaintTab()
|
||||
case tabSettings:
|
||||
m.contentWidth = m.termWidth
|
||||
content = m.viewSettingsTab()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user