Merge branch 'asmodeus' of git.aiterp.net:lucifer/new-server into asmodeus

This commit is contained in:
2021-05-24 08:30:36 +02:00
21 changed files with 366 additions and 12 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ type DriverKind string
var (
DTHue DriverKind = "Hue"
DTNanoLeaf DriverKind = "NanoLeaf"
DTNanoLeaf DriverKind = "Nanoleaf"
)
var ValidDriverKinds = []DriverKind{
+26
View File
@@ -0,0 +1,26 @@
package models
import (
"context"
"strings"
)
type ColorPreset struct {
ID int `json:"id"`
Name string `json:"name"`
Value ColorValue `json:"value"`
}
type ColorPresetRepository interface {
Find(ctx context.Context, id int) (ColorPreset, error)
FetchAll(ctx context.Context) ([]ColorPreset, error)
Save(ctx context.Context, preset *ColorPreset) error
Delete(ctx context.Context, preset *ColorPreset) error
}
func (c *ColorPreset) Validate() {
c.Name = strings.Trim(c.Name, " \t\n")
if len(c.Name) == 0 {
c.Name = c.Value.String()
}
}
+1
View File
@@ -8,6 +8,7 @@ var ErrBadInput = errors.New("bad input")
var ErrBadColor = errors.New("bad color")
var ErrInternal = errors.New("internal")
var ErrUnknownColorFormat = errors.New("unknown color format")
var ErrUnknownDriver = errors.New("unknown driver")
var ErrMissingToken = errors.New("driver is missing authentication information")
var ErrIncorrectToken = errors.New("driver is not accepting authentication information")