Explore: jump to explore from panels with mixed datasources

- extends handlers for panel menu and keypress 'x'
- in a mixed-datasource panel finds first datasource that supports
  explore and collects its targets
- passes those targets to the found datasource to be serialized for
  explore state
- removed `supportMetrics` and `supportsExplore`
- use datasource metadata instead (set in plugin.json)
- Use angular timeout to wrap url change for explore jump
- Extract getExploreUrl into core/utils/explore
This commit is contained in:
David Kaltschmidt
2018-09-24 17:47:43 +02:00
parent 7b543ca4b5
commit 54c9beb146
9 changed files with 80 additions and 41 deletions

View File

@@ -149,8 +149,6 @@ export class PrometheusDatasource {
editorSrc: string;
name: string;
ruleMappings: { [index: string]: string };
supportsExplore: boolean;
supportMetrics: boolean;
url: string;
directUrl: string;
basicAuth: any;
@@ -166,8 +164,6 @@ export class PrometheusDatasource {
this.type = 'prometheus';
this.editorSrc = 'app/features/prometheus/partials/query.editor.html';
this.name = instanceSettings.name;
this.supportsExplore = true;
this.supportMetrics = true;
this.url = instanceSettings.url;
this.directUrl = instanceSettings.directUrl;
this.basicAuth = instanceSettings.basicAuth;
@@ -522,10 +518,10 @@ export class PrometheusDatasource {
});
}
getExploreState(panel) {
getExploreState(targets: any[]) {
let state = {};
if (panel.targets) {
const queries = panel.targets.map(t => ({
if (targets && targets.length > 0) {
const queries = targets.map(t => ({
query: this.templateSrv.replace(t.expr, {}, this.interpolateQueryExpr),
format: t.format,
}));