ソースを参照

feat(influxdb): you can now change group by time iunterval on per query basis, #2647

Torkel Ödegaard 10 年 前
コミット
8c9d551826

+ 8 - 7
public/app/plugins/datasource/influxdb/partials/query.editor2.html

@@ -75,10 +75,10 @@
 					<span ng-show="$index === 0">SELECT</span>
 				</li>
 				<li>
-					<metric-segment-model property="field.func" get-options="getFunctions()" on-change="get_data()"></metric-segment>
+					<metric-segment-model property="field.func" get-options="getFunctions()" on-change="get_data()" css-class="tight-form-item-xlarge"></metric-segment>
 				</li>
 				<li>
-					<metric-segment-model property="field.name" get-options="getFields()" on-change="get_data()"></metric-segment>
+					<metric-segment-model property="field.name" get-options="getFields()" on-change="get_data()" css-class="tight-form-item-large"></metric-segment>
 				</li>
 				<li>
 					<input type="text" class="tight-form-clear-input text-center" style="width: 70px;" ng-model="field.mathExpr" spellcheck='false' placeholder="math expr" ng-blur="get_data()">
@@ -102,16 +102,17 @@
 			<div class="clearfix"></div>
 		</div>
 
-		<div class="tight-form" ng-repeat="tag in target.groupBy">
+		<div class="tight-form" ng-repeat="groupBy in target.groupBy">
 			<ul class="tight-form-list">
 				<li class="tight-form-item query-keyword tight-form-align" style="width: 75px;">
 					<span ng-show="$index === 0">GROUP BY</span>
 				</li>
-				<li class="tight-form-item" ng-if="tag.type === 'time'">
-					time($interval)
+				<li ng-if="groupBy.type === 'time'">
+					<span class="tight-form-item">time</span>
+					<metric-segment-model property="groupBy.interval" get-options="getGroupByTimeIntervals()" on-change="get_data()"></metric-segment>
 				</li>
-				<li ng-if="tag.type === 'tag'">
-					<metric-segment-model property="tag.key" get-options="getTagOptions()" on-change="get_data()"></metric-segment>
+				<li ng-if="groupBy.type === 'tag'">
+					<metric-segment-model property="groupBy.key" get-options="getTagOptions()" on-change="get_data()"></metric-segment>
 				</li>
 			</ul>
 

+ 7 - 0
public/app/plugins/datasource/influxdb/queryCtrl.js

@@ -115,6 +115,13 @@ function (angular, _, InfluxQueryBuilder) {
       }));
     };
 
+    $scope.getGroupByTimeIntervals = function () {
+      var times = ['auto', '1s', '10s', '1m', '2m', '5m', '10m', '30m', '1h', '1d'];
+      return $q.when(_.map(times, function(func) {
+        return uiSegmentSrv.newSegment(func);
+      }));
+    };
+
     $scope.handleQueryError = function(err) {
       $scope.parserError = err.message || 'Failed to issue metric query';
       return [];