Commit 291dd9bd by Torkel Ödegaard

absolute time ranges (zoom in) works with influxdb

parent 549eeeb2
...@@ -207,8 +207,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -207,8 +207,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
$scope.datasources = datasourceSrv.listOptions(); $scope.datasources = datasourceSrv.listOptions();
$scope.datasourceChanged(); $scope.datasourceChanged();
$scope.get_data();
}; };
$scope.datasourceChanged = function() { $scope.datasourceChanged = function() {
...@@ -225,12 +223,13 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -225,12 +223,13 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
$scope.updateTimeRange = function () { $scope.updateTimeRange = function () {
$scope.range = filterSrv.timeRange(); $scope.range = filterSrv.timeRange();
$scope.rangeUnparsed = filterSrv.timeRange(false); $scope.rangeUnparsed = filterSrv.timeRange(false);
$scope.resolution = ($(window).width() / ($scope.panel.span / 12)) / 2;
$scope.interval = '10m'; $scope.interval = '10m';
if ($scope.range) { if ($scope.range) {
$scope.interval = kbn.secondsToHms( $scope.interval = kbn.secondsToHms(
kbn.calculate_interval($scope.range.from, $scope.range.to, $scope.panel.resolution, 0) / 1000 kbn.calculate_interval($scope.range.from, $scope.range.to, $scope.resolution, 0) / 1000
); );
} }
}; };
...@@ -247,7 +246,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -247,7 +246,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
interval: $scope.interval, interval: $scope.interval,
targets: $scope.panel.targets, targets: $scope.panel.targets,
format: $scope.panel.renderer === 'png' ? 'png' : 'json', format: $scope.panel.renderer === 'png' ? 'png' : 'json',
maxDataPoints: $scope.panel.span * 50, maxDataPoints: $scope.resolution,
datasource: $scope.panel.datasource datasource: $scope.panel.datasource
}; };
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
<ul class="grafana-segment-list" role="menu"> <ul class="grafana-segment-list" role="menu">
<li> <li>
<a class="grafana-target-segment"> <a class="grafana-target-segment">
From series from series
</a> </a>
</li> </li>
<li> <li>
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
</li> </li>
<li> <li>
<a class="grafana-target-segment"> <a class="grafana-target-segment">
Select select
</a> </a>
</li> </li>
<li> <li>
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
</li> </li>
<li> <li>
<a class="grafana-target-segment"> <a class="grafana-target-segment">
Function function
</a> </a>
</li> </li>
<li> <li>
...@@ -88,5 +88,5 @@ ...@@ -88,5 +88,5 @@
</div> </div>
<div class="editor-row" style="margin-top: 20px" ng-show="editor.index == 1"> <div class="editor-row" style="margin-top: 20px" ng-show="editor.index == 1">
<button class="btn btn-success pull-right" ng-click="add_target(panel.target)">Add target</button> <button class="btn btn-success pull-right" ng-click="add_target(panel.target)">Add query</button>
</div> </div>
\ No newline at end of file
...@@ -86,7 +86,27 @@ function (angular, _) { ...@@ -86,7 +86,27 @@ function (angular, _) {
}; };
function getTimeFilter(options) { function getTimeFilter(options) {
return "time > now() - 6h"; var from = options.range.from;
var until = options.range.to;
if (_.isString(from)) {
return 'time > now() - ' + from.substring(4);
}
else {
from = to_utc_epoch_seconds(from);
}
if (until === 'now') {
return 'time > ' + from;
}
else {
until = to_utc_epoch_seconds(until);
return 'time > ' + from + ' and time < ' + until;
}
}
function to_utc_epoch_seconds(date) {
return (date.getTime() / 1000).toFixed(0) + 's';
} }
......
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