浏览代码

Add a minimum value option for template auto interval

benrubson 9 年之前
父节点
当前提交
d6e4fb46cf

+ 5 - 1
public/app/core/utils/kbn.js

@@ -119,10 +119,14 @@ function($, _) {
     s: 1
   };
 
-  kbn.calculateInterval = function(range, resolution, userInterval) {
+  kbn.calculateInterval = function(range, resolution, userInterval, lowLimit) {
     var lowLimitMs = 1; // 1 millisecond default low limit
     var intervalMs, lowLimitInterval;
 
+    if(lowLimit) {
+        lowLimitMs = kbn.interval_to_ms(lowLimit);
+    }
+
     if (userInterval) {
       if (userInterval[0] === '>') {
         lowLimitInterval = userInterval.slice(1);

+ 6 - 0
public/app/features/templating/partials/editor.html

@@ -134,6 +134,12 @@
 								<li>
 									<select class="input-mini tight-form-input last" ng-model="current.auto_count" ng-options="f for f in [3,5,10,30,50,100,200]" ng-change="runQuery()"></select>
 								</li>
+								<li class="tight-form-item" ng-show="current.auto">
+									Auto interval min value <tip>The calculated value will not go below this threshold</tip>
+								</li>
+								<li>
+									<input type="text" style="width: 35px" class="input-xxlarge tight-form-input last" ng-model="current.auto_min" ng-change="runQuery()"></input>
+								</li>
 							</ul>
 							<div class="clearfix"></div>
 						</div>

+ 1 - 1
public/app/features/templating/templateValuesSrv.js

@@ -60,7 +60,7 @@ function (angular, _, kbn) {
         variable.options.unshift({ text: 'auto', value: '$__auto_interval' });
       }
 
-      var interval = kbn.calculateInterval(timeSrv.timeRange(), variable.auto_count);
+      var interval = kbn.calculateInterval(timeSrv.timeRange(), variable.auto_count, null, variable.auto_min);
       templateSrv.setGrafanaVariable('$__auto_interval', interval);
     };