diff --git a/internal/endpoint/incidents_test.go b/internal/endpoint/incidents_test.go index a3ad2d51..5d592685 100644 --- a/internal/endpoint/incidents_test.go +++ b/internal/endpoint/incidents_test.go @@ -5,7 +5,7 @@ import ( ) func TestIncidentsHTMLEndpoint(t *testing.T) { - AssertEndpoint(t, "/incidents.html", "./testdata/incidents.html", `Reported by Ayd \(.+\)`) + AssertEndpoint(t, "/incidents.html", "./testdata/incidents.html", `Reported by Ayd \(.+\)|[0-9] years? ago`) } func TestIncidentsRSSEndpoint(t *testing.T) { diff --git a/internal/endpoint/log_test.go b/internal/endpoint/log_test.go index 7c334519..a6d4fdff 100644 --- a/internal/endpoint/log_test.go +++ b/internal/endpoint/log_test.go @@ -492,5 +492,5 @@ func TestLogCSVEndpoint(t *testing.T) { } func TestLogHTMLEndpoint(t *testing.T) { - AssertEndpoint(t, "/log.html?since=2021-01-01T00%3A00%3A00Z&until=2021-01-03T00%3A00%3A00Z", "./testdata/log.html", "") + AssertEndpoint(t, "/log.html?since=2021-01-01T00%3A00%3A00Z&until=2021-01-03T00%3A00%3A00Z", "./testdata/log.html", "[0-9] years? ago") } diff --git a/internal/endpoint/templates.go b/internal/endpoint/templates.go index 38d682fd..3d4ef9af 100644 --- a/internal/endpoint/templates.go +++ b/internal/endpoint/templates.go @@ -157,6 +157,7 @@ var ( type statusSummary struct { Status api.Status + Count int Percent float32 Cumulative float32 IsLast bool @@ -188,7 +189,7 @@ func (b *statusSummaryBuilder) Build() []statusSummary { result := make([]statusSummary, len(b.Count)) i := 0 for s, c := range b.Count { - result[i] = statusSummary{s, float32(c) * 100 / float32(b.Total), 0, false} + result[i] = statusSummary{s, c, float32(c) * 100 / float32(b.Total), 0, false} i++ } sort.Slice(result, func(i, j int) bool { diff --git a/internal/endpoint/templates/base.html b/internal/endpoint/templates/base.html index 7069e3e2..afa02092 100644 --- a/internal/endpoint/templates/base.html +++ b/internal/endpoint/templates/base.html @@ -7,12 +7,12 @@

{{ .Target }}

- + {{ if .ResolvedAt.IsZero -}} ongoing {{- else -}} - + {{- end }}
{{ if .Message }}
{{ .Message }}
{{ end }} diff --git a/internal/endpoint/templates/log.html b/internal/endpoint/templates/log.html index 7e31071a..cf99ea37 100644 --- a/internal/endpoint/templates/log.html +++ b/internal/endpoint/templates/log.html @@ -72,6 +72,18 @@ } {{ end }}{{/* */}} +{{ define "log-records" }} + {{ range .}} + + + {{ .Status }} + {{ .Latency }} + {{ .Target }} + {{ .Message }}{{ range .ReadableExtra }} {{ .Key }} {{ .Value }}{{ end }} + {{ end }} + +{{- end }} + {{ define "body" }}
@@ -99,25 +111,11 @@ message - {{ range .Head }} - - {{ .Time | time2str }} - {{ .Status }} - {{ .Latency }} - {{ .Target }} - {{ .Message }}{{ range .ReadableExtra }} {{ .Key }} {{ .Value }}{{ end }} - {{ end }} - {{ if .Tail }} + {{- block "log-records" .Head }}{{ end }} + {{- if .Tail }} {{ .Omitted }} records have omitted - {{ range .Tail }} - - {{ .Time | time2str }} - {{ .Status }} - {{ .Latency }} - {{ .Target }} - {{ .Message }}{{ range .ReadableExtra }} {{ .Key }} {{ .Value }}{{ end }} - {{ end }} - {{ end }} + {{- block "log-records" .Tail }}{{ end }} + {{- end }}
{{ .Count }} of {{ .Total }} records have shown
diff --git a/internal/endpoint/templates/status.html b/internal/endpoint/templates/status.html index cd9c050d..1179fb48 100644 --- a/internal/endpoint/templates/status.html +++ b/internal/endpoint/templates/status.html @@ -167,7 +167,7 @@ {{ define "body" }}
{{ with .ProbeHistory | calculate_summary }}
    {{ range .}} -
  • +
  • {{ .Status | to_camel }} {{ printf "%.0f%%" .Percent}}
  • {{ end }} diff --git a/internal/endpoint/testdata/incidents.html b/internal/endpoint/testdata/incidents.html index abff3356..b29d0d7e 100644 --- a/internal/endpoint/testdata/incidents.html +++ b/internal/endpoint/testdata/incidents.html @@ -82,7 +82,6 @@ margin: 4px; padding: 12px 16px; border-radius: 4px; - border: 1px solid rgba(var(--fg), .2); } @@ -204,7 +203,7 @@

    http://c.example.com

    - + ongoing
    @@ -223,9 +222,9 @@

    http://b.example.com

    - + - +
    this is failure
    diff --git a/internal/endpoint/testdata/log.html b/internal/endpoint/testdata/log.html index efab81dd..8fa04de4 100644 --- a/internal/endpoint/testdata/log.html +++ b/internal/endpoint/testdata/log.html @@ -82,7 +82,6 @@ margin: 4px; padding: 12px 16px; border-radius: 4px; - border: 1px solid rgba(var(--fg), .2); } @@ -266,49 +265,49 @@ - 2021-01-02T15:04:05Z + HEALTHY 123.456ms http://a.example.com hello world - 2021-01-02T15:04:05Z + FAILURE 12.345ms http://b.example.com this is failure - 2021-01-02T15:04:06Z + HEALTHY 234.567ms http://a.example.com hello world! - 2021-01-02T15:04:06Z + HEALTHY 54.321ms http://b.example.com this is healthy - 2021-01-02T15:04:07Z + HEALTHY 345.678ms http://a.example.com hello world!! - 2021-01-02T15:04:08Z + ABORTED 1.234ms http://c.example.com this is aborted hello world - 2021-01-02T15:04:09Z + UNKNOWN 2.345ms http://c.example.com diff --git a/internal/endpoint/testdata/status.html b/internal/endpoint/testdata/status.html index 3cea71aa..42cc6597 100644 --- a/internal/endpoint/testdata/status.html +++ b/internal/endpoint/testdata/status.html @@ -82,7 +82,6 @@ margin: 4px; padding: 12px 16px; border-radius: 4px; - border: 1px solid rgba(var(--fg), .2); } @@ -262,7 +261,7 @@ } .time-range { - border: 0 solid rgba(var(--fg), .1); + border: 0 solid rgba(var(--fg), .2); border-width: 0 1px; padding: 0 .2em; display: flex; @@ -332,11 +331,11 @@
      -
    • +
    • Unknown 50%
    • -
    • +
    • Healthy 50%
    • @@ -692,7 +691,7 @@

      http://c.example.com

      - + ongoing