Refresh frontend datasourceSrv after datasource update, no longer need to reload the page to use a newly added or updated datasource, #1493

This commit is contained in:
Torkel Ödegaard
2015-02-18 14:06:44 +01:00
parent 4ed54f6aa9
commit 60ae4afe87
8 changed files with 94 additions and 99 deletions
+1
View File
@@ -78,6 +78,7 @@ func Register(r *macaron.Macaron) {
r.Get("/:id", GetDataSourceById)
}, reqAccountAdmin)
r.Get("/frontend/settings/", GetFrontendSettings)
r.Any("/datasources/proxy/:id/*", reqSignedIn, ProxyDataSourceRequest)
// Dashboard
+11 -1
View File
@@ -9,7 +9,7 @@ import (
"github.com/grafana/grafana/pkg/setting"
)
func getFrontendSettings(c *middleware.Context) (map[string]interface{}, error) {
func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, error) {
accountDataSources := make([]*m.DataSource, 0)
if c.IsSignedIn {
@@ -71,3 +71,13 @@ func getFrontendSettings(c *middleware.Context) (map[string]interface{}, error)
return jsonObj, nil
}
func GetFrontendSettings(c *middleware.Context) {
settings, err := getFrontendSettingsMap(c)
if err != nil {
c.JsonApiErr(400, "Failed to get frontend settings", err)
return
}
c.JSON(200, settings)
}
+1 -1
View File
@@ -7,7 +7,7 @@ import (
)
func setIndexViewData(c *middleware.Context) error {
settings, err := getFrontendSettings(c)
settings, err := getFrontendSettingsMap(c)
if err != nil {
return err
}