smon/views/pages/triggers.gotmpl

69 lines
1.6 KiB
Go Template
Raw Permalink Normal View History

2024-04-29 08:36:13 +02:00
{{ define "page" }}
{{ block "page_label" . }}{{end}}
{{ $version := .VERSION }}
2024-06-01 09:18:56 +02:00
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/triggers.css">
2024-04-29 08:36:13 +02:00
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}`
})
}
2024-06-01 09:18:56 +02:00
function deleteTrigger(triggerID, name) {
if (!confirm(`Sure you want to delete '${name}'?`))
return
location.href = `/trigger/delete/${triggerID}`
}
2024-05-30 15:06:41 +02:00
</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 }}
2024-06-02 09:17:50 +02:00
{{ if eq .ID 0 }}
{{ continue }}
{{ end }}
2024-04-29 08:36:13 +02:00
<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 }}
2024-06-01 09:18:56 +02:00
<div class="trigger">
<img src="/images/{{ $version }}/triggers.svg">
<div class="label"><a href="/trigger/edit/{{ .ID }}">{{ .Name }}</a></div>
<img src="/images/{{ $version }}/delete.svg" onclick="deleteTrigger({{ .ID }}, '{{ .Name }}')">
</div>
2024-04-29 08:36:13 +02:00
{{ end }}
</div>
</div>
{{ end }}
</div>
{{ end }}
</div>
{{ end }}