Commit e2dd201e by Torkel Ödegaard

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

parent f0c8b70f
......@@ -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
};
......
......@@ -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];
......
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