diff options
| -rw-r--r-- | config.example.yaml | 1 | ||||
| -rw-r--r-- | internal/config/config.go | 1 | ||||
| -rw-r--r-- | internal/server/server.go | 2 | ||||
| -rw-r--r-- | internal/server/templates/index.html | 2 |
4 files changed, 5 insertions, 1 deletions
diff --git a/config.example.yaml b/config.example.yaml index 9dab8b2..5ceba5f 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -80,6 +80,7 @@ groups: - name: "API" type: https target: "https://api.example.com/health" + link: "https://docs.example.com/api" # Custom link when clicking the monitor name interval: 30s timeout: 10s expected_status: 200 diff --git a/internal/config/config.go b/internal/config/config.go index dfd403a..7bad5f9 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -77,6 +77,7 @@ 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 diff --git a/internal/server/server.go b/internal/server/server.go index 6b5ded3..af3660e 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -144,6 +144,7 @@ type GroupData struct { type MonitorData struct { Name string Type string + Link string // Custom URL for clicking the monitor name Status string StatusClass string ResponseTime int64 @@ -233,6 +234,7 @@ func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) { md := MonitorData{ Name: monCfg.Name, Type: monCfg.Type, + Link: monCfg.Link, DisablePingTooltips: monCfg.DisablePingTooltips, } diff --git a/internal/server/templates/index.html b/internal/server/templates/index.html index 9d98b44..12bcb12 100644 --- a/internal/server/templates/index.html +++ b/internal/server/templates/index.html @@ -88,7 +88,7 @@ {{else}} <div class="w-2 h-2 rounded-full bg-neutral-400 flex-shrink-0"></div> {{end}} - <span class="font-medium truncate">{{.Name}}</span> + {{if .Link}}<a href="{{.Link}}" target="_blank" rel="noopener noreferrer" class="font-medium truncate hover:underline">{{.Name}}</a>{{else}}<span class="font-medium truncate">{{.Name}}</span>{{end}} <span class="text-xs px-1.5 py-0.5 rounded bg-neutral-200 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400 uppercase">{{.Type}}</span> </div> <div class="flex items-center gap-4 text-xs text-neutral-500 dark:text-neutral-400"> |