Add update of timezone setting
This commit is contained in:
parent
65c0984348
commit
22f6b6a413
3 changed files with 33 additions and 1 deletions
20
main.go
20
main.go
|
|
@ -19,6 +19,7 @@ import (
|
|||
"io/fs"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"slices"
|
||||
|
|
@ -149,6 +150,7 @@ func main() { // {{{
|
|||
|
||||
service.Register("/configuration", false, false, pageConfiguration)
|
||||
service.Register("/configuration/theme", false, false, actionConfigurationTheme)
|
||||
service.Register("/configuration/timezone", false, false, actionConfigurationTimezone)
|
||||
service.Register("/entry/{datapoint}", false, false, actionEntryDatapoint)
|
||||
|
||||
go nodataLoop()
|
||||
|
|
@ -1021,3 +1023,21 @@ func actionConfigurationTheme(w http.ResponseWriter, r *http.Request, _ *session
|
|||
w.Header().Add("Location", "/configuration")
|
||||
w.WriteHeader(302)
|
||||
} // }}}
|
||||
func actionConfigurationTimezone(w http.ResponseWriter, r *http.Request, _ *session.T) { // {{{
|
||||
timezone := r.FormValue("timezone")
|
||||
|
||||
_, err := time.LoadLocation(timezone)
|
||||
if err != nil {
|
||||
pageError(w, "/configuration", werr.Wrap(err).Log())
|
||||
return
|
||||
}
|
||||
|
||||
err = smonConfig.SetTimezone(timezone)
|
||||
if err != nil {
|
||||
pageError(w, "/configuration", werr.Wrap(err).Log())
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Add("Location", "/configuration")
|
||||
w.WriteHeader(302)
|
||||
} // }}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue