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