Compare commits
3 Commits
3227c22de1
...
5d24baedac
Author | SHA1 | Date | |
---|---|---|---|
|
5d24baedac | ||
|
fefd4af10c | ||
|
0de7ca4bef |
@ -54,14 +54,14 @@ func (dp DatapointValue) Value() any { // {{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if dp.ValueDateTime.Valid {
|
if dp.ValueDateTime.Valid {
|
||||||
return dp.ValueDateTime.Time
|
return dp.ValueDateTime.Time.In(smonConfig.timezoneLocation)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
} // }}}
|
} // }}}
|
||||||
func (dp DatapointValue) FormattedTime() string { // {{{
|
func (dp DatapointValue) FormattedTime() string { // {{{
|
||||||
if dp.ValueDateTime.Valid {
|
if dp.ValueDateTime.Valid {
|
||||||
return dp.ValueDateTime.Time.Format("2006-01-02 15:04:05")
|
return dp.ValueDateTime.Time.In(smonConfig.timezoneLocation).Format("2006-01-02 15:04:05")
|
||||||
}
|
}
|
||||||
return "invalid time"
|
return "invalid time"
|
||||||
} // }}}
|
} // }}}
|
||||||
|
19
main.go
19
main.go
@ -29,7 +29,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const VERSION = "v30"
|
const VERSION = "v31"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logger *slog.Logger
|
logger *slog.Logger
|
||||||
@ -951,7 +951,22 @@ func actionTriggerDatapointAdd(w http.ResponseWriter, r *http.Request, _ *sessio
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
j, _ := json.Marshal(struct{ OK bool }{OK: true})
|
// Also retrieve the datapoint to get the latest value
|
||||||
|
// for immediate presentation when added.
|
||||||
|
dp, err := DatapointRetrieve(0, dpName)
|
||||||
|
if err != nil {
|
||||||
|
httpError(w, werr.Wrap(err).WithData(dpName).Log())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dp.LastDatapointValue.TemplateValue = dp.LastDatapointValue.Value()
|
||||||
|
j, _ := json.Marshal(
|
||||||
|
struct {
|
||||||
|
OK bool
|
||||||
|
Datapoint Datapoint
|
||||||
|
}{
|
||||||
|
true,
|
||||||
|
dp,
|
||||||
|
})
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", "application/json")
|
||||||
w.Write(j)
|
w.Write(j)
|
||||||
} // }}}
|
} // }}}
|
||||||
|
@ -158,7 +158,7 @@ export class Trigger {
|
|||||||
alert(json.Error)
|
alert(json.Error)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.datapoints[dp.Name] = dp
|
this.datapoints[dp.Name] = json.Datapoint
|
||||||
})
|
})
|
||||||
}//}}}
|
}//}}}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user