diff options
| author | Fuwn <[email protected]> | 2026-01-19 18:37:16 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-01-19 18:37:16 -0800 |
| commit | db17158de7bd7b0a9656893c0c36c6b198b0d713 (patch) | |
| tree | ebc51b6c4ac52edf73612d37468076afbafe0d1b | |
| parent | fix: Preserve config formatting when updating reset flag (diff) | |
| download | kaze-db17158de7bd7b0a9656893c0c36c6b198b0d713.tar.xz kaze-db17158de7bd7b0a9656893c0c36c6b198b0d713.zip | |
feat: Add disable_ping_tooltips option to hide ping hover details
Add monitor-level option to disable hover tooltips on individual ping bars.
Can be set at group defaults or per-monitor. When enabled, visual appearance
remains unchanged but tooltips no longer appear on hover.
| -rw-r--r-- | config.example.yaml | 22 | ||||
| -rw-r--r-- | internal/config/config.go | 48 | ||||
| -rw-r--r-- | internal/server/server.go | 30 | ||||
| -rw-r--r-- | internal/server/templates/index.html | 4 |
4 files changed, 58 insertions, 46 deletions
diff --git a/config.example.yaml b/config.example.yaml index 50c116b..18e9dbc 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -56,12 +56,13 @@ groups: - name: "Web Services" # default_collapsed: false # Start collapsed (false = expanded by default) # show_group_uptime: true # Show aggregate uptime percentage (true by default) - # Group-level defaults (optional - apply to all monitors in this group unless overridden) - # defaults: - # interval: 30s - # timeout: 10s - # retries: 2 - # verify_ssl: true + # Group-level defaults (optional - apply to all monitors in this group unless overridden) + # defaults: + # interval: 30s + # timeout: 10s + # retries: 2 + # verify_ssl: true + # disable_ping_tooltips: false monitors: - name: "Website" type: https @@ -73,9 +74,10 @@ groups: expected_status: 200 # expected_content: "Welcome" # Check if response body contains this text verify_ssl: true - # hide_ssl_days: false # Hide SSL certificate days left from display - # round_response_time: false # Round response time to nearest second - # round_uptime: false # Round uptime percentage (e.g., 99.99% → 100%) + # hide_ssl_days: false # Hide SSL certificate days left from display + # round_response_time: false # Round response time to nearest second + # round_uptime: false # Round uptime percentage (e.g., 99.99% → 100%) + # disable_ping_tooltips: false # Disable hover tooltips on ping history bars - name: "API" type: https @@ -150,6 +152,7 @@ incidents: # timeout: duration - Default timeout for all monitors in group # retries: int - Default retry attempts for all monitors in group # verify_ssl: bool - Default SSL verification for all monitors in group +# disable_ping_tooltips: bool - Default tooltip behavior for all monitors in group # Note: Individual monitors can override these defaults # # Common fields for all monitor types: @@ -165,6 +168,7 @@ incidents: # hide_ssl_days: bool - Hide SSL/TLS certificate days left from display (default: false) # round_response_time: bool - Round response time to nearest second (default: false) # round_uptime: bool - Round uptime percentage to whole number (e.g., 99.99% → 100%) (default: false) +# disable_ping_tooltips: bool - Disable hover tooltips on ping history bars (default: false, or group default) # # HTTP/HTTPS specific fields: # expected_status: int - Expected HTTP status code (default: 200) diff --git a/internal/config/config.go b/internal/config/config.go index 5a173b6..7ed28dd 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -66,31 +66,33 @@ type GroupConfig struct { // MonitorDefaults contains default values that can be set at group level type MonitorDefaults struct { - Interval *Duration `yaml:"interval,omitempty"` - Timeout *Duration `yaml:"timeout,omitempty"` - Retries *int `yaml:"retries,omitempty"` - VerifySSL *bool `yaml:"verify_ssl,omitempty"` + Interval *Duration `yaml:"interval,omitempty"` + Timeout *Duration `yaml:"timeout,omitempty"` + Retries *int `yaml:"retries,omitempty"` + VerifySSL *bool `yaml:"verify_ssl,omitempty"` + DisablePingTooltips *bool `yaml:"disable_ping_tooltips,omitempty"` } // MonitorConfig represents a single monitor type MonitorConfig struct { - Name string `yaml:"name"` - Type string `yaml:"type"` // http, https, tcp, gemini - Target string `yaml:"target"` - Interval Duration `yaml:"interval"` - Timeout Duration `yaml:"timeout"` - Retries int `yaml:"retries,omitempty"` // Number of retry attempts before marking as down - ResetOnNextCheck bool `yaml:"reset_on_next_check,omitempty"` // Wipe monitor data on next check and flip to false - ExpectedStatus int `yaml:"expected_status,omitempty"` - ExpectedContent string `yaml:"expected_content,omitempty"` // Expected text in response body - VerifySSL *bool `yaml:"verify_ssl,omitempty"` - HideSSLDays bool `yaml:"hide_ssl_days,omitempty"` // Hide SSL days left from display - RoundResponseTime bool `yaml:"round_response_time,omitempty"` // Round response time to nearest second - RoundUptime bool `yaml:"round_uptime,omitempty"` // Round uptime percentage (e.g., 99.99% → 100%) - Method string `yaml:"method,omitempty"` - UserAgent string `yaml:"user_agent,omitempty"` // Custom User-Agent header (default: "Kaze-Monitor/1.0") - Headers map[string]string `yaml:"headers,omitempty"` - Body string `yaml:"body,omitempty"` + Name string `yaml:"name"` + Type string `yaml:"type"` // http, https, tcp, gemini + Target string `yaml:"target"` + Interval Duration `yaml:"interval"` + Timeout Duration `yaml:"timeout"` + Retries int `yaml:"retries,omitempty"` // Number of retry attempts before marking as down + ResetOnNextCheck bool `yaml:"reset_on_next_check,omitempty"` // Wipe monitor data on next check and flip to false + ExpectedStatus int `yaml:"expected_status,omitempty"` + ExpectedContent string `yaml:"expected_content,omitempty"` // Expected text in response body + VerifySSL *bool `yaml:"verify_ssl,omitempty"` + HideSSLDays bool `yaml:"hide_ssl_days,omitempty"` // Hide SSL days left from display + RoundResponseTime bool `yaml:"round_response_time,omitempty"` // Round response time to nearest second + RoundUptime bool `yaml:"round_uptime,omitempty"` // Round uptime percentage (e.g., 99.99% → 100%) + DisablePingTooltips bool `yaml:"disable_ping_tooltips,omitempty"` // Disable hover tooltips on ping history bars + Method string `yaml:"method,omitempty"` + UserAgent string `yaml:"user_agent,omitempty"` // Custom User-Agent header (default: "Kaze-Monitor/1.0") + Headers map[string]string `yaml:"headers,omitempty"` + Body string `yaml:"body,omitempty"` } // IncidentConfig represents an incident or maintenance @@ -262,6 +264,10 @@ func (c *Config) applyDefaults() { } } } + // Apply group-level disable_ping_tooltips default + if !m.DisablePingTooltips && grp.Defaults != nil && grp.Defaults.DisablePingTooltips != nil && *grp.Defaults.DisablePingTooltips { + m.DisablePingTooltips = true + } } } } diff --git a/internal/server/server.go b/internal/server/server.go index d0f6fa5..8681873 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -141,18 +141,19 @@ type GroupData struct { // MonitorData contains data for a single monitor type MonitorData struct { - Name string - Type string - Status string - StatusClass string - ResponseTime int64 - UptimePercent float64 - Ticks []*storage.TickData // Aggregated tick data for history bar - SSLDaysLeft int - SSLExpiryDate time.Time - SSLTooltip string // JSON data for SSL expiration tooltip - LastCheck time.Time - LastError string + Name string + Type string + Status string + StatusClass string + ResponseTime int64 + UptimePercent float64 + Ticks []*storage.TickData // Aggregated tick data for history bar + SSLDaysLeft int + SSLExpiryDate time.Time + SSLTooltip string // JSON data for SSL expiration tooltip + LastCheck time.Time + LastError string + DisablePingTooltips bool } // IncidentData contains data for an incident @@ -216,8 +217,9 @@ func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) { for _, monCfg := range group.Monitors { md := MonitorData{ - Name: monCfg.Name, - Type: monCfg.Type, + Name: monCfg.Name, + Type: monCfg.Type, + DisablePingTooltips: monCfg.DisablePingTooltips, } if stat, ok := stats[monCfg.Name]; ok { diff --git a/internal/server/templates/index.html b/internal/server/templates/index.html index 7713c23..f136e51 100644 --- a/internal/server/templates/index.html +++ b/internal/server/templates/index.html @@ -116,10 +116,10 @@ <!-- History Bar --> <div class="mt-3 flex gap-px"> {{range .Ticks}} - <div class="flex-1 h-6 rounded-sm {{tickColor .}}" data-tooltip='{{tickTooltipData . $.TickMode $.Timezone}}'></div> + <div class="flex-1 h-6 rounded-sm {{tickColor .}}"{{if not $.DisablePingTooltips}} data-tooltip='{{tickTooltipData . $.TickMode $.Timezone}}'{{end}}></div> {{else}} {{range seq $.TickCount}} - <div class="flex-1 h-6 rounded-sm bg-neutral-200 dark:bg-neutral-800" data-tooltip='{"header":"No data"}'></div> + <div class="flex-1 h-6 rounded-sm bg-neutral-200 dark:bg-neutral-800"{{if not $.DisablePingTooltips}} data-tooltip='{"header":"No data"}'{{end}}></div> {{end}} {{end}} </div> |