Commit e916f937 by Torkel Ödegaard

feat(mixed datasource): fixed failing unit tests

parent 1332ddbc
......@@ -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() {
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([]));
......
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