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)
|
existing.Publish(conns, OnChange)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Create new
|
ndp := Datapoint{
|
||||||
current.Datapoints[part] = &Datapoint{
|
|
||||||
Uuid: uuid.New(),
|
Uuid: uuid.New(),
|
||||||
CreateDateTime: time.Now().UnixMilli(),
|
CreateDateTime: time.Now().UnixMilli(),
|
||||||
Subscriptions: InitSubscribtion(),
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
created = append(created, json_dataModels.Set{
|
created = append(created, json_dataModels.Set{
|
||||||
Uuid: current.Uuid,
|
Uuid: ndp.Uuid,
|
||||||
Path: current.Path,
|
Path: ndp.Path,
|
||||||
Type: current.Type,
|
Type: ndp.Type,
|
||||||
Value: current.Value,
|
Value: ndp.Value,
|
||||||
Rights: current.ReadWrite,
|
Rights: ndp.ReadWrite,
|
||||||
Driver: dp.Driver,
|
Driver: dp.Driver,
|
||||||
})
|
})
|
||||||
if publish {
|
if publish {
|
||||||
@@ -246,6 +247,13 @@ func (d *Datapoint) UpdateDatapointValue(conns *serverModels.Connections, value
|
|||||||
return nil
|
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) {
|
func (d *Datapoint) RemoveDatapoint(conns *serverModels.Connections, set json_dataModels.Set) (json_dataModels.Set, error) {
|
||||||
parts := strings.Split(set.Path, ":")
|
parts := strings.Split(set.Path, ":")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user