mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(datasource): added new mixed data source
This commit is contained in:
@@ -9,7 +9,6 @@ function (angular, _, config, gfunc, Parser) {
|
||||
'use strict';
|
||||
|
||||
var module = angular.module('grafana.controllers');
|
||||
var targetLetters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
|
||||
module.directive('metricQueryEditorGraphite', function() {
|
||||
return {
|
||||
@@ -28,8 +27,6 @@ function (angular, _, config, gfunc, Parser) {
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.target.target = $scope.target.target || '';
|
||||
$scope.targetLetters = targetLetters;
|
||||
|
||||
parseTarget();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="tight-form-container-no-item-borders" style="margin-bottom: 10px">
|
||||
<div class="tight-form-container-no-item-borders">
|
||||
<div class="tight-form">
|
||||
<ul class="tight-form-list pull-right">
|
||||
<li ng-show="parserError" class="tight-form-item">
|
||||
@@ -48,6 +48,9 @@
|
||||
</ul>
|
||||
|
||||
<ul class="tight-form-list">
|
||||
<li class="tight-form-item" style="min-width: 15px; text-align: center">
|
||||
{{targetLetters[$index]}}
|
||||
</li>
|
||||
<li>
|
||||
<a class="tight-form-item"
|
||||
ng-click="target.hide = !target.hide; get_data();"
|
||||
@@ -77,9 +80,7 @@
|
||||
|
||||
<div class="tight-form" ng-hide="target.rawQuery">
|
||||
<ul class="tight-form-list">
|
||||
<li class="tight-form-item">
|
||||
<i class="fa fa-eye invisible"></i>
|
||||
</li>
|
||||
<li class="tight-form-item" style="width: 44px"></li>
|
||||
<li class="tight-form-item query-keyword" style="width: 75px;">
|
||||
FROM
|
||||
</li>
|
||||
@@ -93,9 +94,7 @@
|
||||
|
||||
<div class="tight-form" ng-hide="target.rawQuery">
|
||||
<ul class="tight-form-list">
|
||||
<li class="tight-form-item">
|
||||
<i class="fa fa-eye invisible"></i>
|
||||
</li>
|
||||
<li class="tight-form-item" style="width: 44px"></li>
|
||||
|
||||
<li class="tight-form-item query-keyword" style="width: 75px;">
|
||||
WHERE
|
||||
@@ -110,10 +109,7 @@
|
||||
|
||||
<div class="tight-form">
|
||||
<ul class="tight-form-list" ng-hide="target.rawQuery">
|
||||
<li class="tight-form-item">
|
||||
<i class="fa fa-eye invisible"></i>
|
||||
</li>
|
||||
|
||||
<li class="tight-form-item" style="width: 44px"></li>
|
||||
<li class="tight-form-item query-keyword">
|
||||
GROUP BY
|
||||
</li>
|
||||
|
||||
42
public/app/plugins/datasource/mixed/datasource.js
Normal file
42
public/app/plugins/datasource/mixed/datasource.js
Normal file
@@ -0,0 +1,42 @@
|
||||
define([
|
||||
'angular',
|
||||
'lodash',
|
||||
'kbn',
|
||||
],
|
||||
function (angular, _, kbn) {
|
||||
'use strict';
|
||||
|
||||
var module = angular.module('grafana.services');
|
||||
|
||||
module.factory('MixedDatasource', function($q, backendSrv, datasourceSrv) {
|
||||
|
||||
function MixedDatasource() {
|
||||
}
|
||||
|
||||
MixedDatasource.prototype.query = function(options) {
|
||||
var sets = _.groupBy(options.targets, 'datasource');
|
||||
var promises = _.map(sets, function(targets) {
|
||||
return datasourceSrv.get(targets[0].datasource).then(function(ds) {
|
||||
var opt = angular.copy(options);
|
||||
opt.targets = targets;
|
||||
return ds.query(opt);
|
||||
});
|
||||
});
|
||||
|
||||
return $q.all(promises).then(function(results) {
|
||||
return { data: _.flatten(_.pluck(results, 'data')) };
|
||||
});
|
||||
|
||||
// console.log(options.targets);
|
||||
// // get from & to in seconds
|
||||
// var from = kbn.parseDate(options.range.from).getTime();
|
||||
// var to = kbn.parseDate(options.range.to).getTime();
|
||||
//
|
||||
// return backendSrv.get('/api/metrics/test', { from: from, to: to, maxDataPoints: options.maxDataPoints });
|
||||
};
|
||||
|
||||
return MixedDatasource;
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
15
public/app/plugins/datasource/mixed/plugin.json
Normal file
15
public/app/plugins/datasource/mixed/plugin.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"pluginType": "datasource",
|
||||
"name": "Mixed datasource",
|
||||
|
||||
"type": "mixed",
|
||||
"serviceName": "MixedDatasource",
|
||||
|
||||
"module": "plugins/datasource/mixed/datasource",
|
||||
|
||||
"partials": {
|
||||
"query": "app/plugins/datasource/mixed/partials/query.editor.html"
|
||||
},
|
||||
|
||||
"metrics": true
|
||||
}
|
||||
Reference in New Issue
Block a user