feat(tui): polish pass — status bar, badges, detail panel, modals #10
@@ -195,11 +195,31 @@ func fmtStatus(status string, paused bool) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m Model) nameWidth() int {
|
||||||
|
w := m.termWidth - 105
|
||||||
|
if w < 13 {
|
||||||
|
w = 13
|
||||||
|
}
|
||||||
|
if w > 40 {
|
||||||
|
w = 40
|
||||||
|
}
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
|
||||||
func (m Model) viewSitesTab() string {
|
func (m Model) viewSitesTab() string {
|
||||||
const sparkWidth = 20
|
const sparkWidth = 20
|
||||||
|
|
||||||
if len(m.sites) == 0 {
|
if len(m.sites) == 0 {
|
||||||
return "\n No sites configured. Press [n] to add one."
|
welcome := lipgloss.NewStyle().
|
||||||
|
Border(lipgloss.RoundedBorder()).
|
||||||
|
BorderForeground(lipgloss.Color("#7D56F4")).
|
||||||
|
Padding(1, 3).
|
||||||
|
Render(
|
||||||
|
titleStyle.Render("Go-Upkeep") + "\n\n" +
|
||||||
|
"No monitors configured yet.\n\n" +
|
||||||
|
subtleStyle.Render("[n] Add your first monitor"),
|
||||||
|
)
|
||||||
|
return "\n" + welcome
|
||||||
}
|
}
|
||||||
|
|
||||||
colWidths := []int{6, 0, 10, 10, 8, 8, sparkWidth + 4, 7, 9}
|
colWidths := []int{6, 0, 10, 10, 8, 8, sparkWidth + 4, 7, 9}
|
||||||
@@ -222,7 +242,7 @@ func (m Model) viewSitesTab() string {
|
|||||||
}
|
}
|
||||||
rows = append(rows, []string{
|
rows = append(rows, []string{
|
||||||
strconv.Itoa(i + 1),
|
strconv.Itoa(i + 1),
|
||||||
m.zones.Mark(fmt.Sprintf("site-%d", i), arrow+" "+limitStr(site.Name, 11)),
|
m.zones.Mark(fmt.Sprintf("site-%d", i), arrow+" "+limitStr(site.Name, m.nameWidth()-2)),
|
||||||
"group",
|
"group",
|
||||||
fmtStatus(site.Status, site.Paused),
|
fmtStatus(site.Status, site.Paused),
|
||||||
subtleStyle.Render("—"),
|
subtleStyle.Render("—"),
|
||||||
@@ -240,9 +260,9 @@ func (m Model) viewSitesTab() string {
|
|||||||
if i+1 >= len(m.sites) || m.sites[i+1].ParentID != site.ParentID {
|
if i+1 >= len(m.sites) || m.sites[i+1].ParentID != site.ParentID {
|
||||||
prefix = "└"
|
prefix = "└"
|
||||||
}
|
}
|
||||||
name = prefix + " " + limitStr(name, 11)
|
name = prefix + " " + limitStr(name, m.nameWidth()-2)
|
||||||
} else {
|
} else {
|
||||||
name = limitStr(name, 13)
|
name = limitStr(name, m.nameWidth())
|
||||||
}
|
}
|
||||||
|
|
||||||
hist, _ := m.engine.GetHistory(site.ID)
|
hist, _ := m.engine.GetHistory(site.ID)
|
||||||
|
|||||||
+6
-1
@@ -551,7 +551,12 @@ func (m Model) View() string {
|
|||||||
}
|
}
|
||||||
msg := dangerStyle.Render(fmt.Sprintf("Delete %s \"%s\"?", kind, m.deleteName))
|
msg := dangerStyle.Render(fmt.Sprintf("Delete %s \"%s\"?", kind, m.deleteName))
|
||||||
hint := subtleStyle.Render("[y] Confirm [n] Cancel")
|
hint := subtleStyle.Render("[y] Confirm [n] Cancel")
|
||||||
return lipgloss.NewStyle().Padding(2, 4).Render(msg + "\n\n" + hint)
|
box := lipgloss.NewStyle().
|
||||||
|
Border(lipgloss.RoundedBorder()).
|
||||||
|
BorderForeground(lipgloss.Color("#F25D94")).
|
||||||
|
Padding(1, 3).
|
||||||
|
Render(msg + "\n\n" + hint)
|
||||||
|
return lipgloss.NewStyle().Padding(2, 4).Render(box)
|
||||||
case stateFormSite, stateFormAlert, stateFormUser:
|
case stateFormSite, stateFormAlert, stateFormUser:
|
||||||
if m.huhForm != nil {
|
if m.huhForm != nil {
|
||||||
title := ""
|
title := ""
|
||||||
|
|||||||
Reference in New Issue
Block a user