|
@ -4,6 +4,7 @@ import ( |
|
|
"git.aiterp.net/lucifer3/server/device" |
|
|
"git.aiterp.net/lucifer3/server/device" |
|
|
"git.aiterp.net/lucifer3/server/effects" |
|
|
"git.aiterp.net/lucifer3/server/effects" |
|
|
"git.aiterp.net/lucifer3/server/events" |
|
|
"git.aiterp.net/lucifer3/server/events" |
|
|
|
|
|
"git.aiterp.net/lucifer3/server/internal/color" |
|
|
"git.aiterp.net/lucifer3/server/internal/gentools" |
|
|
"git.aiterp.net/lucifer3/server/internal/gentools" |
|
|
"github.com/google/uuid" |
|
|
"github.com/google/uuid" |
|
|
) |
|
|
) |
|
@ -25,6 +26,7 @@ func (d *Data) WithPatch(patches ...Patch) Data { |
|
|
gentools.ApplyUpdatePtr(&pd.HWMetadata, patch.Device.HWMetadata) |
|
|
gentools.ApplyUpdatePtr(&pd.HWMetadata, patch.Device.HWMetadata) |
|
|
gentools.ApplyUpdatePtr(&pd.DesiredState, patch.Device.DesiredState) |
|
|
gentools.ApplyUpdatePtr(&pd.DesiredState, patch.Device.DesiredState) |
|
|
gentools.ApplyUpdatePtr(&pd.Assignment, patch.Device.Assignment) |
|
|
gentools.ApplyUpdatePtr(&pd.Assignment, patch.Device.Assignment) |
|
|
|
|
|
gentools.ApplyUpdatePtr(&pd.ActiveColorRGB, patch.Device.ActiveColorRGB) |
|
|
|
|
|
|
|
|
if patch.Device.AddAlias != nil { |
|
|
if patch.Device.AddAlias != nil { |
|
|
pd.Aliases = append(pd.Aliases[:0:0], pd.Aliases...) |
|
|
pd.Aliases = append(pd.Aliases[:0:0], pd.Aliases...) |
|
@ -42,6 +44,9 @@ func (d *Data) WithPatch(patches ...Patch) Data { |
|
|
if patch.Device.ClearAssignment { |
|
|
if patch.Device.ClearAssignment { |
|
|
pd.Assignment = nil |
|
|
pd.Assignment = nil |
|
|
} |
|
|
} |
|
|
|
|
|
if patch.Device.ClearActiveColorRGB { |
|
|
|
|
|
pd.ActiveColorRGB = nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if patch.Device.Delete { |
|
|
if patch.Device.Delete { |
|
|
delete(newData.Devices, pd.ID) |
|
|
delete(newData.Devices, pd.ID) |
|
@ -106,6 +111,7 @@ type Device struct { |
|
|
Name string `json:"name"` |
|
|
Name string `json:"name"` |
|
|
HWMetadata *events.HardwareMetadata `json:"hwMetadata"` |
|
|
HWMetadata *events.HardwareMetadata `json:"hwMetadata"` |
|
|
HWState *events.HardwareState `json:"hwState"` |
|
|
HWState *events.HardwareState `json:"hwState"` |
|
|
|
|
|
ActiveColorRGB *color.RGB `json:"activeColorRgb"` |
|
|
DesiredState *device.State `json:"desiredState"` |
|
|
DesiredState *device.State `json:"desiredState"` |
|
|
Aliases []string `json:"aliases"` |
|
|
Aliases []string `json:"aliases"` |
|
|
Assignment *uuid.UUID `json:"assignment"` |
|
|
Assignment *uuid.UUID `json:"assignment"` |
|
|