fix wrong return of created datapoints
This commit is contained in:
@@ -122,22 +122,23 @@ func (d *Datapoint) CreateDatapoints(conns *serverModels.Connections, sets ...js
|
||||
existing.Publish(conns, OnChange)
|
||||
}
|
||||
} else {
|
||||
// Create new
|
||||
current.Datapoints[part] = &Datapoint{
|
||||
ndp := Datapoint{
|
||||
Uuid: uuid.New(),
|
||||
CreateDateTime: time.Now().UnixMilli(),
|
||||
Subscriptions: InitSubscribtion(),
|
||||
}
|
||||
publish, err := current.Datapoints[part].Set(strings.Join(parts, ":"), dp)
|
||||
// Create new
|
||||
current.Datapoints[part] = &ndp
|
||||
publish, err := ndp.Set(strings.Join(parts, ":"), dp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
created = append(created, json_dataModels.Set{
|
||||
Uuid: current.Uuid,
|
||||
Path: current.Path,
|
||||
Type: current.Type,
|
||||
Value: current.Value,
|
||||
Rights: current.ReadWrite,
|
||||
Uuid: ndp.Uuid,
|
||||
Path: ndp.Path,
|
||||
Type: ndp.Type,
|
||||
Value: ndp.Value,
|
||||
Rights: ndp.ReadWrite,
|
||||
Driver: dp.Driver,
|
||||
})
|
||||
if publish {
|
||||
@@ -246,6 +247,13 @@ func (d *Datapoint) UpdateDatapointValue(conns *serverModels.Connections, value
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Datapoint) UpdateValue(conns *serverModels.Connections, value any) error {
|
||||
d.Value = d.Type.ConvertValue(value)
|
||||
d.UpdateDateTime = time.Now().UnixMilli()
|
||||
d.Publish(conns, OnChange)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Datapoint) RemoveDatapoint(conns *serverModels.Connections, set json_dataModels.Set) (json_dataModels.Set, error) {
|
||||
parts := strings.Split(set.Path, ":")
|
||||
|
||||
|
Reference in New Issue
Block a user