fix(tui): quick wins — version, columns, zebra, sparkline #60
+2
-2
@@ -413,7 +413,7 @@ func runServe(args []string) {
|
|||||||
sshSrv := startSSHServer(*port, s, eng, kc)
|
sshSrv := startSSHServer(*port, s, eng, kc)
|
||||||
|
|
||||||
if isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd()) {
|
if isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd()) {
|
||||||
p := tea.NewProgram(tui.InitialModel(true, s, eng), tea.WithAltScreen(), tea.WithMouseCellMotion())
|
p := tea.NewProgram(tui.InitialModel(true, s, eng, version), tea.WithAltScreen(), tea.WithMouseCellMotion())
|
||||||
if _, err := p.Run(); err != nil {
|
if _, err := p.Run(); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||||
}
|
}
|
||||||
@@ -449,7 +449,7 @@ func startSSHServer(port int, db store.Store, eng *monitor.Engine, kc *keyCache)
|
|||||||
}),
|
}),
|
||||||
wish.WithMiddleware(
|
wish.WithMiddleware(
|
||||||
bm.Middleware(func(s ssh.Session) (tea.Model, []tea.ProgramOption) {
|
bm.Middleware(func(s ssh.Session) (tea.Model, []tea.ProgramOption) {
|
||||||
return tui.InitialModel(false, db, eng), []tea.ProgramOption{tea.WithAltScreen(), tea.WithMouseCellMotion()}
|
return tui.InitialModel(false, db, eng, version), []tea.ProgramOption{tea.WithAltScreen(), tea.WithMouseCellMotion()}
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -131,9 +131,9 @@ func (m Model) groupSparkline(groupID int, width int) string {
|
|||||||
}
|
}
|
||||||
for _, up := range aggregated {
|
for _, up := range aggregated {
|
||||||
if up {
|
if up {
|
||||||
sb.WriteString(specialStyle.Render("●"))
|
sb.WriteString(specialStyle.Render("•"))
|
||||||
} else {
|
} else {
|
||||||
sb.WriteString(dangerStyle.Render("●"))
|
sb.WriteString(dangerStyle.Render("•"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sb.String()
|
return sb.String()
|
||||||
|
|||||||
@@ -78,13 +78,13 @@ func (m Model) computeLayout() tableLayout {
|
|||||||
if nameW < 13 {
|
if nameW < 13 {
|
||||||
nameW = 13
|
nameW = 13
|
||||||
}
|
}
|
||||||
if nameW > 40 {
|
if nameW > 35 {
|
||||||
nameW = 40
|
nameW = 35
|
||||||
}
|
}
|
||||||
|
|
||||||
sparkW := avail - nameW
|
sparkW := avail - nameW
|
||||||
if sparkW < 10 {
|
if sparkW < 15 {
|
||||||
sparkW = 10
|
sparkW = 15
|
||||||
}
|
}
|
||||||
|
|
||||||
widths[1] = nameW
|
widths[1] = nameW
|
||||||
|
|||||||
@@ -66,6 +66,9 @@ func (m Model) renderTable(headers []string, items int, buildRows func(start, en
|
|||||||
if styleOverride != nil {
|
if styleOverride != nil {
|
||||||
if s := styleOverride(row, col); s != nil {
|
if s := styleOverride(row, col); s != nil {
|
||||||
style := *s
|
style := *s
|
||||||
|
if row%2 == 1 {
|
||||||
|
style = style.Background(tableZebraStyle.GetBackground())
|
||||||
|
}
|
||||||
if isSelected {
|
if isSelected {
|
||||||
style = tableSelectedStyle.Foreground(s.GetForeground())
|
style = tableSelectedStyle.Foreground(s.GetForeground())
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -138,9 +138,10 @@ type Model struct {
|
|||||||
// demoMode renders a stable status dot instead of the animated pulse so
|
// demoMode renders a stable status dot instead of the animated pulse so
|
||||||
// screenshots/recordings don't capture the spinner mid-frame. Set via UPTOP_DEMO=1.
|
// screenshots/recordings don't capture the spinner mid-frame. Set via UPTOP_DEMO=1.
|
||||||
demoMode bool
|
demoMode bool
|
||||||
|
version string
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitialModel(isAdmin bool, s store.Store, eng *monitor.Engine) Model {
|
func InitialModel(isAdmin bool, s store.Store, eng *monitor.Engine, version string) Model {
|
||||||
vpLogs := viewport.New(100, 20)
|
vpLogs := viewport.New(100, 20)
|
||||||
vpLogs.SetContent("Waiting for logs...")
|
vpLogs.SetContent("Waiting for logs...")
|
||||||
z := zone.New()
|
z := zone.New()
|
||||||
@@ -172,6 +173,7 @@ func InitialModel(isAdmin bool, s store.Store, eng *monitor.Engine) Model {
|
|||||||
theme: theme,
|
theme: theme,
|
||||||
themeIndex: themeIdx,
|
themeIndex: themeIdx,
|
||||||
demoMode: os.Getenv("UPTOP_DEMO") == "1",
|
demoMode: os.Getenv("UPTOP_DEMO") == "1",
|
||||||
|
version: version,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -275,9 +275,10 @@ func (m Model) renderFooter(stats dashboardStats) string {
|
|||||||
keys = "[T]Theme [Tab]Switch [q]Quit"
|
keys = "[T]Theme [Tab]Switch [q]Quit"
|
||||||
}
|
}
|
||||||
|
|
||||||
footer := "\n" + statusLine + " " + subtleStyle.Render(keys)
|
ver := subtleStyle.Render("v" + m.version)
|
||||||
|
footer := "\n" + statusLine + " " + subtleStyle.Render(keys) + " " + ver
|
||||||
if m.filterText != "" && m.currentTab == 0 {
|
if m.filterText != "" && m.currentTab == 0 {
|
||||||
footer = "\n" + subtleStyle.Render(fmt.Sprintf("filter: %s", m.filterText)) + " " + statusLine + " " + subtleStyle.Render(keys)
|
footer = "\n" + subtleStyle.Render(fmt.Sprintf("filter: %s", m.filterText)) + " " + statusLine + " " + subtleStyle.Render(keys) + " " + ver
|
||||||
}
|
}
|
||||||
return footer
|
return footer
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user