Wip problem
This commit is contained in:
parent
965e2daeb3
commit
ffe0c3def2
3 changed files with 61 additions and 22 deletions
19
main.go
19
main.go
|
|
@ -170,6 +170,13 @@ func entryDatapoint(w http.ResponseWriter, r *http.Request, sess *session.T) { /
|
|||
return
|
||||
}
|
||||
|
||||
var triggers []Trigger
|
||||
triggers, err = TriggersRetrieveByDatapoint(dpoint)
|
||||
for _, trigger := range triggers {
|
||||
trigger.Run()
|
||||
}
|
||||
|
||||
|
||||
j, _ := json.Marshal(struct{ OK bool }{true})
|
||||
w.Write(j)
|
||||
} // }}}
|
||||
|
|
@ -436,23 +443,13 @@ func pageTriggerRun(w http.ResponseWriter, r *http.Request, _ *session.T) { // {
|
|||
expr, _ := io.ReadAll(r.Body)
|
||||
trigger.Expression = string(expr)
|
||||
|
||||
datapoints := make(map[string]Datapoint)
|
||||
for _, dpname := range trigger.Datapoints {
|
||||
dp, err := DatapointRetrieve(0, dpname)
|
||||
if err != nil {
|
||||
httpError(w, we.Wrap(err).Log())
|
||||
return
|
||||
}
|
||||
datapoints[dpname] = dp
|
||||
}
|
||||
|
||||
resp := struct {
|
||||
OK bool
|
||||
Output any
|
||||
}{
|
||||
OK: true,
|
||||
}
|
||||
resp.Output, err = trigger.Run(datapoints)
|
||||
resp.Output, err = trigger.Run()
|
||||
if err != nil {
|
||||
we.Wrap(err).Log()
|
||||
httpError(w, err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue