Live: broadcast events when dashboard is saved (#27583)
Co-authored-by: kay delaney <45561153+kaydelaney@users.noreply.github.com> Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
This commit is contained in:
co-authored by
kay delaney
Torkel Ödegaard
parent
44c9aea28c
commit
8a5fc00330
@@ -262,6 +262,17 @@ func (hs *HTTPServer) PostDashboard(c *models.ReqContext, cmd models.SaveDashboa
|
||||
}
|
||||
}
|
||||
|
||||
// Tell everyone listening that the dashboard changed
|
||||
if hs.Live != nil {
|
||||
err := hs.Live.GrafanaScope.Dashboards.DashboardSaved(
|
||||
dashboard.Uid,
|
||||
c.UserId,
|
||||
)
|
||||
if err != nil {
|
||||
hs.log.Warn("unable to broadcast save event", "uid", dashboard.Uid, "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
c.TimeRequest(metrics.MApiDashboardSave)
|
||||
return JSON(200, util.DynMap{
|
||||
"status": "success",
|
||||
|
||||
@@ -79,15 +79,11 @@ func (hs *HTTPServer) Init() error {
|
||||
|
||||
// Set up a websocket broker
|
||||
if hs.Cfg.IsLiveEnabled() { // feature flag
|
||||
node, err := live.InitalizeBroker()
|
||||
node, err := live.InitializeBroker()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
hs.Live = node
|
||||
|
||||
// Spit random walk to example
|
||||
go live.RunRandomCSV(hs.Live, "grafana/testdata/random-2s-stream", 2000, 0)
|
||||
go live.RunRandomCSV(hs.Live, "grafana/testdata/random-flakey-stream", 400, .6)
|
||||
}
|
||||
|
||||
hs.macaron = hs.newMacaron()
|
||||
|
||||
Reference in New Issue
Block a user