Fixes #13 (partially) Use relative time ranges whenever possible when querying graphite

This commit is contained in:
Torkel Ödegaard
2014-01-22 13:05:07 +01:00
parent f0c8b70f47
commit e2dd201e4a
2 changed files with 19 additions and 3 deletions
+1 -1
View File
@@ -320,7 +320,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
$scope.updateTimeRange();
var graphiteQuery = {
range: $scope.range,
range: filterSrv.timeRange(false),
targets: $scope.panel.targets,
maxDataPoints: $scope.panel.span * 50
};
+18 -2
View File
@@ -14,8 +14,8 @@ function (angular, _, $, config) {
this.query = function(options) {
try {
var graphOptions = {
from: $.plot.formatDate(options.range.from, '%H%:%M_%Y%m%d'),
until: $.plot.formatDate(options.range.to, '%H%:%M_%Y%m%d'),
from: this.translateTime(options.range.from),
until: this.translateTime(options.range.to),
targets: options.targets,
maxDataPoints: options.maxDataPoints
};
@@ -34,6 +34,22 @@ function (angular, _, $, config) {
}
};
this.translateTime = function(date) {
if (_.isDate(date)) {
return $.plot.formatDate(date, '%H%:%M_%Y%m%d');
}
if (date === 'now') {
return 'now';
}
date = date.substring(3);
date = date.replace('m', 'min');
date = date.replace('M', 'mon');
return date;
};
this.match = function(targets, graphiteTargetStr) {
var found = targets[0];