diff --git a/configuration.go b/configuration.go index 889b2fe..5cb9b7c 100644 --- a/configuration.go +++ b/configuration.go @@ -38,3 +38,9 @@ func SmonConfigInit() (err error) { 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 +} diff --git a/main.go b/main.go index 21dcedf..0e8f8ff 100644 --- a/main.go +++ b/main.go @@ -148,6 +148,7 @@ func main() { // {{{ service.Register("/trigger/delete/{id}", false, false, actionTriggerDelete) service.Register("/configuration", false, false, pageConfiguration) + service.Register("/configuration/theme", false, false, actionConfigurationTheme) service.Register("/entry/{datapoint}", false, false, actionEntryDatapoint) go nodataLoop() @@ -955,3 +956,14 @@ func pageConfiguration(w http.ResponseWriter, _ *http.Request, _ *session.T) { / 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) +} // }}} diff --git a/static/css/default_light/main.css b/static/css/default_light/main.css index d672af0..ab1f58e 100644 --- a/static/css/default_light/main.css +++ b/static/css/default_light/main.css @@ -128,6 +128,7 @@ body { h1, h2 { margin-bottom: 4px; + margin-top: 32px; } h1:first-child, h2:first-child { diff --git a/static/css/gruvbox/main.css b/static/css/gruvbox/main.css index 8071027..5c174e2 100644 --- a/static/css/gruvbox/main.css +++ b/static/css/gruvbox/main.css @@ -128,6 +128,7 @@ body { h1, h2 { margin-bottom: 4px; + margin-top: 32px; } h1:first-child, h2:first-child { diff --git a/static/less/main.less b/static/less/main.less index 17ad78c..b0c4729 100644 --- a/static/less/main.less +++ b/static/less/main.less @@ -158,6 +158,7 @@ body { h1, h2 { margin-bottom: 4px; + margin-top: 32px; &:first-child { margin-top: 0px; } diff --git a/views/pages/configuration.gotmpl b/views/pages/configuration.gotmpl index 31e195b..5c1fbaa 100644 --- a/views/pages/configuration.gotmpl +++ b/views/pages/configuration.gotmpl @@ -93,4 +93,12 @@ {{ end }} +

Theme

+
+ +
+ {{ end }}