smon/views/pages/datapoints.gotmpl
2024-05-02 08:59:55 +02:00

30 lines
1.1 KiB
Go Template

{{ define "page" }}
{{ $version := .VERSION }}
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/datapoints.css">
{{ block "page_label" . }}{{end}}
<a href="/datapoint/edit/0">Create</a>
<div id="datapoints">
<div class="header">Name</div>
<div class="header">Datatype</div>
<div class="header">Last value</div>
<div class="header">Value</div>
<div class="header"></div>
{{ range .Data.Datapoints }}
<div class="line"></div>
<div class="name"><a href="/datapoint/edit/{{ .ID }}">{{ .Name }}</a></div>
<div class="datatype">{{ .Datatype }}</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="delete"><a href="/datapoint/delete/{{ .ID }}" onclick="confirm(`Are you sure you want to delete '{{ .Name }}'?`)"><img src="/images/{{ $version }}/delete.svg"></a></div>
{{ end }}
</div>
{{ end }}