Commit e8049439 by Torkel Ödegaard

Merge branch 'always_displayed_datasources' of https://github.com/ctide/grafana…

Merge branch 'always_displayed_datasources' of https://github.com/ctide/grafana into ctide-always_displayed_datasources
parents b3df1aa9 d12dc2bf
...@@ -102,18 +102,14 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro ...@@ -102,18 +102,14 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
datasources[ds.Name] = dsMap datasources[ds.Name] = dsMap
} }
// add grafana backend data source for _, ds := range plugins.DataSources {
grafanaDatasourceMeta, _ := plugins.DataSources["grafana"] if ds.AlwaysDisplay {
datasources["-- Grafana --"] = map[string]interface{}{ datasources[ds.Name] = map[string]interface{}{
"type": "grafana", "type": ds.Type,
"name": "-- Grafana --", "name": ds.Name,
"meta": grafanaDatasourceMeta, "meta": plugins.DataSources[ds.Id],
} }
}
// add mixed backend data source
datasources["-- Mixed --"] = map[string]interface{}{
"type": "mixed",
"meta": plugins.DataSources["mixed"],
} }
if defaultDatasource == "" { if defaultDatasource == "" {
......
...@@ -4,12 +4,13 @@ import "encoding/json" ...@@ -4,12 +4,13 @@ import "encoding/json"
type DataSourcePlugin struct { type DataSourcePlugin struct {
FrontendPluginBase FrontendPluginBase
Annotations bool `json:"annotations"` Annotations bool `json:"annotations"`
Metrics bool `json:"metrics"` Metrics bool `json:"metrics"`
Alerting bool `json:"alerting"` Alerting bool `json:"alerting"`
BuiltIn bool `json:"builtIn"` BuiltIn bool `json:"builtIn"`
Mixed bool `json:"mixed"` Mixed bool `json:"mixed"`
App string `json:"app"` AlwaysDisplay bool `json:"alwaysDisplay"`
App string `json:"app"`
} }
func (p *DataSourcePlugin) Load(decoder *json.Decoder, pluginDir string) error { func (p *DataSourcePlugin) Load(decoder *json.Decoder, pluginDir string) error {
......
{ {
"type": "datasource", "type": "datasource",
"name": "Grafana", "name": "-- Grafana --",
"id": "grafana", "id": "grafana",
"builtIn": true, "builtIn": true,
"annotations": true, "annotations": true,
"alwaysDisplay": true,
"metrics": true "metrics": true
} }
{ {
"type": "datasource", "type": "datasource",
"name": "Mixed datasource", "name": "-- Mixed --",
"id": "mixed", "id": "mixed",
"builtIn": true, "builtIn": true,
"mixed": true, "mixed": true,
"alwaysDisplay": true,
"metrics": true "metrics": true
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment