Browse Source

Including LIMIT, SLIMIT and ORDER BY time on influxdb #6065

Initial work for the query builder interface
thuck 9 years ago
parent
commit
f577dd0f38

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

@@ -21,6 +21,7 @@ export default class InfluxQuery {
     target.policy = target.policy || 'default';
     target.dsType = 'influxdb';
     target.resultFormat = target.resultFormat || 'time_series';
+    target.orderByTime = target.orderByTime || 'ASC';
     target.tags = target.tags || [];
     target.groupBy = target.groupBy || [
       {type: 'time', params: ['$__interval']},

+ 23 - 1
public/app/plugins/datasource/influxdb/partials/query.editor.html

@@ -72,11 +72,33 @@
 			</div>
 		</div>
 
+        <div class="gf-form-inline">
+            <div class="gf-form">
+                <label class="gf-form-label query-keyword width-9">ORDER BY time</label>
+                <div class="gf-form-select-wrapper">
+                    <select class="gf-form-input gf-size-auto" ng-model="ctrl.target.orderByTime" ng-options="f.value as f.text for f in ctrl.orderByTime" ng-change="ctrl.refresh()"></select>
+                </div>
+            </div>
+
+            <div class="gf-form max-width-30">
+                <label class="gf-form-label query-keyword width-7">LIMIT</label>
+                <input type="text" class="gf-form-input" ng-model="ctrl.target.limit" spellcheck='false' placeholder="No Limit" ng-blur="ctrl.refresh()">
+            </div>
+
+            <div class="gf-form max-width-30">
+                <label class="gf-form-label query-keyword width-7">SLIMIT</label>
+                <input type="text" class="gf-form-input" ng-model="ctrl.target.slimit" spellcheck='false' placeholder="No Limit" ng-blur="ctrl.refresh()">
+            </div>
+            <div class="gf-form gf-form--grow">
+                <div class="gf-form-label gf-form-label--grow"></div>
+            </div>
+        </div>
+
 	</div>
 
 	<div class="gf-form-inline">
 		<div class="gf-form max-width-30">
-			<label class="gf-form-label query-keyword width-7">ALIAS BY</label>
+			<label class="gf-form-label query-keyword width-9">ALIAS BY</label>
 			<input type="text" class="gf-form-input" ng-model="ctrl.target.alias" spellcheck='false' placeholder="Naming pattern" ng-blur="ctrl.refresh()">
 		</div>
 		<div class="gf-form">

+ 5 - 0
public/app/plugins/datasource/influxdb/query_ctrl.ts

@@ -14,6 +14,7 @@ export class InfluxQueryCtrl extends QueryCtrl {
   queryBuilder: any;
   groupBySegment: any;
   resultFormats: any[];
+  orderByTime: any[];
   policySegment: any;
   tagSegments: any[];
   selectMenu: any;
@@ -32,6 +33,10 @@ export class InfluxQueryCtrl extends QueryCtrl {
       {text: 'Time series', value: 'time_series'},
       {text: 'Table', value: 'table'},
     ];
+    this.orderByTime = [
+      {text: 'Ascending', value: 'ASC'},
+      {text: 'Descending', value: 'DESC'},
+    ];
 
     this.policySegment = uiSegmentSrv.newSegment(this.target.policy);