Explore: Expand template variables when redirecting from dashboard panel (#19582)

* Fix redirect but adding getExploreState method to graphite

* Explore: Create interpolateVariablesInQueries function for datasources

* Explore: Add interpolateVariablesInQueries method to elasticsearch datasource

* Add interpolateVariablesInQueries function to influx and postgres

* Explore: Add interpolateVariablesInQueries to Mssql and Mysql datasources

* Explore: Add datasources to queries

* Explore: Code formatting

* Prettier formating fix

* Explore: Add rawQuery expanding of variables for influxdb

* Remove console.logs

* Explore: Add rawQuery expanding of multiple variables for influxdb

* Explore: If no queries in Influxdb, return early []

* Explore: Refactor influxDb to follow the code structure
This commit is contained in:
Ivana Huckova
2019-10-08 17:01:20 +02:00
committed by GitHub
parent 9904e14f8e
commit 90b0953620
14 changed files with 173 additions and 14 deletions

View File

@@ -226,6 +226,21 @@ export class ElasticDatasource extends DataSourceApi<ElasticsearchQuery, Elastic
});
}
interpolateVariablesInQueries(queries: ElasticsearchQuery[]): ElasticsearchQuery[] {
let expandedQueries = queries;
if (queries && queries.length > 0) {
expandedQueries = queries.map(query => {
const expandedQuery = {
...query,
datasource: this.name,
query: this.templateSrv.replace(query.query),
};
return expandedQuery;
});
}
return expandedQueries;
}
testDatasource() {
// validate that the index exist and has date field
return this.getFields({ type: 'date' }).then(