smon/views/pages/triggers.gotmpl
2024-05-30 15:06:41 +02:00

60 lines
1.2 KiB
Go Template

{{ define "page" }}
{{ block "page_label" . }}{{end}}
{{ $version := .VERSION }}
<script type="text/javascript">
function createTrigger(sectionID) {
let name = prompt("Trigger name")
if (name === null)
return
if (name.trim() == "") {
alert('A name is required')
return
}
fetch(`/trigger/create/${sectionID}/${encodeURIComponent(name)}`)
.then(data=>data.json())
.then(json=>{
if (!json.OK) {
alert(json.Error)
return
}
location.href = `/trigger/edit/${json.Trigger.ID}`
})
}
</script>
<div id="areas">
{{ range .Data.Areas }}
<div class="area">
<div class="name">{{ .Name }}</div>
{{ range .SortedSections }}
<div class="section">
<div class="create">
<div class="name">{{ .Name }}</div>
<div class="new"><a onclick="createTrigger({{ .ID }})">+</a></div>
</div>
<div class="triggers">
{{ range .SortedTriggers }}
{{ if eq .Name "" }}
{{ continue }}
{{ end }}
<a href="/trigger/edit/{{ .ID }}">
<div class="trigger">
<img src="/images/{{ $version }}/triggers.svg">
<div class="label">{{ .Name }}</div>
</div>
</a>
{{ end }}
</div>
</div>
{{ end }}
</div>
{{ end }}
</div>
{{ end }}