feat(tui): add state change history view with outage duration #55

Merged
lerko merged 5 commits from feat/state-history-view into main 2026-06-04 16:44:32 +00:00
2 changed files with 9 additions and 8 deletions
Showing only changes of commit 1d1f5d0ee4 - Show all commits
+7 -6
View File
@@ -138,9 +138,10 @@ func (m *Model) handleTick(t time.Time) (tea.Model, tea.Cmd) {
func (m *Model) handleMouse(msg tea.MouseMsg) (tea.Model, tea.Cmd) { func (m *Model) handleMouse(msg tea.MouseMsg) (tea.Model, tea.Cmd) {
if m.state == stateHistory { if m.state == stateHistory {
if msg.Button == tea.MouseButtonWheelUp { switch msg.Button {
case tea.MouseButtonWheelUp:
m.historyViewport.ScrollUp(3) m.historyViewport.ScrollUp(3)
} else if msg.Button == tea.MouseButtonWheelDown { case tea.MouseButtonWheelDown:
m.historyViewport.ScrollDown(3) m.historyViewport.ScrollDown(3)
} }
return m, nil return m, nil
@@ -266,13 +267,13 @@ func (m *Model) handleHistoryKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
case "q", "esc": case "q", "esc":
m.state = stateDetail m.state = stateDetail
case "up", "k": case "up", "k":
m.historyViewport.LineUp(1) m.historyViewport.ScrollUp(1)
case "down", "j": case "down", "j":
m.historyViewport.LineDown(1) m.historyViewport.ScrollDown(1)
case "pgup": case "pgup":
m.historyViewport.HalfViewUp() m.historyViewport.HalfPageUp()
case "pgdown": case "pgdown":
m.historyViewport.HalfViewDown() m.historyViewport.HalfPageDown()
case "home", "g": case "home", "g":
m.historyViewport.GotoTop() m.historyViewport.GotoTop()
case "end", "G": case "end", "G":
+2 -2
View File
@@ -160,11 +160,11 @@ func (m Model) viewHistoryPanel() string {
b.WriteString(" " + subtleStyle.Render(strings.Repeat("─", divWidth)) + "\n") b.WriteString(" " + subtleStyle.Render(strings.Repeat("─", divWidth)) + "\n")
} }
b.WriteString(fmt.Sprintf(" %-18s %-17s %-12s %s\n", fmt.Fprintf(&b, " %-18s %-17s %-12s %s\n",
subtleStyle.Render("TIME"), subtleStyle.Render("TIME"),
subtleStyle.Render("TRANSITION"), subtleStyle.Render("TRANSITION"),
subtleStyle.Render("DURATION"), subtleStyle.Render("DURATION"),
subtleStyle.Render("REASON"))) subtleStyle.Render("REASON"))
if len(m.historyChanges) == 0 { if len(m.historyChanges) == 0 {
b.WriteString("\n " + subtleStyle.Render("No state changes recorded") + "\n") b.WriteString("\n " + subtleStyle.Render("No state changes recorded") + "\n")