refactor(tui): replace # column with colored status dot
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.
This commit is contained in:
@@ -162,6 +162,27 @@ func (m Model) fmtRetries(site models.Site) string {
|
||||
return s
|
||||
}
|
||||
|
||||
func (m Model) fmtStatusDot(status models.Status, paused bool, inMaint bool) string {
|
||||
if paused {
|
||||
return m.st.warnStyle.Render("◇")
|
||||
}
|
||||
if inMaint {
|
||||
return m.st.maintStyle.Render("◼")
|
||||
}
|
||||
switch status {
|
||||
case models.StatusDown, models.StatusSSLExp:
|
||||
return m.st.dangerStyle.Render("▼")
|
||||
case models.StatusLate:
|
||||
return m.st.warnStyle.Render("◆")
|
||||
case models.StatusStale:
|
||||
return m.st.staleStyle.Render("◆")
|
||||
case models.StatusPending:
|
||||
return m.st.subtleStyle.Render("○")
|
||||
default:
|
||||
return m.st.specialStyle.Render("▲")
|
||||
}
|
||||
}
|
||||
|
||||
func (m Model) fmtStatus(status models.Status, paused bool, inMaint bool) string {
|
||||
if paused {
|
||||
return m.st.warnStyle.Render("◇ PAUSED")
|
||||
|
||||
@@ -34,7 +34,7 @@ type siteFormData struct {
|
||||
type colKey int
|
||||
|
||||
const (
|
||||
colNum colKey = iota
|
||||
colDot colKey = iota
|
||||
colName
|
||||
colType
|
||||
colStatus
|
||||
@@ -55,7 +55,7 @@ type columnDef struct {
|
||||
}
|
||||
|
||||
var siteColumns = []columnDef{
|
||||
{colNum, "#", "#", 4, 4, 0},
|
||||
{colDot, "", "", 3, 3, 0},
|
||||
{colName, "NAME", "NAME", 0, 0, 0},
|
||||
{colType, "TYPE", "TYPE", 10, 8, mediumBreakpoint},
|
||||
{colStatus, "STATUS", "STATUS", 10, 10, 0},
|
||||
@@ -245,11 +245,12 @@ func (m Model) viewSitesTab() string {
|
||||
if site.Type == "group" {
|
||||
groupRows[i-start] = true
|
||||
icon := typeIcon("group", m.collapsed[site.ID])
|
||||
inMaint := m.isMonitorInMaintenance(site.ID)
|
||||
cells := map[colKey]string{
|
||||
colNum: strconv.Itoa(i + 1),
|
||||
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, m.isMonitorInMaintenance(site.ID)),
|
||||
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),
|
||||
@@ -293,11 +294,12 @@ func (m Model) viewSitesTab() string {
|
||||
spark = m.latencySparkline(hist.Latencies, hist.Statuses, sparkWidth, rowBg)
|
||||
}
|
||||
|
||||
inMaint := m.isMonitorInMaintenance(site.ID)
|
||||
cells := map[colKey]string{
|
||||
colNum: strconv.Itoa(i + 1),
|
||||
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, m.isMonitorInMaintenance(site.ID)),
|
||||
colStatus: m.fmtStatus(site.Status, site.Paused, inMaint),
|
||||
colLatency: m.fmtLatency(site.Latency),
|
||||
colUptime: m.fmtUptimeMaint(hist.Statuses, site.ID),
|
||||
colHistory: spark,
|
||||
|
||||
Reference in New Issue
Block a user