Dashboard editing

This commit is contained in:
Magnus Åhall 2026-08-21 11:03:14 +02:00
parent c3fe5951d4
commit dc0ad136e6
6 changed files with 1596 additions and 65 deletions

View file

@ -7,12 +7,14 @@ import (
// Standard
"context"
"encoding/json"
)
type WidgetType int
const (
WIDGET_LABEL WidgetType = iota
WIDGET_SPACE WidgetType = iota
WIDGET_LABEL
WIDGET_ONOFF
)
@ -48,3 +50,20 @@ func DashboardGet(name string) (dashboard Dashboard, err error) {
return
}
func DashboardUpdate(dashboard Dashboard) error {
widgets, _ := json.Marshal(dashboard.Widgets)
_, err := db.Exec(
context.Background(),
`UPDATE dashboard SET name=$2, widgets=$3 WHERE id=$1`,
dashboard.ID,
dashboard.Name,
widgets,
)
if err != nil {
return werr.Wrap(err)
}
return nil
}