Commit 6ee0f2c6 by Torkel Ödegaard

feat(mixed data source queries): lots of minor polish to new mixed data source…

feat(mixed data source queries): lots of minor polish to new mixed data source and all the changes it has required, #436
parent 56d5b0b1
...@@ -115,7 +115,7 @@ func GetDataSourcePlugins(c *middleware.Context) { ...@@ -115,7 +115,7 @@ func GetDataSourcePlugins(c *middleware.Context) {
dsList := make(map[string]interface{}) dsList := make(map[string]interface{})
for key, value := range plugins.DataSources { for key, value := range plugins.DataSources {
if value.(map[string]interface{})["hide"] == nil { if value.(map[string]interface{})["builtIn"] == nil {
dsList[key] = value dsList[key] = value
} }
} }
......
...@@ -86,12 +86,13 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro ...@@ -86,12 +86,13 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
// add grafana backend data source // add grafana backend data source
grafanaDatasourceMeta, _ := plugins.DataSources["grafana"] grafanaDatasourceMeta, _ := plugins.DataSources["grafana"]
datasources["grafana"] = map[string]interface{}{ datasources["-- Grafana --"] = map[string]interface{}{
"type": "grafana", "type": "grafana",
"meta": grafanaDatasourceMeta, "meta": grafanaDatasourceMeta,
} }
// add mixed backend data source // add mixed backend data source
datasources["mixed"] = map[string]interface{}{ datasources["-- Mixed --"] = map[string]interface{}{
"type": "mixed", "type": "mixed",
"meta": plugins.DataSources["mixed"], "meta": plugins.DataSources["mixed"],
} }
......
...@@ -48,7 +48,7 @@ function (angular, _, config) { ...@@ -48,7 +48,7 @@ function (angular, _, config) {
var target = {}; var target = {};
if (datasource) { if (datasource) {
target.datasource = datasource; target.datasource = datasource.name;
} }
target.refId = _.find(letters, function(refId) { target.refId = _.find(letters, function(refId) {
...@@ -66,21 +66,24 @@ function (angular, _, config) { ...@@ -66,21 +66,24 @@ function (angular, _, config) {
}; };
$scope.setDatasource = function(datasource) { $scope.setDatasource = function(datasource) {
$scope.panel.datasource = datasource; // switching to mixed
$scope.datasource = null; if (datasource.meta.mixed) {
$scope.panel.targets = _.filter($scope.panel.targets, function(target) { _.each($scope.panel.targets, function(target) {
delete target.datasource; target.datasource = $scope.panel.datasource;
return target.datasource === void 0; if (target.datasource === null) {
target.datasource = config.defaultDatasource;
}
}); });
if ($scope.panel.targets.length === 0) {
$scope.panel.targets = [{refId: 'A'}];
} }
// switching from mixed
if (datasource === 'mixed') { else if ($scope.datasource && $scope.datasource.meta.mixed) {
$scope.panel.targets = []; _.each($scope.panel.targets, function(target) {
delete target.datasource;
});
} }
$scope.panel.datasource = datasource.value;
$scope.datasource = null;
$scope.get_data(); $scope.get_data();
}; };
......
...@@ -6,23 +6,23 @@ ...@@ -6,23 +6,23 @@
</div> </div>
<div style="margin: 20px 0 0 0"> <div style="margin: 20px 0 0 0">
<button class="btn btn-inverse" ng-click="addDataQuery(panel.target)" ng-if="datasource.meta.type !== 'mixed'"> <button class="btn btn-inverse" ng-click="addDataQuery()" ng-hide="datasource.meta.builtIn">
<i class="fa fa-plus"></i>&nbsp; <i class="fa fa-plus"></i>&nbsp;
Query Query
</button> </button>
<span class="dropdown" ng-if="datasource.meta.type === 'mixed'"> <div class="dropdown" ng-if="datasource.meta.builtIn">
<button class="btn btn-inverse dropdown-toggle" data-toggle="dropdown"> <button class="btn btn-inverse dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-plus"></i>&nbsp; <i class="fa fa-plus"></i>&nbsp;
Query &nbsp; <span class="caret"></span> Query &nbsp; <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu" role="menu"> <ul class="dropdown-menu" role="menu">
<li ng-repeat="datasource in datasources" role="menuitem"> <li ng-repeat="datasource in datasources" role="menuitem" ng-hide="datasource.meta.builtIn">
<a ng-click="addDataQuery(datasource.name);">{{datasource.name}}</a> <a ng-click="addDataQuery(datasource);">{{datasource.name}}</a>
</li> </li>
</ul> </ul>
</span> </div>
</div> </div>
......
{ {
"pluginType": "datasource", "pluginType": "datasource",
"name": "Grafana (for testing)", "name": "Grafana",
"hide": true, "builtIn": true,
"type": "grafana", "type": "grafana",
"serviceName": "GrafanaDatasource", "serviceName": "GrafanaDatasource",
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
"module": "plugins/datasource/graphite/datasource", "module": "plugins/datasource/graphite/datasource",
"partials": { "partials": {
"config": "app/plugins/datasource/graphite/partials/config.html", "config": "app/plugins/datasource/graphite/partials/config.html"
}, },
"metrics": true, "metrics": true,
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
"module": "plugins/datasource/influxdb/datasource", "module": "plugins/datasource/influxdb/datasource",
"partials": { "partials": {
"config": "app/plugins/datasource/influxdb/partials/config.html", "config": "app/plugins/datasource/influxdb/partials/config.html"
}, },
"metrics": true, "metrics": true,
......
{ {
"pluginType": "datasource", "pluginType": "datasource",
"name": "Mixed datasource", "name": "Mixed datasource",
"hide": true, "builtIn": true,
"mixed": true,
"type": "mixed", "type": "mixed",
"serviceName": "MixedDatasource", "serviceName": "MixedDatasource",
......
...@@ -3,6 +3,7 @@ define([ ...@@ -3,6 +3,7 @@ define([
'lodash', 'lodash',
'kbn', 'kbn',
'moment', 'moment',
'./directives',
'./queryCtrl', './queryCtrl',
], ],
function (angular, _, kbn) { function (angular, _, kbn) {
......
...@@ -20,13 +20,24 @@ function (angular, _, config) { ...@@ -20,13 +20,24 @@ function (angular, _, config) {
if (value.meta && value.meta.metrics) { if (value.meta && value.meta.metrics) {
self.metricSources.push({ self.metricSources.push({
value: key === config.defaultDatasource ? null : key, value: key === config.defaultDatasource ? null : key,
name: key name: key,
meta: value.meta,
}); });
} }
if (value.meta && value.meta.annotations) { if (value.meta && value.meta.annotations) {
self.annotationSources.push(value); self.annotationSources.push(value);
} }
}); });
this.metricSources.sort(function(a, b) {
if (a.meta.builtIn || a.name > b.name) {
return 1;
}
if (a.name < b.name) {
return -1;
}
return 0;
});
}; };
this.get = function(name) { this.get = function(name) {
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
// Components: Buttons & Alerts // Components: Buttons & Alerts
@import "buttons.less"; @import "buttons.less";
// @import "button-groups.less"; @import "button-groups.less";
@import "alerts.less"; // Note: alerts share common CSS with buttons and thus have styles in buttons.less @import "alerts.less"; // Note: alerts share common CSS with buttons and thus have styles in buttons.less
// Components: Nav // Components: Nav
......
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