smon/views/pages/configuration.gotmpl

145 lines
4.2 KiB
Go Template
Raw Permalink Normal View History

2024-04-29 08:36:13 +02:00
{{ define "page" }}
2024-06-02 09:17:50 +02:00
{{ $version := .VERSION }}
2024-06-25 09:49:09 +02:00
{{ $theme := .CONFIG.THEME }}
2024-06-25 08:59:07 +02:00
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/{{ .CONFIG.THEME }}/configuration.css">
<script type="text/javascript">
function newArea() {
let name = prompt("Area name")
if (name === null)
return
if (name.trim() == '') {
alert("Name can't be empty")
return
}
location.href = `/area/new/${name.trim()}`
}
function renameArea(id, name) {
const newName = prompt('Rename area', name)
if (newName === null)
return
if (newName.trim() == '') {
alert("Name can't be empty")
return
}
location.href = `/area/rename/${id}/${newName.trim()}`
}
function newSection(areaID) {
let name = prompt("Section name")
if (name === null)
return
if (name.trim() == '') {
alert("Name can't be empty")
return
}
location.href = `/section/new/${areaID}/${name.trim()}`
}
function renameSection(id, name) {
const newName = prompt('Rename section', name)
if (newName === null)
return
if (newName.trim() == '') {
alert("Name can't be empty")
return
}
location.href = `/section/rename/${id}/${newName.trim()}`
}
2024-06-02 09:17:50 +02:00
function deleteArea(id, name) {
if (!confirm(`Are you sure you want to delete '${name}'?\nEverything in it will be deleted!`))
return
location.href = `/area/delete/${id}`
}
function deleteSection(id, name) {
if (!confirm(`Are you sure you want to delete '${name}'?\nEverything in it will be deleted!`))
return
location.href = `/section/delete/${id}`
}
2024-06-28 15:28:52 +02:00
function newNotification() {
const select = document.getElementById('notification-create-type')
const nType = select.value
location.href = `/configuration/notification?type=${nType}`
}
2024-06-28 17:18:08 +02:00
function deleteNotification(prio) {
if (!confirm(`Are you sure you want to delete notification with prio ${prio}?`))
return
location.href = `/configuration/notification/delete/${prio}`;
}
</script>
2024-04-29 08:36:13 +02:00
{{ block "page_label" . }}{{end}}
<h1>Areas</h1>
<a href="#" onclick="newArea()">Create</a>
2024-04-29 08:36:13 +02:00
<div id="areas">
{{ range .Data.Areas }}
<div class="area">
2024-06-02 09:17:50 +02:00
<div class="name">
<div onclick="renameArea({{ .ID }}, '{{ .Name }}')">{{ .Name }}</div>
2024-06-25 09:49:09 +02:00
<img class="delete" src="/images/{{ $version }}/{{ $theme }}/delete_white.svg" onclick="deleteArea({{ .ID }}, '{{ .Name }}')">
2024-06-02 09:17:50 +02:00
</div>
<div style="margin: 8px 16px">
<a href="#" onclick="newSection({{ .ID }})">Create</a>
</div>
2024-04-29 08:36:13 +02:00
{{ range .SortedSections }}
2024-06-02 09:17:50 +02:00
{{ if eq .ID 0 }}
{{ continue }}
{{ end }}
2024-05-28 07:37:22 +02:00
<div class="section configuration">
<div class="name" onclick="renameSection({{ .ID }}, {{ .Name }})">{{ .Name }}</div>
2024-06-25 09:49:09 +02:00
<img src="/images/{{ $version }}/{{ $theme }}/delete.svg" onclick="deleteSection({{ .ID }}, '{{ .Name }}')">
2024-04-29 08:36:13 +02:00
</div>
{{ end }}
</div>
{{ end }}
</div>
2024-06-25 09:18:15 +02:00
<h1>Theme</h1>
2024-06-27 10:02:11 +02:00
<form action="/configuration/theme">
2024-06-25 09:18:15 +02:00
<select name="theme" onchange="console.log(this.form.submit())">
<option value="default_light" {{ if eq "default_light" .CONFIG.THEME }}selected{{ end }}>Default light</option>
<option value="gruvbox" {{ if eq "gruvbox" .CONFIG.THEME }}selected{{ end }}>Gruvbox</option>
</select>
</form>
2024-06-27 10:02:11 +02:00
<h1>Timezone</h1>
<form action="/configuration/timezone" method="post">
<input name="timezone" type="text" value="{{ .CONFIG.TIMEZONE }}">
<button style="margin-left: 8px;">Update</button>
</form>
2024-06-28 15:28:52 +02:00
<h1>Notifications</h1>
<select id="notification-create-type">
{{ range .Data.AvailableServices }}
<option>{{ .GetType }}</option>
{{ end }}
</select>
<button onclick="newNotification()">Create</button>
<div id="services">
<div class="header">Prio</div>
<div class="header">Type</div>
<div class="header">Target</div>
2024-06-28 17:18:08 +02:00
<div></div>
2024-06-28 15:28:52 +02:00
<div class="line"></div>
{{ range .Data.NotificationServices }}
<div><a href="/configuration/notification?prio={{ .GetPrio }}">{{ .GetPrio }}</a></div>
<div><a href="/configuration/notification?prio={{ .GetPrio }}">{{ .GetType }}</a></div>
<div><a href="/configuration/notification?prio={{ .GetPrio }}">{{ .String }}</a></div>
2024-06-28 17:18:08 +02:00
<div><img onclick="deleteNotification({{ .GetPrio }})" class="delete" src="/images/{{ $version }}/{{ $theme }}/delete.svg"></div>
2024-06-28 15:28:52 +02:00
{{ end }}
</div>
2024-04-29 08:36:13 +02:00
{{ end }}