Sven Klemm il y a 7 ans
Parent
commit
0b358ff5f3

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

@@ -19,7 +19,7 @@
       </div>
 
       <div class="gf-form" ng-repeat="segment in ctrl.whereSegments">
-        <metric-segment segment="segment" get-options="ctrl.getTagsOrValues(segment, $index)" on-change="ctrl.whereSegmentUpdated(segment, $index)"></metric-segment>
+        <metric-segment segment="segment" get-options="ctrl.getWhereSegments(segment, $index)" on-change="ctrl.whereSegmentUpdated(segment, $index)"></metric-segment>
       </div>
 
       <div class="gf-form gf-form--grow">

+ 3 - 28
public/app/plugins/datasource/postgres/query_ctrl.ts

@@ -273,17 +273,12 @@ export class PostgresQueryCtrl extends QueryCtrl {
     }
   }
 
-  getTagsOrValues(segment, index) {
+  getWhereSegments(segment, index) {
     if (segment.type === 'condition') {
       return this.$q.when([this.uiSegmentSrv.newSegment('AND'), this.uiSegmentSrv.newSegment('OR')]);
     }
     if (segment.type === 'operator') {
-      var nextValue = this.whereSegments[index + 1].value;
-      if (/^\/.*\/$/.test(nextValue)) {
-        return this.$q.when(this.uiSegmentSrv.newOperators(['=~', '!~']));
-      } else {
-        return this.$q.when(this.uiSegmentSrv.newOperators(['=', '!=', '<>', '<', '>']));
-      }
+      return this.$q.when(this.uiSegmentSrv.newOperators(['=', '!=', '<>', '<', '>']));
     }
 
     var query, addTemplateVars;
@@ -308,15 +303,6 @@ export class PostgresQueryCtrl extends QueryCtrl {
       .catch(this.handleQueryError.bind(this));
   }
 
-  getTagValueOperator(tagValue, tagOperator): string {
-    if (tagOperator !== '=~' && tagOperator !== '!~' && /^\/.*\/$/.test(tagValue)) {
-      return '=~';
-    } else if ((tagOperator === '=~' || tagOperator === '!~') && /^(?!\/.*\/$)/.test(tagValue)) {
-      return '=';
-    }
-    return null;
-  }
-
   whereSegmentUpdated(segment, index) {
     this.whereSegments[index] = segment;
 
@@ -381,14 +367,11 @@ export class PostgresQueryCtrl extends QueryCtrl {
       .metricFindQuery(this.queryBuilder.buildColumnQuery())
       .then(tags => {
         var options = [];
-        if (!this.target.limit) {
-          options.push(this.uiSegmentSrv.newSegment({ value: 'LIMIT' }));
-        }
         if (!this.queryModel.hasGroupByTime()) {
           options.push(this.uiSegmentSrv.newSegment({ type: 'time', value: 'time(1m,none)' }));
         }
         for (let tag of tags) {
-          options.push(this.uiSegmentSrv.newSegment({ type: 'column', value: 'column(' + tag.text + ')' }));
+          options.push(this.uiSegmentSrv.newSegment({ type: 'column', value: tag.text }));
         }
         return options;
       })
@@ -397,14 +380,6 @@ export class PostgresQueryCtrl extends QueryCtrl {
 
   groupByAction() {
     switch (this.groupBySegment.value) {
-      case 'LIMIT': {
-        this.target.limit = 10;
-        break;
-      }
-      case 'ORDER BY time DESC': {
-        this.target.orderByTime = 'DESC';
-        break;
-      }
       default: {
         this.queryModel.addGroupBy(this.groupBySegment.value);
       }