diff options
| author | Fuwn <[email protected]> | 2026-01-20 06:39:49 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-01-20 06:39:49 -0800 |
| commit | 7eae8963da2312e663b253bc06d365061f13fe5c (patch) | |
| tree | ccb37aae8e9d1cf1b49ec47712e62d30fde3bd0d | |
| parent | fix: Use correct column name error_message in last failure query (diff) | |
| download | kaze-7eae8963da2312e663b253bc06d365061f13fe5c.tar.xz kaze-7eae8963da2312e663b253bc06d365061f13fe5c.zip | |
feat: Add disable_uptime_tooltip option
| -rw-r--r-- | internal/config/config.go | 41 | ||||
| -rw-r--r-- | internal/server/server.go | 48 | ||||
| -rw-r--r-- | internal/server/templates/index.html | 2 |
3 files changed, 47 insertions, 44 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index 626873b..b598306 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -77,26 +77,27 @@ type MonitorDefaults struct { // MonitorConfig represents a single monitor type MonitorConfig struct { - Name string `yaml:"name"` - Type string `yaml:"type"` // http, https, tcp, gemini - Target string `yaml:"target"` - Link string `yaml:"link,omitempty"` // Custom URL for clicking the monitor name (e.g., docs page) - 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 - HidePing bool `yaml:"hide_ping,omitempty"` // Hide response time 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"` + Name string `yaml:"name"` + Type string `yaml:"type"` // http, https, tcp, gemini + Target string `yaml:"target"` + Link string `yaml:"link,omitempty"` // Custom URL for clicking the monitor name (e.g., docs page) + 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 + HidePing bool `yaml:"hide_ping,omitempty"` // Hide response time 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 + DisableUptimeTooltip bool `yaml:"disable_uptime_tooltip,omitempty"` // Disable hover tooltip on uptime percentage + 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"` // ICMP specific fields PingCount int `yaml:"ping_count,omitempty"` // Number of ICMP packets to send (default: 4) // DNS specific fields diff --git a/internal/server/server.go b/internal/server/server.go index 499ca31..92b0f09 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -154,24 +154,25 @@ type GroupData struct { // MonitorData contains data for a single monitor type MonitorData struct { - Name string - Type string - Link template.URL // Custom URL for clicking the monitor name (trusted) - Status string - StatusClass string - ResponseTime int64 - HidePing bool // Hide response time from display - UptimePercent float64 - UptimeTooltip string // JSON data for uptime tooltip with last failure info - 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 - LastFailure *time.Time // Time of last failure - LastFailureError string // Error from last failure - DisablePingTooltips bool + Name string + Type string + Link template.URL // Custom URL for clicking the monitor name (trusted) + Status string + StatusClass string + ResponseTime int64 + HidePing bool // Hide response time from display + UptimePercent float64 + UptimeTooltip string // JSON data for uptime tooltip with last failure info + 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 + LastFailure *time.Time // Time of last failure + LastFailureError string // Error from last failure + DisablePingTooltips bool + DisableUptimeTooltip bool } // IncidentData contains data for an incident @@ -251,11 +252,12 @@ func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) { for _, monCfg := range group.Monitors { md := MonitorData{ - Name: monCfg.Name, - Type: monCfg.Type, - Link: template.URL(monCfg.Link), - HidePing: monCfg.HidePing, - DisablePingTooltips: monCfg.DisablePingTooltips, + Name: monCfg.Name, + Type: monCfg.Type, + Link: template.URL(monCfg.Link), + HidePing: monCfg.HidePing, + DisablePingTooltips: monCfg.DisablePingTooltips, + DisableUptimeTooltip: monCfg.DisableUptimeTooltip, } if stat, ok := stats[monCfg.Name]; ok { diff --git a/internal/server/templates/index.html b/internal/server/templates/index.html index c192a66..be80544 100644 --- a/internal/server/templates/index.html +++ b/internal/server/templates/index.html @@ -104,7 +104,7 @@ </div> </div> <div class="flex items-center gap-2 flex-shrink-0"> - <span class="text-sm font-medium {{if ge .UptimePercent 99.0}}text-emerald-600 dark:text-emerald-400{{else if ge .UptimePercent 95.0}}text-yellow-600 dark:text-yellow-400{{else}}text-red-600 dark:text-red-400{{end}}"{{if not $monitor.DisablePingTooltips}} data-tooltip='{{.UptimeTooltip}}'{{end}}>{{formatUptime .UptimePercent}}</span> + <span class="text-sm font-medium {{if ge .UptimePercent 99.0}}text-emerald-600 dark:text-emerald-400{{else if ge .UptimePercent 95.0}}text-yellow-600 dark:text-yellow-400{{else}}text-red-600 dark:text-red-400{{end}}"{{if not $monitor.DisableUptimeTooltip}} data-tooltip='{{.UptimeTooltip}}'{{end}}>{{formatUptime .UptimePercent}}</span> </div> </div> <!-- History Bar --> |