浏览代码

Add support for InfluxDB's time zone clause

Jürgen Kreileder 7 年之前
父节点
当前提交
41eb0ba52e

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

@@ -256,6 +256,10 @@ export default class InfluxQuery {
       query += ' SLIMIT ' + target.slimit;
     }
 
+    if (target.tz) {
+      query += " tz('" + target.tz + "')";
+    }
+
     return query;
   }
 

+ 10 - 0
public/app/plugins/datasource/influxdb/partials/query.editor.html

@@ -119,6 +119,16 @@
 			</div>
     </div>
 
+    <div class="gf-form-inline" ng-if="ctrl.target.tz">
+      <div class="gf-form">
+        <label class="gf-form-label query-keyword width-7">tz</label>
+        <input type="text" class="gf-form-input width-9" ng-model="ctrl.target.tz" spellcheck='false' placeholder="No Timezone" 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 class="gf-form-inline">
       <div class="gf-form">
         <label class="gf-form-label query-keyword width-7">FORMAT AS</label>

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

@@ -100,6 +100,9 @@ export class InfluxQueryCtrl extends QueryCtrl {
         if (!this.target.slimit) {
           options.push(this.uiSegmentSrv.newSegment({ value: 'SLIMIT' }));
         }
+        if (!this.target.tz) {
+          options.push(this.uiSegmentSrv.newSegment({ value: 'tz' }));
+        }
         if (this.target.orderByTime === 'ASC') {
           options.push(this.uiSegmentSrv.newSegment({ value: 'ORDER BY time DESC' }));
         }
@@ -124,6 +127,10 @@ export class InfluxQueryCtrl extends QueryCtrl {
         this.target.slimit = 10;
         break;
       }
+      case 'tz': {
+        this.target.tz = 'UTC';
+        break;
+      }
       case 'ORDER BY time DESC': {
         this.target.orderByTime = 'DESC';
         break;