瀏覽代碼

Merge branch 'influxdb_global_interval'

bergquist 10 年之前
父節點
當前提交
23fa5fa1c7

+ 37 - 37
public/app/features/panel/metrics_panel_ctrl.ts

@@ -111,49 +111,49 @@ class MetricsPanelCtrl extends PanelCtrl {
 
     var panelInterval = this.panel.interval;
     var datasourceInterval = (this.datasource || {}).interval;
-      this.interval = kbn.calculateInterval(this.range, this.resolution, panelInterval || datasourceInterval);
-    };
-
-    applyPanelTimeOverrides() {
-      this.timeInfo = '';
-
-      // check panel time overrrides
-      if (this.panel.timeFrom) {
-        var timeFromInfo = rangeUtil.describeTextRange(this.panel.timeFrom);
-        if (timeFromInfo.invalid) {
-          this.timeInfo = 'invalid time override';
-          return;
-        }
+    this.interval = kbn.calculateInterval(this.range, this.resolution, panelInterval || datasourceInterval);
+  };
+
+  applyPanelTimeOverrides() {
+    this.timeInfo = '';
+
+    // check panel time overrrides
+    if (this.panel.timeFrom) {
+      var timeFromInfo = rangeUtil.describeTextRange(this.panel.timeFrom);
+      if (timeFromInfo.invalid) {
+        this.timeInfo = 'invalid time override';
+        return;
+      }
 
-        if (_.isString(this.rangeRaw.from)) {
-          var timeFromDate = dateMath.parse(timeFromInfo.from);
-          this.timeInfo = timeFromInfo.display;
-          this.rangeRaw.from = timeFromInfo.from;
-          this.rangeRaw.to = timeFromInfo.to;
-          this.range.from = timeFromDate;
-          this.range.to = dateMath.parse(timeFromInfo.to);
-        }
+      if (_.isString(this.rangeRaw.from)) {
+        var timeFromDate = dateMath.parse(timeFromInfo.from);
+        this.timeInfo = timeFromInfo.display;
+        this.rangeRaw.from = timeFromInfo.from;
+        this.rangeRaw.to = timeFromInfo.to;
+        this.range.from = timeFromDate;
+        this.range.to = dateMath.parse(timeFromInfo.to);
       }
+    }
 
-      if (this.panel.timeShift) {
-        var timeShiftInfo = rangeUtil.describeTextRange(this.panel.timeShift);
-        if (timeShiftInfo.invalid) {
-          this.timeInfo = 'invalid timeshift';
-          return;
-        }
+    if (this.panel.timeShift) {
+      var timeShiftInfo = rangeUtil.describeTextRange(this.panel.timeShift);
+      if (timeShiftInfo.invalid) {
+        this.timeInfo = 'invalid timeshift';
+        return;
+      }
 
-        var timeShift = '-' + this.panel.timeShift;
-        this.timeInfo += ' timeshift ' + timeShift;
-        this.range.from = dateMath.parseDateMath(timeShift, this.range.from, false);
-        this.range.to = dateMath.parseDateMath(timeShift, this.range.to, true);
+      var timeShift = '-' + this.panel.timeShift;
+      this.timeInfo += ' timeshift ' + timeShift;
+      this.range.from = dateMath.parseDateMath(timeShift, this.range.from, false);
+      this.range.to = dateMath.parseDateMath(timeShift, this.range.to, true);
 
-        this.rangeRaw = this.range;
-      }
+      this.rangeRaw = this.range;
+    }
 
-      if (this.panel.hideTimeOverride) {
-        this.timeInfo = '';
-      }
-    };
+    if (this.panel.hideTimeOverride) {
+      this.timeInfo = '';
+    }
+  };
 
   issueQueries(datasource) {
     this.updateTimeRange();

+ 1 - 1
public/app/plugins/datasource/influxdb/datasource.ts

@@ -19,7 +19,7 @@ export function InfluxDatasource(instanceSettings, $q, backendSrv, templateSrv)
   this.name = instanceSettings.name;
   this.database = instanceSettings.database;
   this.basicAuth = instanceSettings.basicAuth;
-
+  this.interval = (instanceSettings.jsonData || {}).timeInterval;
   this.supportAnnotations = true;
   this.supportMetrics = true;
 

+ 17 - 0
public/app/plugins/datasource/influxdb/partials/config.html

@@ -33,3 +33,20 @@
 </div>
 
 
+<br>
+<h4>Default query settings</h4>
+<div class="tight-form last">
+	<ul class="tight-form-list">
+		<li class="tight-form-item" style="width: 200px">
+			Group by time interval
+		</li>
+		<li>
+			<input type="text" class="input-medium tight-form-input input-xlarge" ng-model="ctrl.current.jsonData.timeInterval"
+			spellcheck='false' placeholder="example: >10s">
+		</li>
+		<li class="tight-form-item">
+			<i class="fa fa-question-circle" bs-tooltip="'Set a low limit by having a greater sign: example: >10s'" data-placement="right"></i>
+		</li>
+	</ul>
+	<div class="clearfix"></div>
+</div>