From 92bd23fa5b6a1ad239a007dc905ce101a37fbe31 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Tue, 20 Jan 2026 05:37:38 -0800 Subject: fix: Hide ping in tooltips when hide_ping is enabled --- internal/server/server.go | 34 +++++++++++++++++++++++++++++----- internal/server/templates/index.html | 2 +- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/internal/server/server.go b/internal/server/server.go index 50a41af..28b3662 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -539,7 +539,7 @@ func templateFuncs() template.FuncMap { } return "bg-neutral-200 dark:bg-neutral-800" }, - "tickTooltipData": func(tick *storage.TickData, mode, timezone string) string { + "tickTooltipData": func(tick *storage.TickData, mode, timezone string, hidePing bool) string { if tick == nil { data := map[string]interface{}{"header": "No data"} b, _ := json.Marshal(data) @@ -586,7 +586,13 @@ func templateFuncs() template.FuncMap { statusClass = tickStatusClass(tick.Status) rows = append(rows, map[string]string{"label": "Status", "value": tick.Status, "class": statusClass}, - map[string]string{"label": "Response", "value": fmt.Sprintf("%dms", tick.ResponseTime), "class": ""}, + ) + if !hidePing { + rows = append(rows, + map[string]string{"label": "Response", "value": fmt.Sprintf("%dms", tick.ResponseTime), "class": ""}, + ) + } + rows = append(rows, map[string]string{"label": "Timezone", "value": fmt.Sprintf("%s (%s)", tzAbbr, utcOffset), "class": ""}, ) case "minute": @@ -595,7 +601,13 @@ func templateFuncs() template.FuncMap { rows = append(rows, map[string]string{"label": "Checks", "value": fmt.Sprintf("%d", tick.TotalChecks), "class": ""}, map[string]string{"label": "Uptime", "value": fmt.Sprintf("%.1f%%", tick.UptimePercent), "class": statusClass}, - map[string]string{"label": "Avg Response", "value": fmt.Sprintf("%dms", int(tick.AvgResponse)), "class": ""}, + ) + if !hidePing { + rows = append(rows, + map[string]string{"label": "Avg Response", "value": fmt.Sprintf("%dms", int(tick.AvgResponse)), "class": ""}, + ) + } + rows = append(rows, map[string]string{"label": "Timezone", "value": fmt.Sprintf("%s (%s)", tzAbbr, utcOffset), "class": ""}, ) case "hour": @@ -604,7 +616,13 @@ func templateFuncs() template.FuncMap { rows = append(rows, map[string]string{"label": "Checks", "value": fmt.Sprintf("%d", tick.TotalChecks), "class": ""}, map[string]string{"label": "Uptime", "value": fmt.Sprintf("%.1f%%", tick.UptimePercent), "class": statusClass}, - map[string]string{"label": "Avg Response", "value": fmt.Sprintf("%dms", int(tick.AvgResponse)), "class": ""}, + ) + if !hidePing { + rows = append(rows, + map[string]string{"label": "Avg Response", "value": fmt.Sprintf("%dms", int(tick.AvgResponse)), "class": ""}, + ) + } + rows = append(rows, map[string]string{"label": "Timezone", "value": fmt.Sprintf("%s (%s)", tzAbbr, utcOffset), "class": ""}, ) case "day": @@ -613,7 +631,13 @@ func templateFuncs() template.FuncMap { rows = append(rows, map[string]string{"label": "Checks", "value": fmt.Sprintf("%d", tick.TotalChecks), "class": ""}, map[string]string{"label": "Uptime", "value": fmt.Sprintf("%.1f%%", tick.UptimePercent), "class": statusClass}, - map[string]string{"label": "Avg Response", "value": fmt.Sprintf("%dms", int(tick.AvgResponse)), "class": ""}, + ) + if !hidePing { + rows = append(rows, + map[string]string{"label": "Avg Response", "value": fmt.Sprintf("%dms", int(tick.AvgResponse)), "class": ""}, + ) + } + rows = append(rows, map[string]string{"label": "Timezone", "value": fmt.Sprintf("%s (%s)", tzAbbr, utcOffset), "class": ""}, ) default: diff --git a/internal/server/templates/index.html b/internal/server/templates/index.html index 62a56b4..d689416 100644 --- a/internal/server/templates/index.html +++ b/internal/server/templates/index.html @@ -111,7 +111,7 @@
{{range $monitor.Ticks}} -
+
{{else}} {{range seq $.TickCount}}
-- cgit v1.2.3