smon/views/pages/triggers.gotmpl

60 lines
1.2 KiB
Go Template
Raw Normal View History

2024-04-29 08:36:13 +02:00
{{ define "page" }}
{{ block "page_label" . }}{{end}}
{{ $version := .VERSION }}
2024-05-30 15:06:41 +02:00
<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>
2024-04-29 08:36:13 +02:00
<div id="areas">
{{ range .Data.Areas }}
<div class="area">
<div class="name">{{ .Name }}</div>
{{ range .SortedSections }}
<div class="section">
2024-05-01 10:02:33 +02:00
<div class="create">
<div class="name">{{ .Name }}</div>
2024-05-30 15:06:41 +02:00
<div class="new"><a onclick="createTrigger({{ .ID }})">+</a></div>
2024-05-01 10:02:33 +02:00
</div>
2024-04-29 08:36:13 +02:00
<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 }}