Dashboard editing
This commit is contained in:
parent
c3fe5951d4
commit
dc0ad136e6
6 changed files with 1596 additions and 65 deletions
21
dashboard.go
21
dashboard.go
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue