mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
prefill editor with first metric table
This commit is contained in:
parent
ff2564900f
commit
49319fbdea
@ -24,7 +24,7 @@ export class PostgresMetaQuery {
|
||||
}
|
||||
|
||||
findMetricTable() {
|
||||
// query that returns first table found that has a timestamptz column and a float column
|
||||
// query that returns first table found that has a timestamp(tz) column and a float column
|
||||
let query = `
|
||||
SELECT
|
||||
table_name,
|
||||
|
@ -56,6 +56,18 @@ export class PostgresQueryCtrl extends QueryCtrl {
|
||||
this.target.rawSql = 'SELECT 1';
|
||||
} else {
|
||||
this.target.rawSql = defaultQuery;
|
||||
this.datasource.metricFindQuery(this.metaBuilder.findMetricTable()).then(result => {
|
||||
if (result.length > 0) {
|
||||
this.target.table = result[0].text;
|
||||
this.tableSegment = uiSegmentSrv.newSegment(this.target.table);
|
||||
this.target.timeColumn = result[1].text;
|
||||
this.timeColumnSegment = uiSegmentSrv.newSegment(this.target.timeColumn);
|
||||
this.target.timeColumnType = 'timestamp';
|
||||
this.target.select = [[{ type: 'column', params: [result[2].text] }]];
|
||||
this.updateProjection();
|
||||
this.panelCtrl.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user