Added theme to configuration page
This commit is contained in:
parent
c77737a20e
commit
54ba7b160b
@ -38,3 +38,9 @@ func SmonConfigInit() (err error) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cfg *Configuration) SetTheme(theme string) (err error) {
|
||||||
|
cfg.Settings["THEME"] = theme
|
||||||
|
_, err = service.Db.Conn.Exec(`UPDATE public.configuration SET value=$1 WHERE setting='THEME'`, theme)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
12
main.go
12
main.go
@ -148,6 +148,7 @@ func main() { // {{{
|
|||||||
service.Register("/trigger/delete/{id}", false, false, actionTriggerDelete)
|
service.Register("/trigger/delete/{id}", false, false, actionTriggerDelete)
|
||||||
|
|
||||||
service.Register("/configuration", false, false, pageConfiguration)
|
service.Register("/configuration", false, false, pageConfiguration)
|
||||||
|
service.Register("/configuration/theme", false, false, actionConfigurationTheme)
|
||||||
service.Register("/entry/{datapoint}", false, false, actionEntryDatapoint)
|
service.Register("/entry/{datapoint}", false, false, actionEntryDatapoint)
|
||||||
|
|
||||||
go nodataLoop()
|
go nodataLoop()
|
||||||
@ -955,3 +956,14 @@ func pageConfiguration(w http.ResponseWriter, _ *http.Request, _ *session.T) { /
|
|||||||
|
|
||||||
page.Render(w)
|
page.Render(w)
|
||||||
} // }}}
|
} // }}}
|
||||||
|
func actionConfigurationTheme(w http.ResponseWriter, r *http.Request, _ *session.T) { // {{{
|
||||||
|
theme := r.FormValue("theme")
|
||||||
|
err := smonConfig.SetTheme(theme)
|
||||||
|
if err != nil {
|
||||||
|
httpError(w, werr.Wrap(err).Log())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Header().Add("Location", "/configuration")
|
||||||
|
w.WriteHeader(302)
|
||||||
|
} // }}}
|
||||||
|
@ -128,6 +128,7 @@ body {
|
|||||||
h1,
|
h1,
|
||||||
h2 {
|
h2 {
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
|
margin-top: 32px;
|
||||||
}
|
}
|
||||||
h1:first-child,
|
h1:first-child,
|
||||||
h2:first-child {
|
h2:first-child {
|
||||||
|
@ -128,6 +128,7 @@ body {
|
|||||||
h1,
|
h1,
|
||||||
h2 {
|
h2 {
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
|
margin-top: 32px;
|
||||||
}
|
}
|
||||||
h1:first-child,
|
h1:first-child,
|
||||||
h2:first-child {
|
h2:first-child {
|
||||||
|
@ -158,6 +158,7 @@ body {
|
|||||||
h1,
|
h1,
|
||||||
h2 {
|
h2 {
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
|
margin-top: 32px;
|
||||||
&:first-child {
|
&:first-child {
|
||||||
margin-top: 0px;
|
margin-top: 0px;
|
||||||
}
|
}
|
||||||
|
@ -93,4 +93,12 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<h1>Theme</h1>
|
||||||
|
<form action="/configuration/theme" id="theme-set">
|
||||||
|
<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>
|
||||||
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
Loading…
Reference in New Issue
Block a user