chore(tui): visual polish — detail sections, column headers, alert detail #37
@@ -57,7 +57,7 @@ func fmtMaintMonitorW(monitorID int, sites []models.Site, maxW int) string {
|
|||||||
return fmt.Sprintf("#%d", monitorID)
|
return fmt.Sprintf("#%d", monitorID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func fmtMaintTime(t time.Time) string {
|
func fmtMaintTime(t time.Time, colW int) string {
|
||||||
if t.IsZero() {
|
if t.IsZero() {
|
||||||
return subtleStyle.Render("—")
|
return subtleStyle.Render("—")
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,10 @@ func fmtMaintTime(t time.Time) string {
|
|||||||
if t.Year() == now.Year() && t.YearDay() == now.YearDay() {
|
if t.Year() == now.Year() && t.YearDay() == now.YearDay() {
|
||||||
return t.Format("15:04")
|
return t.Format("15:04")
|
||||||
}
|
}
|
||||||
|
if colW >= 14 {
|
||||||
return t.Format("15:04 Jan 02")
|
return t.Format("15:04 Jan 02")
|
||||||
|
}
|
||||||
|
return t.Format("Jan 02")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m Model) isMonitorInMaintenance(monitorID int) bool {
|
func (m Model) isMonitorInMaintenance(monitorID int) bool {
|
||||||
@@ -99,16 +102,17 @@ func (m Model) viewMaintTab() string {
|
|||||||
|
|
||||||
cols := []colDef{
|
cols := []colDef{
|
||||||
{"#", "#", 4, 4, false},
|
{"#", "#", 4, 4, false},
|
||||||
{"TITLE", "TITLE", 10, 28, true},
|
{"TITLE", "TITLE", 12, 24, false},
|
||||||
{"TYPE", "TYPE", 13, 14, false},
|
{"TYPE", "TYPE", 13, 14, false},
|
||||||
{"MON", "MONITORS", 10, 22, false},
|
{"MON", "MONITORS", 14, 22, true},
|
||||||
{"ST", "STATUS", 8, 12, false},
|
{"ST", "STATUS", 11, 12, false},
|
||||||
{"START", "STARTED", 8, 16, false},
|
{"START", "STARTED", 14, 16, false},
|
||||||
{"ENDS", "ENDS", 8, 16, false},
|
{"ENDS", "ENDS", 14, 16, false},
|
||||||
}
|
}
|
||||||
headers, widths := m.computeTableLayout(cols, 0)
|
headers, widths := m.computeTableLayout(cols, 0)
|
||||||
titleW := widths[1]
|
titleW := widths[1]
|
||||||
monW := widths[3]
|
monW := widths[3]
|
||||||
|
timeW := widths[5]
|
||||||
|
|
||||||
return m.renderTable(
|
return m.renderTable(
|
||||||
headers,
|
headers,
|
||||||
@@ -124,8 +128,8 @@ func (m Model) viewMaintTab() string {
|
|||||||
fmtMaintType(mw.Type),
|
fmtMaintType(mw.Type),
|
||||||
fmtMaintMonitorW(mw.MonitorID, allSites, monW-2),
|
fmtMaintMonitorW(mw.MonitorID, allSites, monW-2),
|
||||||
fmtMaintStatus(mw),
|
fmtMaintStatus(mw),
|
||||||
fmtMaintTime(mw.StartTime),
|
fmtMaintTime(mw.StartTime, timeW),
|
||||||
fmtMaintTime(mw.EndTime),
|
fmtMaintTime(mw.EndTime, timeW),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return rows
|
return rows
|
||||||
|
|||||||
Reference in New Issue
Block a user