mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(mixed data source queries): lots of minor polish to new mixed data source and all the changes it has required, #436
This commit is contained in:
parent
56d5b0b12a
commit
6ee0f2c6a7
@ -115,7 +115,7 @@ func GetDataSourcePlugins(c *middleware.Context) {
|
||||
dsList := make(map[string]interface{})
|
||||
|
||||
for key, value := range plugins.DataSources {
|
||||
if value.(map[string]interface{})["hide"] == nil {
|
||||
if value.(map[string]interface{})["builtIn"] == nil {
|
||||
dsList[key] = value
|
||||
}
|
||||
}
|
||||
|
@ -86,12 +86,13 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
|
||||
|
||||
// add grafana backend data source
|
||||
grafanaDatasourceMeta, _ := plugins.DataSources["grafana"]
|
||||
datasources["grafana"] = map[string]interface{}{
|
||||
datasources["-- Grafana --"] = map[string]interface{}{
|
||||
"type": "grafana",
|
||||
"meta": grafanaDatasourceMeta,
|
||||
}
|
||||
|
||||
// add mixed backend data source
|
||||
datasources["mixed"] = map[string]interface{}{
|
||||
datasources["-- Mixed --"] = map[string]interface{}{
|
||||
"type": "mixed",
|
||||
"meta": plugins.DataSources["mixed"],
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ function (angular, _, config) {
|
||||
var target = {};
|
||||
|
||||
if (datasource) {
|
||||
target.datasource = datasource;
|
||||
target.datasource = datasource.name;
|
||||
}
|
||||
|
||||
target.refId = _.find(letters, function(refId) {
|
||||
@ -66,21 +66,24 @@ function (angular, _, config) {
|
||||
};
|
||||
|
||||
$scope.setDatasource = function(datasource) {
|
||||
$scope.panel.datasource = datasource;
|
||||
// switching to mixed
|
||||
if (datasource.meta.mixed) {
|
||||
_.each($scope.panel.targets, function(target) {
|
||||
target.datasource = $scope.panel.datasource;
|
||||
if (target.datasource === null) {
|
||||
target.datasource = config.defaultDatasource;
|
||||
}
|
||||
});
|
||||
}
|
||||
// switching from mixed
|
||||
else if ($scope.datasource && $scope.datasource.meta.mixed) {
|
||||
_.each($scope.panel.targets, function(target) {
|
||||
delete target.datasource;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.panel.datasource = datasource.value;
|
||||
$scope.datasource = null;
|
||||
$scope.panel.targets = _.filter($scope.panel.targets, function(target) {
|
||||
delete target.datasource;
|
||||
return target.datasource === void 0;
|
||||
});
|
||||
|
||||
if ($scope.panel.targets.length === 0) {
|
||||
$scope.panel.targets = [{refId: 'A'}];
|
||||
}
|
||||
|
||||
if (datasource === 'mixed') {
|
||||
$scope.panel.targets = [];
|
||||
}
|
||||
|
||||
$scope.get_data();
|
||||
};
|
||||
|
||||
|
@ -6,23 +6,23 @@
|
||||
</div>
|
||||
|
||||
<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>
|
||||
Query
|
||||
</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">
|
||||
<i class="fa fa-plus"></i>
|
||||
Query <span class="caret"></span>
|
||||
</button>
|
||||
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li ng-repeat="datasource in datasources" role="menuitem">
|
||||
<a ng-click="addDataQuery(datasource.name);">{{datasource.name}}</a>
|
||||
<li ng-repeat="datasource in datasources" role="menuitem" ng-hide="datasource.meta.builtIn">
|
||||
<a ng-click="addDataQuery(datasource);">{{datasource.name}}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"pluginType": "datasource",
|
||||
"name": "Grafana (for testing)",
|
||||
"hide": true,
|
||||
"name": "Grafana",
|
||||
"builtIn": true,
|
||||
|
||||
"type": "grafana",
|
||||
"serviceName": "GrafanaDatasource",
|
||||
|
@ -8,7 +8,7 @@
|
||||
"module": "plugins/datasource/graphite/datasource",
|
||||
|
||||
"partials": {
|
||||
"config": "app/plugins/datasource/graphite/partials/config.html",
|
||||
"config": "app/plugins/datasource/graphite/partials/config.html"
|
||||
},
|
||||
|
||||
"metrics": true,
|
||||
|
@ -8,7 +8,7 @@
|
||||
"module": "plugins/datasource/influxdb/datasource",
|
||||
|
||||
"partials": {
|
||||
"config": "app/plugins/datasource/influxdb/partials/config.html",
|
||||
"config": "app/plugins/datasource/influxdb/partials/config.html"
|
||||
},
|
||||
|
||||
"metrics": true,
|
||||
|
@ -1,7 +1,8 @@
|
||||
{
|
||||
"pluginType": "datasource",
|
||||
"name": "Mixed datasource",
|
||||
"hide": true,
|
||||
"builtIn": true,
|
||||
"mixed": true,
|
||||
|
||||
"type": "mixed",
|
||||
"serviceName": "MixedDatasource",
|
||||
|
@ -3,6 +3,7 @@ define([
|
||||
'lodash',
|
||||
'kbn',
|
||||
'moment',
|
||||
'./directives',
|
||||
'./queryCtrl',
|
||||
],
|
||||
function (angular, _, kbn) {
|
||||
|
@ -20,13 +20,24 @@ function (angular, _, config) {
|
||||
if (value.meta && value.meta.metrics) {
|
||||
self.metricSources.push({
|
||||
value: key === config.defaultDatasource ? null : key,
|
||||
name: key
|
||||
name: key,
|
||||
meta: value.meta,
|
||||
});
|
||||
}
|
||||
if (value.meta && value.meta.annotations) {
|
||||
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) {
|
||||
|
2
public/vendor/bootstrap/less/bootstrap.less
vendored
2
public/vendor/bootstrap/less/bootstrap.less
vendored
@ -32,7 +32,7 @@
|
||||
|
||||
// Components: Buttons & Alerts
|
||||
@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
|
||||
|
||||
// Components: Nav
|
||||
|
Loading…
Reference in New Issue
Block a user