smon/views/pages/trigger_edit.gotmpl

49 lines
1.5 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 }}',
2024-05-01 10:02:33 +02:00
{{ .Data.Datapoints }},
2024-04-29 08:36:13 +02:00
)
_ui.setTrigger(trigger)
2024-05-01 10:02:33 +02:00
_ui.render()
2024-04-29 08:36:13 +02:00
</script>
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/trigger_edit.css">
{{ block "page_label" . }}{{end}}
2024-05-01 10:02:33 +02:00
<dialog id="dlg-datapoints">
<input list="list-datapoints" id="datapoint">
<datalist id="list-datapoints"></datalist>
<button onclick="_ui.chooseDatapoint()">OK</button>
</dialog>
2024-04-30 08:04:16 +02:00
<form id="form-trigger" action="/trigger/update/{{ .Data.Trigger.ID }}" method="post">
2024-05-01 10:02:33 +02:00
<input type="hidden" name="sectionID" value="{{ .Data.Trigger.SectionID }}">
<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">
<div><a onclick="_ui.addDatapoint()">Add</a></div>
<div></div>
</div>
<div class="label">Expression</div>
<div><textarea id="expr" name="expression" rows=8>{{ .Data.Trigger.Expression }}</textarea></div>
<div></div>
<div class="action">
<button id="button-update" onclick="_ui.update(); return false">{{ if eq .Data.Trigger.ID 0 }}Create{{ else }}Update{{ end }}</button>
<button id="button-run" onclick="window._ui.run(); return false">Test</button>
<div id="run-result"></div>
</div>
2024-04-29 08:36:13 +02:00
</div>
</form>
{{ end }}