Browse Source

absolute time ranges (zoom in) works with influxdb

Torkel Ödegaard 12 years ago
parent
commit
291dd9bd48

+ 3 - 4
src/app/panels/graphite/module.js

@@ -207,8 +207,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
 
       $scope.datasources = datasourceSrv.listOptions();
       $scope.datasourceChanged();
-
-      $scope.get_data();
     };
 
     $scope.datasourceChanged = function() {
@@ -225,12 +223,13 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
     $scope.updateTimeRange = function () {
       $scope.range = filterSrv.timeRange();
       $scope.rangeUnparsed = filterSrv.timeRange(false);
+      $scope.resolution = ($(window).width() / ($scope.panel.span / 12)) / 2;
 
       $scope.interval = '10m';
 
       if ($scope.range) {
         $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) {
         interval: $scope.interval,
         targets: $scope.panel.targets,
         format: $scope.panel.renderer === 'png' ? 'png' : 'json',
-        maxDataPoints: $scope.panel.span * 50,
+        maxDataPoints: $scope.resolution,
         datasource: $scope.panel.datasource
       };
 

+ 4 - 4
src/app/partials/influxdb/editor.html

@@ -46,7 +46,7 @@
         <ul class="grafana-segment-list" role="menu">
           <li>
             <a class="grafana-target-segment">
-              From series
+              from series
             </a>
           </li>
           <li>
@@ -59,7 +59,7 @@
           </li>
           <li>
             <a class="grafana-target-segment">
-              Select
+              select
             </a>
           </li>
           <li>
@@ -72,7 +72,7 @@
           </li>
           <li>
             <a class="grafana-target-segment">
-              Function
+              function
             </a>
           </li>
           <li>
@@ -88,5 +88,5 @@
 </div>
 
 <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>

+ 21 - 1
src/app/services/influxdb/influxdbDatasource.js

@@ -86,7 +86,27 @@ function (angular, _) {
     };
 
     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';
     }