Skip to content

Commit

Permalink
chore: refactor templates (#28)
Browse files Browse the repository at this point in the history
* chore: revamped alert template

* chore: revamped silence create template

* chore: revamped silences list template
  • Loading branch information
freak12techno authored Dec 11, 2023
1 parent c75ff59 commit c47fff2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
9 changes: 7 additions & 2 deletions templates/alert.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
{{- range $alertId, $alert := .Data.Alerts }}

- {{ GetEmojiByStatus $alert.State }}
<strong>Firing for:</strong> {{ FormatDuration $alert.ActiveSince }} (since {{ FormatDate $alert.ActiveAt }})
{{- if $alert.Value }}
<strong>Value: </strong>{{ StrToFloat64 $alert.Value }}
{{- end }}
<strong>Labels: </strong>
{{- range $key, $label := $alert.Labels }}
{{ $key }} = {{ $label }}
{{ $key }} = {{ $label }}
{{- end }}
{{- end }}
{{- end }}
17 changes: 9 additions & 8 deletions templates/silences_create.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<strong>Created silence with following params:</strong>
ID: <code>{{ .Data.ID }}</code>
Starts at: <pre>{{ .Data.StartsAt.String }}</pre>
Ends at: <pre>{{ .Data.EndsAt.String }}</pre>
Created by: <pre>{{ .Data.CreatedBy }}</pre>
Comment: <pre>{{ .Data.Comment }}</pre>
Status: <pre>{{ GetEmojiBySilenceStatus .Data.Status.State }} {{ .Data.Status.State }}</pre>
Matchers:

<strong>ID:</strong> <code>{{ .Data.ID }}</code>
<strong>Starts at:</strong> {{ FormatDate .Data.StartsAt }}
<strong>Ends at:</strong> {{ FormatDate .Data.EndsAt }}
<strong>Created by:</strong> {{ .Data.CreatedBy }}
<strong>Comment:</strong> {{ .Data.Comment }}
<strong>Status:</strong> {{ GetEmojiBySilenceStatus .Data.Status.State }} {{ .Data.Status.State }}
<strong>Matchers:</strong>
{{- range $matcherId, $matcher := .Data.Matchers }}
<pre> {{ $matcher.Serialize }}</pre>
{{ $matcher.Serialize }}
{{- end }}
7 changes: 4 additions & 3 deletions templates/silences_delete.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<strong>Deleted silence with following params:</strong>
ID: <code>{{ .Data.ID }}</code>
Matchers:

<strong>ID:</strong> {{ .Data.ID }}
<strong>Matchers:</strong>
{{- range $matcherId, $matcher := .Data.Matchers }}
<pre> {{ $matcher.Serialize }}</pre>
{{ $matcher.Serialize }}
{{- end }}
22 changes: 12 additions & 10 deletions templates/silences_list.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
{{- $global := . }}
<strong>Silences</strong>
{{- if not .Data }}
<strong>Silences</strong>
No silences.
{{- end }}
{{- else }}
<strong>Silences ({{ len .Data }}):</strong>
{{ end }}
{{- range $silenceId, $silence := .Data }}
ID: <code>{{ $silence.ID }}</code>
Starts at: <pre>{{ $silence.StartsAt.String }}</pre>
Ends at: <pre>{{ $silence.EndsAt.String }}</pre>
Created by: <pre>{{ $silence.CreatedBy }}</pre>
Comment: <pre>{{ $silence.Comment }}</pre>
Status: <pre>{{ GetEmojiBySilenceStatus $silence.Status.State }} {{ $silence.Status.State }}</pre>
Matchers:
<strong>ID:</strong> <code>{{ $silence.ID }}</code>
<strong>Starts at:</strong> {{ FormatDate $silence.StartsAt }}
<strong>Ends at:</strong> {{ FormatDate $silence.EndsAt }}
<strong>Created by:</strong> {{ $silence.CreatedBy }}
<strong>Comment:</strong> {{ $silence.Comment }}
<strong>Status:</strong> {{ GetEmojiBySilenceStatus $silence.Status.State }} {{ $silence.Status.State }}
<strong>Matchers:</strong>
{{- range $matcherId, $matcher := $silence.Matchers }}
<pre> {{ $matcher.Serialize }}</pre>
{{ $matcher.Serialize }}
{{- end }}
{{ end }}

0 comments on commit c47fff2

Please sign in to comment.