From 73248d6687aad2533c1c155958c7080b8f46be2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 13 Sep 2017 09:48:50 +0200 Subject: [PATCH] fixes for metrics tab when data source was not found --- public/app/features/panel/metrics_tab.ts | 17 ++++++++++------- .../features/panel/partials/metrics_tab.html | 6 +++--- public/sass/components/_alerts.scss | 4 ++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/public/app/features/panel/metrics_tab.ts b/public/app/features/panel/metrics_tab.ts index 4feaf516438..53d53cdbbff 100644 --- a/public/app/features/panel/metrics_tab.ts +++ b/public/app/features/panel/metrics_tab.ts @@ -9,7 +9,7 @@ export class MetricsTabCtrl { panel: any; panelCtrl: any; datasources: any[]; - current: any; + datasourceInstance: any; nextRefId: string; dashboard: DashboardModel; panelDsValue: any; @@ -29,23 +29,26 @@ export class MetricsTabCtrl { this.panel = this.panelCtrl.panel; this.dashboard = this.panelCtrl.dashboard; this.datasources = datasourceSrv.getMetricSources(); - this.panelDsValue = this.panelCtrl.panel.datasource || null; + this.panelDsValue = this.panelCtrl.panel.datasource; for (let ds of this.datasources) { if (ds.value === this.panelDsValue) { - this.current = ds; + this.datasourceInstance = ds; } } this.addQueryDropdown = {text: 'Add Query', value: null, fake: true}; + // update next ref id this.panelCtrl.nextRefId = this.dashboard.getNextQueryLetter(this.panel); this.updateDatasourceOptions(); } updateDatasourceOptions() { - this.hasQueryHelp = this.current.meta.hasQueryHelp; - this.queryOptions = this.current.meta.queryOptions; + if (this.datasourceInstance) { + this.hasQueryHelp = this.datasourceInstance.meta.hasQueryHelp; + this.queryOptions = this.datasourceInstance.meta.queryOptions; + } } getOptions(includeBuiltin) { @@ -61,7 +64,7 @@ export class MetricsTabCtrl { return; } - this.current = option.datasource; + this.datasourceInstance = option.datasource; this.panelCtrl.setDatasource(option.datasource); this.updateDatasourceOptions(); } @@ -85,7 +88,7 @@ export class MetricsTabCtrl { this.queryTroubleshooterOpen = false; this.helpOpen = !this.helpOpen; - this.backendSrv.get(`/api/plugins/${this.current.meta.id}/markdown/query_help`).then(res => { + this.backendSrv.get(`/api/plugins/${this.datasourceInstance.meta.id}/markdown/query_help`).then(res => { var md = new Remarkable(); this.helpHtml = this.$sce.trustAsHtml(md.render(res)); }); diff --git a/public/app/features/panel/partials/metrics_tab.html b/public/app/features/panel/partials/metrics_tab.html index c3643152716..03a2c374a14 100644 --- a/public/app/features/panel/partials/metrics_tab.html +++ b/public/app/features/panel/partials/metrics_tab.html @@ -73,7 +73,7 @@ -
+
@@ -89,11 +89,11 @@ {{ctrl.panelCtrl.nextRefId}} - -