feat(tui): add type icons to sites table #12
@@ -15,6 +15,28 @@ import (
|
|||||||
|
|
||||||
var sparkChars = []rune{'▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'}
|
var sparkChars = []rune{'▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'}
|
||||||
|
|
||||||
|
func typeIcon(siteType string, collapsed bool) string {
|
||||||
|
switch siteType {
|
||||||
|
case "http":
|
||||||
|
return "→"
|
||||||
|
case "push":
|
||||||
|
return "↓"
|
||||||
|
case "ping":
|
||||||
|
return "↔"
|
||||||
|
case "port":
|
||||||
|
return "⊡"
|
||||||
|
case "dns":
|
||||||
|
return "◆"
|
||||||
|
case "group":
|
||||||
|
if collapsed {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
default:
|
||||||
|
return "·"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var siteGroupStyle = lipgloss.NewStyle().
|
var siteGroupStyle = lipgloss.NewStyle().
|
||||||
Padding(0, 1).
|
Padding(0, 1).
|
||||||
Bold(true).
|
Bold(true).
|
||||||
@@ -247,13 +269,10 @@ func (m Model) viewSitesTab() string {
|
|||||||
|
|
||||||
if site.Type == "group" {
|
if site.Type == "group" {
|
||||||
groupRows[i-start] = true
|
groupRows[i-start] = true
|
||||||
arrow := "▾"
|
icon := typeIcon("group", m.collapsed[site.ID])
|
||||||
if m.collapsed[site.ID] {
|
|
||||||
arrow = "▸"
|
|
||||||
}
|
|
||||||
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, nameW-2)),
|
m.zones.Mark(fmt.Sprintf("site-%d", i), icon+" "+limitStr(site.Name, nameW-2)),
|
||||||
"group",
|
"group",
|
||||||
fmtStatus(site.Status, site.Paused),
|
fmtStatus(site.Status, site.Paused),
|
||||||
subtleStyle.Render("—"),
|
subtleStyle.Render("—"),
|
||||||
@@ -287,7 +306,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), name),
|
m.zones.Mark(fmt.Sprintf("site-%d", i), name),
|
||||||
site.Type,
|
typeIcon(site.Type, false) + " " + site.Type,
|
||||||
fmtStatus(site.Status, site.Paused),
|
fmtStatus(site.Status, site.Paused),
|
||||||
fmtLatency(site.Latency),
|
fmtLatency(site.Latency),
|
||||||
fmtUptime(hist.TotalChecks, hist.UpChecks),
|
fmtUptime(hist.TotalChecks, hist.UpChecks),
|
||||||
|
|||||||
Reference in New Issue
Block a user