smon/views/pages/trigger_edit.gotmpl

41 lines
1.2 KiB
Go Template
Raw Normal View History

2024-04-29 08:36:13 +02:00
{{ define "page" }}
<script type="module" defer>
import {UI, Trigger} from "/js/{{ .VERSION }}/trigger_edit.mjs"
window._ui = new UI()
let trigger = new Trigger(
{{ .Data.Trigger.ID }},
'{{ .Data.Trigger.Name }}',
)
_ui.setTrigger(trigger)
</script>
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/trigger_edit.css">
{{ block "page_label" . }}{{end}}
2024-04-30 08:04:16 +02:00
<form id="form-trigger" action="/trigger/update/{{ .Data.Trigger.ID }}" method="post">
2024-04-29 08:36:13 +02:00
<div id="widgets" class="widgets">
<div class="label">Name</div>
<div><input type="text" name="name" value="{{ .Data.Trigger.Name }}"></div>
<div class="label">Datapoints</div>
<div class="datapoints" style="margin-top: 4px">
{{ range .Data.Datapoints }}
2024-04-30 08:04:16 +02:00
<div class="datapoint name"><b>{{ .Name }}</b></div>
2024-04-29 08:36:13 +02:00
<div class="datapoint value">{{ .LastDatapointValue.Value }}</div>
{{ end }}
</div>
<div class="label">Expression</div>
<div><textarea id="expr" name="expression" rows=8>{{ .Data.Trigger.Expression }}</textarea></div>
<div></div>
<div class="action">
2024-04-30 08:04:16 +02:00
<button id="button-update">Update</button>
2024-04-29 08:36:13 +02:00
<button id="button-run" onclick="window._ui.run(); return false">Test</button>
<div id="run-result"></div>
</div>
</form>
{{ end }}