Charts: color picker for loadpoints and consumers (#30021)

This commit is contained in:
Michael Geers 2026-05-20 12:47:19 +02:00 • committed by GitHub
parent 41c169ee9a
commit 62ecd175a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 994 additions and 144 deletions

30
ui/colors.go Normal file
View file

@ -0,0 +1,30 @@
// Package ui persists UI-only state (color overrides, etc.).
package ui
import (
"maps"
"sync"
"github.com/evcc-io/evcc/core/keys"
"github.com/evcc-io/evcc/server/db/settings"
)
var colorsMu sync.RWMutex
// GetDeviceColors returns the persisted title→hex map (never nil).
func GetDeviceColors() map[string]string {
colorsMu.RLock()
defer colorsMu.RUnlock()
m := map[string]string{}
_ = settings.Json(keys.DeviceColors, &m)
return m
}
// SaveDeviceColors persists the title→hex map.
func SaveDeviceColors(m map[string]string) error {
colorsMu.Lock()
defer colorsMu.Unlock()
clean := make(map[string]string, len(m))
maps.Copy(clean, m)
return settings.SetJson(keys.DeviceColors, clean)
}