UI Customize: add custom-theme flag for default theme (#33042)

This commit is contained in:
Michael Geers 2026-08-21 14:00:50 +02:00 • committed by GitHub
parent eeb2f593bf
commit a8c4dfd372
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 50 additions and 1 deletions

View file

@ -55,6 +55,7 @@ type Customization struct {
Website string
Email string
Phone string
Theme string
}
// NewHTTPd creates HTTP server with configured routes for loadpoint
@ -112,6 +113,12 @@ func NewHTTPd(addr string, hub *SocketHub, custom Customization) *HTTPd {
log.FATAL.Fatal("custom logo requires both light and dark variants")
}
switch custom.Theme {
case "", "auto", "light", "dark":
default:
log.FATAL.Fatalf("invalid custom theme: %s (expected auto, light, dark)", custom.Theme)
}
for path, file := range map[string]string{
"/custom-logo-light": custom.LogoLight,
"/custom-logo-dark": custom.LogoDark,

View file

@ -59,6 +59,7 @@ func globalsJsHandler(custom Customization) http.HandlerFunc {
Website string `json:"customWebsite"`
Email string `json:"customEmail"`
Phone string `json:"customPhone"`
Theme string `json:"customTheme"`
}{
Version: util.Version,
CustomCss: custom.Css != "",
@ -67,6 +68,7 @@ func globalsJsHandler(custom Customization) http.HandlerFunc {
Website: custom.Website,
Email: custom.Email,
Phone: custom.Phone,
Theme: custom.Theme,
}
return func(w http.ResponseWriter, r *http.Request) {