mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(mixed datasource): fixed failing unit tests
This commit is contained in:
parent
1332ddbc93
commit
e916f93787
@ -8,68 +8,23 @@ function (angular, _, kbn) {
|
||||
|
||||
var module = angular.module('grafana.services');
|
||||
|
||||
module.factory('GrafanaDatasource', function($q, backendSrv, datasourceSrv) {
|
||||
module.factory('GrafanaDatasource', function($q, backendSrv) {
|
||||
|
||||
function GrafanaDatasource() {
|
||||
}
|
||||
|
||||
GrafanaDatasource.prototype.getDashboard = function(slug, isTemp) {
|
||||
var url = '/dashboards/' + slug;
|
||||
|
||||
if (isTemp) {
|
||||
url = '/temp/' + slug;
|
||||
}
|
||||
|
||||
return backendSrv.get('/api/dashboards/db/' + slug);
|
||||
};
|
||||
|
||||
GrafanaDatasource.prototype.query = function(options) {
|
||||
return datasourceSrv.get(options.targets[0].datasource).then(function(ds) {
|
||||
options.targets = [options.targets[0]];
|
||||
return ds.query(options);
|
||||
});
|
||||
// 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 });
|
||||
// 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 });
|
||||
};
|
||||
|
||||
GrafanaDatasource.prototype.metricFindQuery = function() {
|
||||
return $q.when([]);
|
||||
};
|
||||
|
||||
GrafanaDatasource.prototype.starDashboard = function(dashId) {
|
||||
return backendSrv.post('/api/user/stars/dashboard/' + dashId);
|
||||
};
|
||||
|
||||
GrafanaDatasource.prototype.unstarDashboard = function(dashId) {
|
||||
return backendSrv.delete('/api/user/stars/dashboard/' + dashId);
|
||||
};
|
||||
|
||||
GrafanaDatasource.prototype.saveDashboard = function(dashboard) {
|
||||
return backendSrv.post('/api/dashboards/db/', { dashboard: dashboard })
|
||||
.then(function(data) {
|
||||
return { title: dashboard.title, url: '/dashboard/db/' + data.slug };
|
||||
}, function(err) {
|
||||
err.isHandled = true;
|
||||
err.data = err.data || {};
|
||||
throw err.data.message || "Unknown error";
|
||||
});
|
||||
};
|
||||
|
||||
GrafanaDatasource.prototype.deleteDashboard = function(id) {
|
||||
return backendSrv.delete('/api/dashboards/db/' + id);
|
||||
};
|
||||
|
||||
GrafanaDatasource.prototype.searchDashboards = function(query) {
|
||||
return backendSrv.get('/api/search/', query)
|
||||
.then(function(data) {
|
||||
return data;
|
||||
});
|
||||
};
|
||||
|
||||
return GrafanaDatasource;
|
||||
|
||||
});
|
||||
|
@ -26,8 +26,10 @@ function (angular, _, config, gfunc, Parser) {
|
||||
module.controller('GraphiteQueryCtrl', function($scope, $sce, templateSrv) {
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.target.target = $scope.target.target || '';
|
||||
parseTarget();
|
||||
if ($scope.target) {
|
||||
$scope.target.target = $scope.target.target || '';
|
||||
parseTarget();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.toggleEditorMode = function() {
|
||||
|
@ -24,6 +24,8 @@ function (angular, _, InfluxQueryBuilder) {
|
||||
module.controller('InfluxQueryCtrl', function($scope, $timeout, $sce, templateSrv, $q) {
|
||||
|
||||
$scope.init = function() {
|
||||
if (!$scope.target) { return; }
|
||||
|
||||
var target = $scope.target;
|
||||
target.tags = target.tags || [];
|
||||
target.groupByTags = target.groupByTags || [];
|
||||
|
@ -13,9 +13,7 @@ define([
|
||||
beforeEach(ctx.createControllerPhase('GraphiteQueryCtrl'));
|
||||
|
||||
beforeEach(function() {
|
||||
ctx.scope.target = {
|
||||
target: 'aliasByNode(scaleToSeconds(test.prod.*,1),2)'
|
||||
};
|
||||
ctx.scope.target = {target: 'aliasByNode(scaleToSeconds(test.prod.*,1),2)'};
|
||||
|
||||
ctx.scope.datasource = ctx.datasource;
|
||||
ctx.scope.datasource.metricFindQuery = sinon.stub().returns(ctx.$q.when([]));
|
||||
|
Loading…
Reference in New Issue
Block a user