mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -27,7 +27,6 @@ import {
|
||||
import { safeStringifyValue } from 'app/core/utils/explore';
|
||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||
import { ExploreUrlState } from 'app/types';
|
||||
import TableModel from 'app/core/table_model';
|
||||
|
||||
export interface PromDataQueryResponse {
|
||||
@@ -625,25 +624,19 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
|
||||
});
|
||||
}
|
||||
|
||||
getExploreState(queries: PromQuery[]): Partial<ExploreUrlState> {
|
||||
let state: Partial<ExploreUrlState> = { datasource: this.name };
|
||||
interpolateVariablesInQueries(queries: PromQuery[]): PromQuery[] {
|
||||
let expandedQueries = queries;
|
||||
if (queries && queries.length > 0) {
|
||||
const expandedQueries = queries.map(query => {
|
||||
expandedQueries = queries.map(query => {
|
||||
const expandedQuery = {
|
||||
...query,
|
||||
datasource: this.name,
|
||||
expr: this.templateSrv.replace(query.expr, {}, this.interpolateQueryExpr),
|
||||
context: 'explore',
|
||||
};
|
||||
|
||||
return expandedQuery;
|
||||
});
|
||||
|
||||
state = {
|
||||
...state,
|
||||
queries: expandedQueries,
|
||||
};
|
||||
}
|
||||
return state;
|
||||
return expandedQueries;
|
||||
}
|
||||
|
||||
getQueryHints(query: PromQuery, result: any[]) {
|
||||
|
||||
Reference in New Issue
Block a user