Charts: color picker for loadpoints and consumers (#30021)
This commit is contained in:
parent
41c169ee9a
commit
62ecd175a6
27 changed files with 994 additions and 144 deletions
30
ui/colors.go
Normal file
30
ui/colors.go
Normal 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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue