smon/views/pages/datapoints.gotmpl
2024-06-25 10:50:31 +02:00

47 lines
1.9 KiB
Go Template

{{ define "page" }}
{{ $version := .VERSION }}
{{ $theme := .CONFIG.THEME }}
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/{{ .CONFIG.THEME }}/datapoints.css">
{{ block "page_label" . }}{{end}}
<a href="/datapoint/edit/0">Create</a>
<div id="datapoints">
{{ $prevGroup := "15ecfcc0-b1aa-45cd-af9c-74146a7e7f56-not-very-likely" }}
{{ range .Data.Datapoints }}
{{ if ne $prevGroup .Group }}
<h2 class="line">{{ .Group }}</h2>
<div class="header">Name</div>
<div class="header">Datatype</div>
<div class="header">No data</div>
<div class="header">Last value</div>
<div class="header">Value</div>
<div class="header"></div>
{{ else }}
<div class="line"></div>
{{ end }}
<div class="name"><a href="/datapoint/edit/{{ .ID }}">{{ .Name }}</a></div>
<div class="datatype">{{ .Datatype }}</div>
<div class="datatype">{{ .NodataProblemSeconds }}</div>
<div class="last-value">{{ format_time .LastValue }}</div>
{{ if eq .Datatype "DATETIME" }}
<div class="value">{{ if .LastDatapointValue.ValueDateTime.Valid }}{{ format_time .LastDatapointValue.Value }}{{ end }}</div>
{{ else }}
<div class="value">{{ .LastDatapointValue.Value }}</div>
{{ end }}
<div class="icons">
{{ if eq .Comment "" }}
<div class="values"><img class="info" src="/images/{{ $version }}/{{ $theme }}/info-outline.svg"></div>
{{ else }}
<div class="values"><img class="info" src="/images/{{ $version }}/{{ $theme }}/info-filled.svg" title="{{ .Comment }}"></div>
{{ end }}
<div class="values"><a href="/datapoint/values/{{ .ID }}"><img src="/images/{{ $version }}/{{ $theme }}/values.svg"></a></div>
<div class="delete"><a href="/datapoint/delete/{{ .ID }}" onclick="confirm(`Are you sure you want to delete '{{ .Name }}'?`)"><img src="/images/{{ $version }}/{{ $theme }}/delete.svg"></a></div>
</div>
{{ $prevGroup = .Group }}
{{ end }}
</div>
{{ end }}