Compare commits

1 Commits

Author SHA1 Message Date
lerko 24b0cb05ba refactor(tui): replace # column with colored status dot
CI / lint (pull_request) Has been cancelled
CI / vulncheck (pull_request) Has been cancelled
CI / test (pull_request) Has been cancelled
Drop the row-number column and add a colored status dot as the first
column. Dot uses the same icon/color as the existing status indicators
(▲ green for up, ▼ red for down, ◼ purple for maint, etc). Matches
the maint strip visual pattern. Status text column retained for
explicit label.
2026-06-30 23:29:45 -04:00
+17 -49
View File
@@ -37,6 +37,7 @@ const (
colDot colKey = iota
colName
colType
colStatus
colLatency
colUptime
colHistory
@@ -56,16 +57,15 @@ type columnDef struct {
var siteColumns = []columnDef{
{colDot, "", "", 3, 3, 0},
{colName, "NAME", "NAME", 0, 0, 0},
{colType, "TYPE", "TYPE", 10, 8, 0},
{colType, "TYPE", "TYPE", 10, 8, mediumBreakpoint},
{colStatus, "STATUS", "STATUS", 10, 10, 0},
{colLatency, "LATENCY", "LAT", 10, 7, 0},
{colUptime, "UPTIME", "UP%", 8, 8, 0},
{colHistory, "HISTORY", "HISTORY", 0, 0, 0},
{colSSL, "SSL", "SSL", 7, 5, 0},
{colRetries, "RETRIES", "RT", 9, 5, 0},
{colUptime, "UPTIME", "UP%", 8, 8, mediumBreakpoint},
{colHistory, "HISTORY", "HISTORY", 0, 0, mediumBreakpoint},
{colSSL, "SSL", "SSL", 7, 5, wideBreakpoint},
{colRetries, "RETRIES", "RT", 9, 5, wideBreakpoint},
}
var columnDropOrder = []colKey{colHistory, colRetries, colSSL, colUptime, colType}
type tableLayout struct {
nameW, sparkW int
headers []string
@@ -76,51 +76,17 @@ type tableLayout struct {
func (m Model) computeLayout() tableLayout {
wide := m.isWide()
cw := m.contentWidth
if cw == 0 {
cw = m.termWidth
}
dropped := make(map[colKey]bool)
minNameW := 20
minSparkW := 12
for attempt := 0; attempt <= len(columnDropOrder); attempt++ {
var fixed int
var flexCount int
for _, c := range siteColumns {
if dropped[c.key] {
continue
}
w := c.narrowW
if wide {
w = c.wideW
}
if w > 0 {
fixed += w
} else {
flexCount++
}
}
numCols := len(siteColumns) - len(dropped)
borderOverhead := 2 + (numCols - 1)
avail := cw - chromePadH - 2 - borderOverhead - fixed
minFlex := minNameW
if flexCount > 1 {
minFlex += minSparkW
}
if avail >= minFlex || attempt >= len(columnDropOrder) {
break
}
dropped[columnDropOrder[attempt]] = true
}
var active []colKey
var headers []string
var widths []int
var fixed int
cw := m.contentWidth
if cw == 0 {
cw = m.termWidth
}
for _, c := range siteColumns {
if dropped[c.key] {
if c.minTerm > 0 && cw < c.minTerm {
continue
}
active = append(active, c.key)
@@ -140,12 +106,12 @@ func (m Model) computeLayout() tableLayout {
}
sortColMap := map[int]colKey{
sortStatus: colDot,
sortStatus: colStatus,
sortName: colName,
sortLatency: colLatency,
}
sortableKeys := map[colKey]string{
colDot: "sort-status",
colStatus: "sort-status",
colName: "sort-name",
colLatency: "sort-latency",
}
@@ -284,6 +250,7 @@ func (m Model) viewSitesTab() string {
colDot: m.fmtStatusDot(site.Status, site.Paused, inMaint),
colName: m.zones.Mark(fmt.Sprintf("site-%d", i), icon+" "+limitStr(site.Name, nameW-4)),
colType: "group",
colStatus: m.fmtStatus(site.Status, site.Paused, inMaint),
colLatency: m.st.subtleStyle.Render("—"),
colUptime: m.groupUptime(site.ID),
colHistory: m.groupSparkline(site.ID, sparkWidth, rowBg),
@@ -332,6 +299,7 @@ func (m Model) viewSitesTab() string {
colDot: m.fmtStatusDot(site.Status, site.Paused, inMaint),
colName: m.zones.Mark(fmt.Sprintf("site-%d", i), name),
colType: typeIcon(site.Type, false) + " " + site.Type,
colStatus: m.fmtStatus(site.Status, site.Paused, inMaint),
colLatency: m.fmtLatency(site.Latency),
colUptime: m.fmtUptimeMaint(hist.Statuses, site.ID),
colHistory: spark,