UI Customize: add custom-theme flag for default theme (#33042)
This commit is contained in:
parent
eeb2f593bf
commit
a8c4dfd372
7 changed files with 50 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue