smon/views/pages/datapoint_values.gotmpl

56 lines
1.8 KiB
Go Template
Raw Normal View History

2024-05-05 20:16:28 +02:00
{{ define "page" }}
{{ $version := .VERSION }}
2024-06-27 08:59:34 +02:00
{{ $graph := and (eq .Data.Display "graph") (eq .Data.Datapoint.Datatype "INT") }}
2024-06-25 08:59:07 +02:00
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/{{ .CONFIG.THEME }}/datapoints.css">
2024-06-27 17:32:47 +02:00
<script src="/js/{{ .VERSION }}/datapoint_values.js"></script>
2024-06-26 11:58:54 +02:00
<script src="/js/{{ .VERSION }}/lib/plotly-2.32.0.min.js" charset="utf-8"></script>
2024-05-05 20:16:28 +02:00
{{ block "page_label" . }}{{end}}
2024-07-04 15:14:24 +02:00
{{ block "timefilter" . }}{{ end }}
{{ if eq .Data.Datapoint.Datatype "INT" }}
<div style="margin-top: 16px">
2024-07-04 13:37:06 +02:00
<input onchange="selectDisplay('graph')" name="display" type="radio" id="display-graph" {{ if $graph }} checked {{ end}}> <label for="display-graph">Graph</label>
2024-07-05 12:04:56 +02:00
<br>
2024-07-04 13:37:06 +02:00
<input onchange="selectDisplay('list')" name="display" type="radio" id="display-list" {{ if not $graph }} checked {{ end }}> <label for="display-list">List</label>
</div>
2024-07-04 15:14:24 +02:00
{{ end }}
2024-06-27 16:53:30 +02:00
2024-07-04 13:37:06 +02:00
<script type="text/javascript">
const inputDisplay = document.createElement('input')
inputDisplay.id = 'input-display'
inputDisplay.type = 'hidden'
2024-07-04 15:14:24 +02:00
inputDisplay.name = 'display'
inputDisplay.value = '{{ if $graph }}graph{{ else }}list{{ end }}'
document.getElementById('form-time-selector').append(inputDisplay)
2024-07-04 13:37:06 +02:00
</script>
2024-06-27 08:59:34 +02:00
{{ if $graph }}
2024-06-27 09:14:02 +02:00
<div class="graph">
<div id="graph-values"></div>
</div>
2024-06-27 16:53:30 +02:00
<div style="margin-top: 8px;">
<b>Number of values:</b>
<span id="num-values">{{ len .Data.Values }}</span>
</div>
2024-06-26 11:58:54 +02:00
<script type="text/javascript">
2024-06-27 16:53:30 +02:00
new Graph(
{{ .Data.Datapoint.ID }},
{{ .Data.Values }},
)
2024-06-26 11:58:54 +02:00
</script>
2024-06-26 12:01:47 +02:00
{{ else }}
<div id="values">
2024-06-27 13:45:01 +02:00
<div class="header">Value added</div>
<div class="header">Value</div>
<div class="line"></div>
2024-06-26 12:01:47 +02:00
{{ range .Data.Values }}
<div class="value">{{ format_time .Ts }}</div>
2024-06-27 16:53:30 +02:00
<div class="value">{{ .Value }}</div>
2024-06-26 12:01:47 +02:00
{{ end }}
</div>
2024-06-26 11:58:54 +02:00
{{ end }}
2024-05-05 20:16:28 +02:00
{{ end }}