|
@@ -90,28 +90,28 @@ export class PostgresQueryCtrl extends QueryCtrl {
|
|
|
getSchemaSegments() {
|
|
getSchemaSegments() {
|
|
|
return this.datasource
|
|
return this.datasource
|
|
|
.metricFindQuery(this.queryBuilder.buildSchemaQuery())
|
|
.metricFindQuery(this.queryBuilder.buildSchemaQuery())
|
|
|
- .then(this.transformToSegments(true))
|
|
|
|
|
|
|
+ .then(this.transformToSegments({}))
|
|
|
.catch(this.handleQueryError.bind(this));
|
|
.catch(this.handleQueryError.bind(this));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
getTableSegments() {
|
|
getTableSegments() {
|
|
|
return this.datasource
|
|
return this.datasource
|
|
|
.metricFindQuery(this.queryBuilder.buildTableQuery())
|
|
.metricFindQuery(this.queryBuilder.buildTableQuery())
|
|
|
- .then(this.transformToSegments(true))
|
|
|
|
|
|
|
+ .then(this.transformToSegments({}))
|
|
|
.catch(this.handleQueryError.bind(this));
|
|
.catch(this.handleQueryError.bind(this));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
getTimeColumnSegments() {
|
|
getTimeColumnSegments() {
|
|
|
return this.datasource
|
|
return this.datasource
|
|
|
.metricFindQuery(this.queryBuilder.buildColumnQuery('time'))
|
|
.metricFindQuery(this.queryBuilder.buildColumnQuery('time'))
|
|
|
- .then(this.transformToSegments(true))
|
|
|
|
|
|
|
+ .then(this.transformToSegments({}))
|
|
|
.catch(this.handleQueryError.bind(this));
|
|
.catch(this.handleQueryError.bind(this));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
getMetricColumnSegments() {
|
|
getMetricColumnSegments() {
|
|
|
return this.datasource
|
|
return this.datasource
|
|
|
.metricFindQuery(this.queryBuilder.buildColumnQuery('metric'))
|
|
.metricFindQuery(this.queryBuilder.buildColumnQuery('metric'))
|
|
|
- .then(this.transformToSegments(true))
|
|
|
|
|
|
|
+ .then(this.transformToSegments({}))
|
|
|
.catch(this.handleQueryError.bind(this));
|
|
.catch(this.handleQueryError.bind(this));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -155,7 +155,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- transformToSegments(addTemplateVars) {
|
|
|
|
|
|
|
+ transformToSegments(config) {
|
|
|
return results => {
|
|
return results => {
|
|
|
var segments = _.map(results, segment => {
|
|
var segments = _.map(results, segment => {
|
|
|
return this.uiSegmentSrv.newSegment({
|
|
return this.uiSegmentSrv.newSegment({
|
|
@@ -164,12 +164,18 @@ export class PostgresQueryCtrl extends QueryCtrl {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- if (addTemplateVars) {
|
|
|
|
|
|
|
+ if (config.addTemplateVars) {
|
|
|
for (let variable of this.templateSrv.variables) {
|
|
for (let variable of this.templateSrv.variables) {
|
|
|
|
|
+ var value;
|
|
|
|
|
+ value = '$' + variable.name;
|
|
|
|
|
+ if (config.templateQuoter && variable.multi === false) {
|
|
|
|
|
+ value = config.templateQuoter(value);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
segments.unshift(
|
|
segments.unshift(
|
|
|
this.uiSegmentSrv.newSegment({
|
|
this.uiSegmentSrv.newSegment({
|
|
|
type: 'template',
|
|
type: 'template',
|
|
|
- value: '$' + variable.name,
|
|
|
|
|
|
|
+ value: value,
|
|
|
expandable: true,
|
|
expandable: true,
|
|
|
})
|
|
})
|
|
|
);
|
|
);
|
|
@@ -196,12 +202,12 @@ export class PostgresQueryCtrl extends QueryCtrl {
|
|
|
case 'aggregate':
|
|
case 'aggregate':
|
|
|
return this.datasource
|
|
return this.datasource
|
|
|
.metricFindQuery(this.queryBuilder.buildAggregateQuery())
|
|
.metricFindQuery(this.queryBuilder.buildAggregateQuery())
|
|
|
- .then(this.transformToSegments(false))
|
|
|
|
|
|
|
+ .then(this.transformToSegments({}))
|
|
|
.catch(this.handleQueryError.bind(this));
|
|
.catch(this.handleQueryError.bind(this));
|
|
|
case 'column':
|
|
case 'column':
|
|
|
return this.datasource
|
|
return this.datasource
|
|
|
.metricFindQuery(this.queryBuilder.buildColumnQuery('value'))
|
|
.metricFindQuery(this.queryBuilder.buildColumnQuery('value'))
|
|
|
- .then(this.transformToSegments(true))
|
|
|
|
|
|
|
+ .then(this.transformToSegments({}))
|
|
|
.catch(this.handleQueryError.bind(this));
|
|
.catch(this.handleQueryError.bind(this));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -225,7 +231,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
|
|
|
case 'get-param-options': {
|
|
case 'get-param-options': {
|
|
|
return this.datasource
|
|
return this.datasource
|
|
|
.metricFindQuery(this.queryBuilder.buildColumnQuery())
|
|
.metricFindQuery(this.queryBuilder.buildColumnQuery())
|
|
|
- .then(this.transformToSegments(true))
|
|
|
|
|
|
|
+ .then(this.transformToSegments({}))
|
|
|
.catch(this.handleQueryError.bind(this));
|
|
.catch(this.handleQueryError.bind(this));
|
|
|
}
|
|
}
|
|
|
case 'part-param-changed': {
|
|
case 'part-param-changed': {
|
|
@@ -255,12 +261,12 @@ export class PostgresQueryCtrl extends QueryCtrl {
|
|
|
case 'left':
|
|
case 'left':
|
|
|
return this.datasource
|
|
return this.datasource
|
|
|
.metricFindQuery(this.queryBuilder.buildColumnQuery())
|
|
.metricFindQuery(this.queryBuilder.buildColumnQuery())
|
|
|
- .then(this.transformToSegments(false))
|
|
|
|
|
|
|
+ .then(this.transformToSegments({}))
|
|
|
.catch(this.handleQueryError.bind(this));
|
|
.catch(this.handleQueryError.bind(this));
|
|
|
case 'right':
|
|
case 'right':
|
|
|
return this.datasource
|
|
return this.datasource
|
|
|
.metricFindQuery(this.queryBuilder.buildValueQuery(part.params[0]))
|
|
.metricFindQuery(this.queryBuilder.buildValueQuery(part.params[0]))
|
|
|
- .then(this.transformToSegments(true))
|
|
|
|
|
|
|
+ .then(this.transformToSegments({ addTemplateVars: true, templateQuoter: this.queryModel.quoteLiteral }))
|
|
|
.catch(this.handleQueryError.bind(this));
|
|
.catch(this.handleQueryError.bind(this));
|
|
|
case 'op':
|
|
case 'op':
|
|
|
return this.$q.when(this.uiSegmentSrv.newOperators(['=', '!=', '<', '<=', '>', '>=', 'IN']));
|
|
return this.$q.when(this.uiSegmentSrv.newOperators(['=', '!=', '<', '<=', '>', '>=', 'IN']));
|