Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
3480679176
|
@@ -110,24 +110,6 @@ func gotifyPayload(priority string) PayloadFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func opsgeniePayload(priority string) PayloadFunc {
|
|
||||||
return func(title, message string) ([]byte, error) {
|
|
||||||
return json.Marshal(map[string]any{
|
|
||||||
"message": limitMessage(title, 130),
|
|
||||||
"description": message,
|
|
||||||
"source": "uptop",
|
|
||||||
"priority": priority,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func limitMessage(s string, max int) string {
|
|
||||||
if len(s) <= max {
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
return s[:max]
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetProvider(cfg models.AlertConfig) Provider {
|
func GetProvider(cfg models.AlertConfig) Provider {
|
||||||
switch cfg.Type {
|
switch cfg.Type {
|
||||||
case "discord":
|
case "discord":
|
||||||
@@ -191,20 +173,6 @@ func GetProvider(cfg models.AlertConfig) Provider {
|
|||||||
Payload: gotifyPayload(priority),
|
Payload: gotifyPayload(priority),
|
||||||
Headers: map[string]string{"X-Gotify-Key": cfg.Settings["token"]},
|
Headers: map[string]string{"X-Gotify-Key": cfg.Settings["token"]},
|
||||||
}
|
}
|
||||||
case "opsgenie":
|
|
||||||
priority := "P3"
|
|
||||||
if p, ok := cfg.Settings["priority"]; ok && p != "" {
|
|
||||||
priority = p
|
|
||||||
}
|
|
||||||
apiURL := "https://api.opsgenie.com/v2/alerts"
|
|
||||||
if eu, ok := cfg.Settings["eu"]; ok && eu == "true" {
|
|
||||||
apiURL = "https://api.eu.opsgenie.com/v2/alerts"
|
|
||||||
}
|
|
||||||
return &HTTPProvider{
|
|
||||||
URL: apiURL,
|
|
||||||
Payload: opsgeniePayload(priority),
|
|
||||||
Headers: map[string]string{"Authorization": "GenieKey " + cfg.Settings["api_key"]},
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,76 +196,8 @@ func TestHTTPProviderGotify(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHTTPProviderOpsgenie(t *testing.T) {
|
|
||||||
var received map[string]any
|
|
||||||
var authHeader string
|
|
||||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
authHeader = r.Header.Get("Authorization")
|
|
||||||
json.NewDecoder(r.Body).Decode(&received)
|
|
||||||
w.WriteHeader(202)
|
|
||||||
}))
|
|
||||||
defer srv.Close()
|
|
||||||
|
|
||||||
p := GetProvider(models.AlertConfig{Type: "opsgenie", Settings: map[string]string{
|
|
||||||
"api_key": "test-genie-key",
|
|
||||||
"priority": "P1",
|
|
||||||
}})
|
|
||||||
hp := p.(*HTTPProvider)
|
|
||||||
hp.URL = srv.URL
|
|
||||||
|
|
||||||
if err := p.Send(context.Background(), "Site Down", "mysite.com is unreachable"); err != nil {
|
|
||||||
t.Fatalf("Send: %v", err)
|
|
||||||
}
|
|
||||||
if authHeader != "GenieKey test-genie-key" {
|
|
||||||
t.Errorf("expected auth 'GenieKey test-genie-key', got '%s'", authHeader)
|
|
||||||
}
|
|
||||||
if received["message"] != "Site Down" {
|
|
||||||
t.Errorf("unexpected message: %v", received["message"])
|
|
||||||
}
|
|
||||||
if received["description"] != "mysite.com is unreachable" {
|
|
||||||
t.Errorf("unexpected description: %v", received["description"])
|
|
||||||
}
|
|
||||||
if received["source"] != "uptop" {
|
|
||||||
t.Errorf("expected source 'uptop', got '%v'", received["source"])
|
|
||||||
}
|
|
||||||
if received["priority"] != "P1" {
|
|
||||||
t.Errorf("expected priority 'P1', got '%v'", received["priority"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestOpsgenieEUEndpoint(t *testing.T) {
|
|
||||||
p := GetProvider(models.AlertConfig{Type: "opsgenie", Settings: map[string]string{
|
|
||||||
"api_key": "key", "eu": "true",
|
|
||||||
}})
|
|
||||||
hp := p.(*HTTPProvider)
|
|
||||||
if hp.URL != "https://api.eu.opsgenie.com/v2/alerts" {
|
|
||||||
t.Errorf("expected EU URL, got '%s'", hp.URL)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestOpsgenieUSEndpoint(t *testing.T) {
|
|
||||||
p := GetProvider(models.AlertConfig{Type: "opsgenie", Settings: map[string]string{
|
|
||||||
"api_key": "key",
|
|
||||||
}})
|
|
||||||
hp := p.(*HTTPProvider)
|
|
||||||
if hp.URL != "https://api.opsgenie.com/v2/alerts" {
|
|
||||||
t.Errorf("expected US URL, got '%s'", hp.URL)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestLimitMessage(t *testing.T) {
|
|
||||||
short := "short"
|
|
||||||
if got := limitMessage(short, 130); got != short {
|
|
||||||
t.Errorf("expected '%s', got '%s'", short, got)
|
|
||||||
}
|
|
||||||
long := string(make([]byte, 200))
|
|
||||||
if got := limitMessage(long, 130); len(got) != 130 {
|
|
||||||
t.Errorf("expected length 130, got %d", len(got))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetProviderNewTypes(t *testing.T) {
|
func TestGetProviderNewTypes(t *testing.T) {
|
||||||
for _, typ := range []string{"telegram", "pagerduty", "pushover", "gotify", "opsgenie"} {
|
for _, typ := range []string{"telegram", "pagerduty", "pushover", "gotify"} {
|
||||||
p := GetProvider(models.AlertConfig{Type: typ, Settings: map[string]string{
|
p := GetProvider(models.AlertConfig{Type: typ, Settings: map[string]string{
|
||||||
"token": "x", "chat_id": "1", "routing_key": "k", "user": "u", "url": "http://localhost",
|
"token": "x", "chat_id": "1", "routing_key": "k", "user": "u", "url": "http://localhost",
|
||||||
}})
|
}})
|
||||||
|
|||||||
@@ -509,7 +509,6 @@ func (e *Engine) checkPush(site models.Site) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
overdue := site.LastCheck.Add(interval)
|
overdue := site.LastCheck.Add(interval)
|
||||||
staleMark := overdue.Add(grace / 2)
|
|
||||||
graceEnd := overdue.Add(grace)
|
graceEnd := overdue.Add(grace)
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
@@ -517,10 +516,6 @@ func (e *Engine) checkPush(site models.Site) {
|
|||||||
if site.Status != "DOWN" {
|
if site.Status != "DOWN" {
|
||||||
e.handleStatusChange(site, "DOWN", 0, 0, "heartbeat missed")
|
e.handleStatusChange(site, "DOWN", 0, 0, "heartbeat missed")
|
||||||
}
|
}
|
||||||
} else if now.After(staleMark) {
|
|
||||||
if site.Status != "STALE" {
|
|
||||||
e.handleStatusChange(site, "STALE", 0, 0, "heartbeat stale")
|
|
||||||
}
|
|
||||||
} else if now.After(overdue) {
|
} else if now.After(overdue) {
|
||||||
if site.Status != "LATE" {
|
if site.Status != "LATE" {
|
||||||
e.handleStatusChange(site, "LATE", 0, 0, "heartbeat overdue")
|
e.handleStatusChange(site, "LATE", 0, 0, "heartbeat overdue")
|
||||||
@@ -748,11 +743,7 @@ func (e *Engine) checkGroup(site models.Site) {
|
|||||||
}
|
}
|
||||||
if child.Status == "DOWN" || child.Status == "SSL EXP" {
|
if child.Status == "DOWN" || child.Status == "SSL EXP" {
|
||||||
status = "DOWN"
|
status = "DOWN"
|
||||||
} else if child.Status == "STALE" && status != "DOWN" {
|
} else if child.Status == "PENDING" && status != "DOWN" {
|
||||||
status = "STALE"
|
|
||||||
} else if child.Status == "LATE" && status != "DOWN" && status != "STALE" {
|
|
||||||
status = "LATE"
|
|
||||||
} else if child.Status == "PENDING" && status != "DOWN" && status != "STALE" && status != "LATE" {
|
|
||||||
status = "PENDING"
|
status = "PENDING"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -574,26 +574,6 @@ func TestCheckPush_OverdueBecomesLate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCheckPush_OverdueBecomesStale(t *testing.T) {
|
|
||||||
ms := newMockStore()
|
|
||||||
e := newTestEngine(ms)
|
|
||||||
// interval=300, grace=150 (300/2), staleMark=overdue+75
|
|
||||||
// at 380s: past staleMark(375) but before graceEnd(450)
|
|
||||||
site := models.Site{
|
|
||||||
ID: 1, Name: "push", Type: "push", Status: "UP",
|
|
||||||
Interval: 300,
|
|
||||||
LastCheck: time.Now().Add(-380 * time.Second),
|
|
||||||
}
|
|
||||||
injectSite(e, site)
|
|
||||||
|
|
||||||
e.checkPush(site)
|
|
||||||
|
|
||||||
s, _ := getSite(e, 1)
|
|
||||||
if s.Status != "STALE" {
|
|
||||||
t.Errorf("expected STALE when past midpoint of grace, got %s", s.Status)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCheckPush_WithinDeadline(t *testing.T) {
|
func TestCheckPush_WithinDeadline(t *testing.T) {
|
||||||
ms := newMockStore()
|
ms := newMockStore()
|
||||||
e := newTestEngine(ms)
|
e := newTestEngine(ms)
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ func siteOrder(s models.Site) int {
|
|||||||
switch s.Status {
|
switch s.Status {
|
||||||
case "DOWN", "SSL EXP":
|
case "DOWN", "SSL EXP":
|
||||||
return 0
|
return 0
|
||||||
case "STALE":
|
|
||||||
return 1
|
|
||||||
case "LATE":
|
case "LATE":
|
||||||
return 1
|
return 1
|
||||||
case "PENDING":
|
case "PENDING":
|
||||||
@@ -144,8 +142,6 @@ func fmtStatus(status string, paused bool, inMaint bool, errCategory ErrorCatego
|
|||||||
return dangerStyle.Render(status)
|
return dangerStyle.Render(status)
|
||||||
case "LATE":
|
case "LATE":
|
||||||
return warnStyle.Render(status)
|
return warnStyle.Render(status)
|
||||||
case "STALE":
|
|
||||||
return staleStyle.Render(status)
|
|
||||||
case "PENDING":
|
case "PENDING":
|
||||||
return subtleStyle.Render(status)
|
return subtleStyle.Render(status)
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -39,10 +39,6 @@ type alertFormData struct {
|
|||||||
GotifyURL string
|
GotifyURL string
|
||||||
GotifyToken string
|
GotifyToken string
|
||||||
GotifyPriority string
|
GotifyPriority string
|
||||||
// Opsgenie
|
|
||||||
OpsgenieAPIKey string
|
|
||||||
OpsgeniePriority string
|
|
||||||
OpsgenieEU bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func fmtAlertType(t string) string {
|
func fmtAlertType(t string) string {
|
||||||
@@ -65,8 +61,6 @@ func fmtAlertType(t string) string {
|
|||||||
return lipgloss.NewStyle().Foreground(lipgloss.Color("#249DF1")).Render(t)
|
return lipgloss.NewStyle().Foreground(lipgloss.Color("#249DF1")).Render(t)
|
||||||
case "gotify":
|
case "gotify":
|
||||||
return lipgloss.NewStyle().Foreground(lipgloss.Color("#3F8BBA")).Render(t)
|
return lipgloss.NewStyle().Foreground(lipgloss.Color("#3F8BBA")).Render(t)
|
||||||
case "opsgenie":
|
|
||||||
return lipgloss.NewStyle().Foreground(lipgloss.Color("#2684FF")).Render(t)
|
|
||||||
default:
|
default:
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
@@ -114,19 +108,6 @@ func fmtAlertConfig(alert struct {
|
|||||||
return limitStr(url, 34)
|
return limitStr(url, 34)
|
||||||
}
|
}
|
||||||
return subtleStyle.Render("—")
|
return subtleStyle.Render("—")
|
||||||
case "opsgenie":
|
|
||||||
key := alert.Settings["api_key"]
|
|
||||||
if key != "" {
|
|
||||||
masked := key
|
|
||||||
if len(masked) > 8 {
|
|
||||||
masked = masked[:4] + "…" + masked[len(masked)-4:]
|
|
||||||
}
|
|
||||||
if alert.Settings["eu"] == "true" {
|
|
||||||
return limitStr(fmt.Sprintf("EU %s", masked), 34)
|
|
||||||
}
|
|
||||||
return limitStr(masked, 34)
|
|
||||||
}
|
|
||||||
return subtleStyle.Render("—")
|
|
||||||
default:
|
default:
|
||||||
if val, ok := alert.Settings["url"]; ok {
|
if val, ok := alert.Settings["url"]; ok {
|
||||||
return limitStr(val, 34)
|
return limitStr(val, 34)
|
||||||
@@ -257,7 +238,6 @@ func (m *Model) initAlertHuhForm() tea.Cmd {
|
|||||||
NtfyPri: "3",
|
NtfyPri: "3",
|
||||||
PagerDutySeverity: "critical",
|
PagerDutySeverity: "critical",
|
||||||
GotifyPriority: "5",
|
GotifyPriority: "5",
|
||||||
OpsgeniePriority: "P3",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.editID > 0 {
|
if m.editID > 0 {
|
||||||
@@ -295,10 +275,6 @@ func (m *Model) initAlertHuhForm() tea.Cmd {
|
|||||||
m.alertFormData.GotifyURL = alert.Settings["url"]
|
m.alertFormData.GotifyURL = alert.Settings["url"]
|
||||||
m.alertFormData.GotifyToken = alert.Settings["token"]
|
m.alertFormData.GotifyToken = alert.Settings["token"]
|
||||||
m.alertFormData.GotifyPriority = alert.Settings["priority"]
|
m.alertFormData.GotifyPriority = alert.Settings["priority"]
|
||||||
case "opsgenie":
|
|
||||||
m.alertFormData.OpsgenieAPIKey = alert.Settings["api_key"]
|
|
||||||
m.alertFormData.OpsgeniePriority = alert.Settings["priority"]
|
|
||||||
m.alertFormData.OpsgenieEU = alert.Settings["eu"] == "true"
|
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -327,7 +303,6 @@ func (m *Model) initAlertHuhForm() tea.Cmd {
|
|||||||
huh.NewOption("PagerDuty", "pagerduty"),
|
huh.NewOption("PagerDuty", "pagerduty"),
|
||||||
huh.NewOption("Pushover", "pushover"),
|
huh.NewOption("Pushover", "pushover"),
|
||||||
huh.NewOption("Gotify", "gotify"),
|
huh.NewOption("Gotify", "gotify"),
|
||||||
huh.NewOption("Opsgenie", "opsgenie"),
|
|
||||||
).Value(&m.alertFormData.AlertType),
|
).Value(&m.alertFormData.AlertType),
|
||||||
).Title("Alert Config"),
|
).Title("Alert Config"),
|
||||||
huh.NewGroup(
|
huh.NewGroup(
|
||||||
@@ -435,23 +410,6 @@ func (m *Model) initAlertHuhForm() tea.Cmd {
|
|||||||
).Title("Gotify Settings").WithHideFunc(func() bool {
|
).Title("Gotify Settings").WithHideFunc(func() bool {
|
||||||
return m.alertFormData.AlertType != "gotify"
|
return m.alertFormData.AlertType != "gotify"
|
||||||
}),
|
}),
|
||||||
huh.NewGroup(
|
|
||||||
huh.NewInput().Title("API Key").
|
|
||||||
Placeholder("your-opsgenie-api-key").
|
|
||||||
Value(&m.alertFormData.OpsgenieAPIKey),
|
|
||||||
huh.NewSelect[string]().Title("Priority").
|
|
||||||
Options(
|
|
||||||
huh.NewOption("Critical (P1)", "P1"),
|
|
||||||
huh.NewOption("High (P2)", "P2"),
|
|
||||||
huh.NewOption("Moderate (P3)", "P3"),
|
|
||||||
huh.NewOption("Low (P4)", "P4"),
|
|
||||||
huh.NewOption("Informational (P5)", "P5"),
|
|
||||||
).Value(&m.alertFormData.OpsgeniePriority),
|
|
||||||
huh.NewConfirm().Title("EU Instance?").
|
|
||||||
Value(&m.alertFormData.OpsgenieEU),
|
|
||||||
).Title("Opsgenie Settings").WithHideFunc(func() bool {
|
|
||||||
return m.alertFormData.AlertType != "opsgenie"
|
|
||||||
}),
|
|
||||||
).WithTheme(m.theme.HuhTheme())
|
).WithTheme(m.theme.HuhTheme())
|
||||||
|
|
||||||
return m.huhForm.Init()
|
return m.huhForm.Init()
|
||||||
@@ -488,12 +446,6 @@ func (m *Model) submitAlertForm() {
|
|||||||
settings["url"] = d.GotifyURL
|
settings["url"] = d.GotifyURL
|
||||||
settings["token"] = d.GotifyToken
|
settings["token"] = d.GotifyToken
|
||||||
settings["priority"] = d.GotifyPriority
|
settings["priority"] = d.GotifyPriority
|
||||||
case "opsgenie":
|
|
||||||
settings["api_key"] = d.OpsgenieAPIKey
|
|
||||||
settings["priority"] = d.OpsgeniePriority
|
|
||||||
if d.OpsgenieEU {
|
|
||||||
settings["eu"] = "true"
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
settings["url"] = d.WebhookURL
|
settings["url"] = d.WebhookURL
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ func (m Model) viewSitesTab() string {
|
|||||||
name = limitStr(name, nameW-2)
|
name = limitStr(name, nameW-2)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (site.Status == "DOWN" || site.Status == "SSL EXP" || site.Status == "LATE" || site.Status == "STALE") && site.LastError != "" {
|
if (site.Status == "DOWN" || site.Status == "SSL EXP" || site.Status == "LATE") && site.LastError != "" {
|
||||||
nameLen := len([]rune(name))
|
nameLen := len([]rune(name))
|
||||||
errSpace := nameW - nameLen - 3
|
errSpace := nameW - nameLen - 3
|
||||||
if errSpace > 10 {
|
if errSpace > 10 {
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ type Theme struct {
|
|||||||
// Semantic
|
// Semantic
|
||||||
Success lipgloss.Color
|
Success lipgloss.Color
|
||||||
Warning lipgloss.Color
|
Warning lipgloss.Color
|
||||||
Stale lipgloss.Color
|
|
||||||
Danger lipgloss.Color
|
Danger lipgloss.Color
|
||||||
Info lipgloss.Color
|
Info lipgloss.Color
|
||||||
Accent lipgloss.Color
|
Accent lipgloss.Color
|
||||||
@@ -55,7 +54,6 @@ var themeFlexokiDark = Theme{
|
|||||||
Subtle: "#6F6E69",
|
Subtle: "#6F6E69",
|
||||||
Success: "#879A39",
|
Success: "#879A39",
|
||||||
Warning: "#D0A215",
|
Warning: "#D0A215",
|
||||||
Stale: "#DA702C",
|
|
||||||
Danger: "#D14D41",
|
Danger: "#D14D41",
|
||||||
Info: "#4385BE",
|
Info: "#4385BE",
|
||||||
Accent: "#3AA99F",
|
Accent: "#3AA99F",
|
||||||
@@ -76,7 +74,6 @@ var themeTokyoNight = Theme{
|
|||||||
Subtle: "#565f89",
|
Subtle: "#565f89",
|
||||||
Success: "#9ece6a",
|
Success: "#9ece6a",
|
||||||
Warning: "#e0af68",
|
Warning: "#e0af68",
|
||||||
Stale: "#ff9e64",
|
|
||||||
Danger: "#f7768e",
|
Danger: "#f7768e",
|
||||||
Info: "#7aa2f7",
|
Info: "#7aa2f7",
|
||||||
Accent: "#7dcfff",
|
Accent: "#7dcfff",
|
||||||
@@ -97,7 +94,6 @@ var themeGruvbox = Theme{
|
|||||||
Subtle: "#7c6f64",
|
Subtle: "#7c6f64",
|
||||||
Success: "#b8bb26",
|
Success: "#b8bb26",
|
||||||
Warning: "#fabd2f",
|
Warning: "#fabd2f",
|
||||||
Stale: "#fe8019",
|
|
||||||
Danger: "#fb4934",
|
Danger: "#fb4934",
|
||||||
Info: "#83a598",
|
Info: "#83a598",
|
||||||
Accent: "#8ec07c",
|
Accent: "#8ec07c",
|
||||||
@@ -118,7 +114,6 @@ var themeCatppuccinMocha = Theme{
|
|||||||
Subtle: "#6c7086",
|
Subtle: "#6c7086",
|
||||||
Success: "#a6e3a1",
|
Success: "#a6e3a1",
|
||||||
Warning: "#f9e2af",
|
Warning: "#f9e2af",
|
||||||
Stale: "#fab387",
|
|
||||||
Danger: "#f38ba8",
|
Danger: "#f38ba8",
|
||||||
Info: "#89b4fa",
|
Info: "#89b4fa",
|
||||||
Accent: "#94e2d5",
|
Accent: "#94e2d5",
|
||||||
@@ -139,7 +134,6 @@ var themeNord = Theme{
|
|||||||
Subtle: "#4c566a",
|
Subtle: "#4c566a",
|
||||||
Success: "#a3be8c",
|
Success: "#a3be8c",
|
||||||
Warning: "#ebcb8b",
|
Warning: "#ebcb8b",
|
||||||
Stale: "#d08770",
|
|
||||||
Danger: "#bf616a",
|
Danger: "#bf616a",
|
||||||
Info: "#81a1c1",
|
Info: "#81a1c1",
|
||||||
Accent: "#88c0d0",
|
Accent: "#88c0d0",
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ var (
|
|||||||
subtleStyle lipgloss.Style
|
subtleStyle lipgloss.Style
|
||||||
specialStyle lipgloss.Style
|
specialStyle lipgloss.Style
|
||||||
warnStyle lipgloss.Style
|
warnStyle lipgloss.Style
|
||||||
staleStyle lipgloss.Style
|
|
||||||
dangerStyle lipgloss.Style
|
dangerStyle lipgloss.Style
|
||||||
titleStyle lipgloss.Style
|
titleStyle lipgloss.Style
|
||||||
activeTab lipgloss.Style
|
activeTab lipgloss.Style
|
||||||
@@ -31,7 +30,6 @@ func applyTheme(t Theme) {
|
|||||||
subtleStyle = lipgloss.NewStyle().Foreground(t.Subtle)
|
subtleStyle = lipgloss.NewStyle().Foreground(t.Subtle)
|
||||||
specialStyle = lipgloss.NewStyle().Foreground(t.Success)
|
specialStyle = lipgloss.NewStyle().Foreground(t.Success)
|
||||||
warnStyle = lipgloss.NewStyle().Foreground(t.Warning)
|
warnStyle = lipgloss.NewStyle().Foreground(t.Warning)
|
||||||
staleStyle = lipgloss.NewStyle().Foreground(t.Stale)
|
|
||||||
dangerStyle = lipgloss.NewStyle().Foreground(t.Danger)
|
dangerStyle = lipgloss.NewStyle().Foreground(t.Danger)
|
||||||
titleStyle = lipgloss.NewStyle().Foreground(t.Accent).Bold(true)
|
titleStyle = lipgloss.NewStyle().Foreground(t.Accent).Bold(true)
|
||||||
activeTab = lipgloss.NewStyle().Border(lipgloss.NormalBorder(), false, false, true, false).BorderForeground(t.Accent).Foreground(t.Accent).Bold(true).Padding(0, 1)
|
activeTab = lipgloss.NewStyle().Border(lipgloss.NormalBorder(), false, false, true, false).BorderForeground(t.Accent).Foreground(t.Accent).Bold(true).Padding(0, 1)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func (m Model) viewDetailPanel() string {
|
|||||||
errCat := classifyError(site.LastError, site.Type, site.StatusCode)
|
errCat := classifyError(site.LastError, site.Type, site.StatusCode)
|
||||||
row("Status", fmtStatus(site.Status, site.Paused, m.isMonitorInMaintenance(site.ID), errCat))
|
row("Status", fmtStatus(site.Status, site.Paused, m.isMonitorInMaintenance(site.ID), errCat))
|
||||||
|
|
||||||
if (site.Status == "DOWN" || site.Status == "SSL EXP" || site.Status == "LATE" || site.Status == "STALE") && site.LastError != "" {
|
if (site.Status == "DOWN" || site.Status == "SSL EXP" || site.Status == "LATE") && site.LastError != "" {
|
||||||
errWidth := m.termWidth - chromePadH - 19
|
errWidth := m.termWidth - chromePadH - 19
|
||||||
if errWidth < 30 {
|
if errWidth < 30 {
|
||||||
errWidth = 30
|
errWidth = 30
|
||||||
@@ -105,10 +105,6 @@ func (m Model) viewDetailPanel() string {
|
|||||||
|
|
||||||
section("ENDPOINT")
|
section("ENDPOINT")
|
||||||
row("Type", site.Type)
|
row("Type", site.Type)
|
||||||
if site.Type == "push" && site.Token != "" {
|
|
||||||
row("Token", site.Token)
|
|
||||||
row("Push", "curl -X POST -H 'Authorization: Bearer "+site.Token+"' <host>/api/push")
|
|
||||||
}
|
|
||||||
if site.URL != "" {
|
if site.URL != "" {
|
||||||
row("URL", site.URL)
|
row("URL", site.URL)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,14 +119,9 @@ func (m Model) buildHistoryContent() string {
|
|||||||
ts := sc.ChangedAt.Format("2006-01-02 15:04")
|
ts := sc.ChangedAt.Format("2006-01-02 15:04")
|
||||||
|
|
||||||
arrow := subtleStyle.Render(sc.FromStatus) + " → "
|
arrow := subtleStyle.Render(sc.FromStatus) + " → "
|
||||||
switch sc.ToStatus {
|
if sc.ToStatus == "UP" {
|
||||||
case "UP":
|
|
||||||
arrow += specialStyle.Render(sc.ToStatus)
|
arrow += specialStyle.Render(sc.ToStatus)
|
||||||
case "LATE":
|
} else {
|
||||||
arrow += warnStyle.Render(sc.ToStatus)
|
|
||||||
case "STALE":
|
|
||||||
arrow += staleStyle.Render(sc.ToStatus)
|
|
||||||
default:
|
|
||||||
arrow += dangerStyle.Render(sc.ToStatus)
|
arrow += dangerStyle.Render(sc.ToStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user