pi-agent: Implement Operations Console dashboard
This commit is contained in:
+42
-29
@@ -11,16 +11,17 @@ import (
|
||||
)
|
||||
|
||||
type semanticTheme struct {
|
||||
title lipgloss.Style
|
||||
section lipgloss.Style
|
||||
selected lipgloss.Style
|
||||
status lipgloss.Style
|
||||
warning lipgloss.Style
|
||||
enabled lipgloss.Style
|
||||
disabled lipgloss.Style
|
||||
external lipgloss.Style
|
||||
drifted lipgloss.Style
|
||||
applying lipgloss.Style
|
||||
title lipgloss.Style
|
||||
section lipgloss.Style
|
||||
selected lipgloss.Style
|
||||
status lipgloss.Style
|
||||
warning lipgloss.Style
|
||||
enabled lipgloss.Style
|
||||
disabled lipgloss.Style
|
||||
external lipgloss.Style
|
||||
drifted lipgloss.Style
|
||||
unavailable lipgloss.Style
|
||||
applying lipgloss.Style
|
||||
}
|
||||
|
||||
func newSemanticTheme(mode themeMode, output io.Writer) semanticTheme {
|
||||
@@ -56,38 +57,50 @@ func newSemanticTheme(mode themeMode, output io.Writer) semanticTheme {
|
||||
}
|
||||
style := renderer.NewStyle
|
||||
return semanticTheme{
|
||||
title: style().Bold(true).Foreground(lipgloss.Color(accent)),
|
||||
section: style().Bold(true).Foreground(lipgloss.Color(foreground)),
|
||||
selected: style().Bold(true).Underline(true).Foreground(lipgloss.Color(accent)),
|
||||
status: style().Foreground(lipgloss.Color(foreground)),
|
||||
warning: style().Bold(true).Foreground(lipgloss.Color("172")),
|
||||
enabled: style().Foreground(lipgloss.Color("34")),
|
||||
disabled: style().Foreground(lipgloss.Color(subtle)),
|
||||
external: style().Foreground(lipgloss.Color("172")),
|
||||
drifted: style().Bold(true).Foreground(lipgloss.Color("160")),
|
||||
applying: style().Foreground(lipgloss.Color(accent)),
|
||||
title: style().Bold(true).Foreground(lipgloss.Color(accent)),
|
||||
section: style().Bold(true).Foreground(lipgloss.Color(foreground)),
|
||||
selected: style().Bold(true).Underline(true).Foreground(lipgloss.Color(accent)),
|
||||
status: style().Foreground(lipgloss.Color(foreground)),
|
||||
warning: style().Bold(true).Foreground(lipgloss.Color("172")),
|
||||
enabled: style().Foreground(lipgloss.Color("34")),
|
||||
disabled: style().Foreground(lipgloss.Color(subtle)),
|
||||
external: style().Foreground(lipgloss.Color("172")),
|
||||
drifted: style().Bold(true).Foreground(lipgloss.Color("160")),
|
||||
unavailable: style().Foreground(lipgloss.Color(subtle)),
|
||||
applying: style().Foreground(lipgloss.Color(accent)),
|
||||
}
|
||||
}
|
||||
|
||||
func (t semanticTheme) renderTargetState(state target.State, applying bool) string {
|
||||
if applying {
|
||||
return t.applying.Render("Applying…")
|
||||
return t.applying.Render("… Applying")
|
||||
}
|
||||
label := string(state)
|
||||
label := targetStateLabel(state)
|
||||
switch state {
|
||||
case target.Enabled:
|
||||
return t.enabled.Render(paddedState(label))
|
||||
return t.enabled.Render(label)
|
||||
case target.Disabled:
|
||||
return t.disabled.Render(paddedState(label))
|
||||
return t.disabled.Render(label)
|
||||
case target.External:
|
||||
return t.external.Render(paddedState(label))
|
||||
return t.external.Render(label)
|
||||
case target.Drifted:
|
||||
return t.drifted.Render(paddedState(label))
|
||||
return t.drifted.Render(label)
|
||||
default:
|
||||
return paddedState(label)
|
||||
return label
|
||||
}
|
||||
}
|
||||
|
||||
func paddedState(label string) string {
|
||||
return lipgloss.NewStyle().Width(9).Render(label)
|
||||
func targetStateLabel(state target.State) string {
|
||||
switch state {
|
||||
case target.Enabled:
|
||||
return "● Enabled"
|
||||
case target.Disabled:
|
||||
return "○ Disabled"
|
||||
case target.External:
|
||||
return "◇ External"
|
||||
case target.Drifted:
|
||||
return "! Drifted"
|
||||
default:
|
||||
return "? Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user