Add admin-settable MOTD, rewrite existing warning system to use it
Some checks failed
ecodash/pipeline/head There was a failure building this commit

This commit is contained in:
MassiveBox 2023-10-31 23:59:09 +01:00
parent 4bf1455ba4
commit 8b81c41bd7
Signed by: massivebox
GPG key ID: 9B74D3A59181947D
6 changed files with 75 additions and 37 deletions

View file

@ -4,15 +4,15 @@
<a href="https://ecodash.xyz/docs/setup/admin-panel">Documentation</a>
</p>
{{if .Warning}}
<article class="card" style="background-color: {{if .Warning.IsSuccess}}#008000{{else}}#ff5050{{end}}; color: white">
<header>
<h3>{{.Warning.Header}}</h3>
</header>
<footer>
<p>{{.Warning.BodyHTML}}</p>
</footer>
</article>
{{if .Message}}
<article class="card {{.Message.Style}}">
<header>
<h3>{{.Message.Title}}</h3>
</header>
<footer>
<p>{{.Message.Content}}</p>
</footer>
</article>
{{end}}
<form action="./admin" method="POST">
@ -45,6 +45,16 @@
</select>
</label>
<label>Dashboard name <input type="text" name="name" value="{{.Config.Dashboard.Name}}"></label>
<label>MOTD title <input type="text" name="motd_title" value="{{if .Config.Dashboard.MOTD}}{{.Config.Dashboard.MOTD.Title}}{{end}}"></label>
<label>MOTD content <input type="text" name="motd_content" value="{{if .Config.Dashboard.MOTD}}{{.Config.Dashboard.MOTD.Content}}{{end}}"></label>
<label>MOTD style
<select name="motd_style">
<option value="" {{if .Config.Dashboard.MOTD}}{{if eq .Config.Dashboard.MOTD.Style ""}}selected{{end}}{{end}}>Default</option>
<option value="success" {{if .Config.Dashboard.MOTD}}{{if eq .Config.Dashboard.MOTD.Style "success"}}selected{{end}}{{end}}>Success</option>
<option value="warning" {{if .Config.Dashboard.MOTD}}{{if eq .Config.Dashboard.MOTD.Style "warning"}}selected{{end}}{{end}}>Warning</option>
<option value="error" {{if .Config.Dashboard.MOTD}}{{if eq .Config.Dashboard.MOTD.Style "error"}}selected{{end}}{{end}}>Error</option>
</select>
</label>
<input type="submit" placeholder="Submit" style="margin-top: 2em; width: 100%">
</form>

View file

@ -46,4 +46,14 @@ svg, footer img { width: 100% }
fill: white;
}
}
.success {
background-color: #008000; color: white
}
.warning {
background-color: #807a00; color: white
}
.error {
background-color: #800000; color: white
}

View file

@ -1,5 +1,16 @@
<script src="assets/chartjs/chart.js"></script>
{{if .MOTD}}
<article class="card {{.MOTD.Style}}">
<header>
<h3>{{.MOTD.Title}}</h3>
</header>
<footer>
<p>{{.MOTD.Content}}</p>
</footer>
</article>
{{end}}
<h1>Green report</h1>
<canvas id="report"></canvas>
@ -7,7 +18,6 @@
This server's energy statistics for the last eight days (current day included)
</p>
<div class="flex two">
<div>
<div class="home-cards card">