Explore: Adds ability to save a panel's query from Explore (#17982)

* Explore: Adds ability to return to origin dashboard
This commit is contained in:
kay delaney
2019-09-05 13:44:37 +01:00
committed by GitHub
parent 991f77cee1
commit a838d2b30a
22 changed files with 404 additions and 87 deletions

View File

@@ -25,10 +25,10 @@ import {
DataQueryResponseData,
DataStreamState,
} from '@grafana/ui';
import { ExploreUrlState } from 'app/types/explore';
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';
export interface PromDataQueryResponse {
data: {
@@ -603,15 +603,16 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
getExploreState(queries: PromQuery[]): Partial<ExploreUrlState> {
let state: Partial<ExploreUrlState> = { datasource: this.name };
if (queries && queries.length > 0) {
const expandedQueries = queries.map(query => ({
...query,
expr: this.templateSrv.replace(query.expr, {}, this.interpolateQueryExpr),
context: 'explore',
const expandedQueries = queries.map(query => {
const expandedQuery = {
...query,
expr: this.templateSrv.replace(query.expr, {}, this.interpolateQueryExpr),
context: 'explore',
};
return expandedQuery;
});
// null out values we don't support in Explore yet
legendFormat: null,
step: null,
}));
state = {
...state,
queries: expandedQueries,