Bläddra i källkod

Added error-url parameter to monitor sites

Jeck 5 månader sedan
förälder
incheckning
c8200f2972
3 ändrade filer med 10 tillägg och 0 borttagningar
  1. 5 0
      docs/configuration.md
  2. 4 0
      internal/glance/templates/monitor.html
  3. 1 0
      internal/glance/widget-monitor.go

+ 5 - 0
docs/configuration.md

@@ -1220,6 +1220,7 @@ Properties for each site:
 | title | string | yes | |
 | url | string | yes | |
 | check-url | string | no | |
+| error-url | string | no | |
 | icon | string | no | |
 | allow-insecure | boolean | no | false |
 | same-tab | boolean | no | false |
@@ -1237,6 +1238,10 @@ The public facing URL of a monitored service, the user will be redirected here.
 
 The URL which will be requested and its response will determine the status of the site. If not specified, the `url` property is used.
 
+`error-url`
+
+If the monitored service returns an error, the user will be redirected here. If not specified, the `url` property is used.
+
 `icon`
 
 Optional URL to an image which will be used as the icon for the site. Can be an external URL or internal via [server configured assets](#assets-path). You can also directly use [Simple Icons](https://simpleicons.org/) via a `si:` prefix or [Dashboard Icons](https://github.com/walkxcode/dashboard-icons) via a `di:` prefix:

+ 4 - 0
internal/glance/templates/monitor.html

@@ -25,7 +25,11 @@
 <img class="monitor-site-icon{{ if .Icon.IsFlatIcon }} flat-icon{{ end }}" src="{{ .Icon.URL }}" alt="" loading="lazy">
 {{ end }}
 <div class="min-width-0">
+    {{ if and .Status.Error ( ne "" .ErrorURL)}}
+    <a class="size-h3 color-highlight text-truncate block" href="{{ .ErrorURL | safeURL }}" {{ if not .SameTab }}target="_blank"{{ end }} rel="noreferrer">{{ .Title }}</a>
+    {{ else }}
     <a class="size-h3 color-highlight text-truncate block" href="{{ .URL | safeURL }}" {{ if not .SameTab }}target="_blank"{{ end }} rel="noreferrer">{{ .Title }}</a>
+    {{ end }}
     <ul class="list-horizontal-text">
         {{ if not .Status.Error }}
         <li title="{{ .Status.Code }}">{{ .StatusText }}</li>

+ 1 - 0
internal/glance/widget-monitor.go

@@ -20,6 +20,7 @@ type monitorWidget struct {
 	Sites      []struct {
 		*SiteStatusRequest `yaml:",inline"`
 		Status             *siteStatus     `yaml:"-"`
+		ErrorURL           string          `yaml:"error-url"`
 		Title              string          `yaml:"title"`
 		Icon               customIconField `yaml:"icon"`
 		SameTab            bool            `yaml:"same-tab"`