From 91fb3f2224cd9e228ad516ec4b232bd89cfa1839 Mon Sep 17 00:00:00 2001 From: Jesse White Date: Fri, 1 Sep 2017 01:19:51 -0400 Subject: [PATCH 01/27] fix: cancel the initial timer when changing the auto-refresh interval, fixes #9139 (#9140) --- public/app/features/dashboard/time_srv.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/public/app/features/dashboard/time_srv.ts b/public/app/features/dashboard/time_srv.ts index abde4152b63..2c16915b5aa 100644 --- a/public/app/features/dashboard/time_srv.ts +++ b/public/app/features/dashboard/time_srv.ts @@ -116,16 +116,14 @@ class TimeSrv { setAutoRefresh(interval) { this.dashboard.refresh = interval; + this.cancelNextRefresh(); if (interval) { var intervalMs = kbn.interval_to_ms(interval); - this.$timeout(() => { + this.refreshTimer = this.timer.register(this.$timeout(() => { this.startNextRefreshTimer(intervalMs); this.refreshDashboard(); - }, intervalMs); - - } else { - this.cancelNextRefresh(); + }, intervalMs)); } // update url From b349b3ef5574a797d69cb28d9023aa1e98ba0b8b Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Wed, 13 Sep 2017 16:29:53 +0900 Subject: [PATCH 02/27] provide ace editor for external datasource plugin (#9224) --- .../app/core/components/code_editor/code_editor.ts | 13 +++++++++---- .../datasource/prometheus}/mode-prometheus.js | 0 .../prometheus/partials/query.editor.html | 2 +- .../datasource/prometheus}/snippets/prometheus.js | 0 4 files changed, 10 insertions(+), 5 deletions(-) rename public/app/{core/components/code_editor => plugins/datasource/prometheus}/mode-prometheus.js (100%) rename public/app/{core/components/code_editor => plugins/datasource/prometheus}/snippets/prometheus.js (100%) diff --git a/public/app/core/components/code_editor/code_editor.ts b/public/app/core/components/code_editor/code_editor.ts index 7c41eb3b3a2..61ebb17d9b3 100644 --- a/public/app/core/components/code_editor/code_editor.ts +++ b/public/app/core/components/code_editor/code_editor.ts @@ -40,11 +40,11 @@ const DEFAULT_MAX_LINES = 10; const DEFAULT_TAB_SIZE = 2; const DEFAULT_BEHAVIOURS = true; -const GRAFANA_MODULES = ['mode-prometheus', 'snippets-prometheus', 'theme-grafana-dark']; +const GRAFANA_MODULES = ['theme-grafana-dark']; const GRAFANA_MODULE_BASE = "public/app/core/components/code_editor/"; // Trick for loading additional modules -function setModuleUrl(moduleType, name) { +function setModuleUrl(moduleType, name, pluginBaseUrl = null) { let baseUrl = ACE_SRC_BASE; let aceModeName = `ace/${moduleType}/${name}`; let moduleName = `${moduleType}-${name}`; @@ -54,6 +54,10 @@ function setModuleUrl(moduleType, name) { baseUrl = GRAFANA_MODULE_BASE; } + if (pluginBaseUrl) { + baseUrl = pluginBaseUrl + '/'; + } + if (moduleType === 'snippets') { componentName = `${moduleType}/${name}.js`; } @@ -159,8 +163,8 @@ function link(scope, elem, attrs) { function setLangMode(lang) { let aceModeName = `ace/mode/${lang}`; - setModuleUrl("mode", lang); - setModuleUrl("snippets", lang); + setModuleUrl("mode", lang, scope.datasource.meta.baseUrl || null); + setModuleUrl("snippets", lang, scope.datasource.meta.baseUrl || null); editorSession.setMode(aceModeName); ace.config.loadModule("ace/ext/language_tools", (language_tools) => { @@ -210,6 +214,7 @@ export function codeEditorDirective() { template: editorTemplate, scope: { content: "=", + datasource: "=", codeEditorFocus: "<", onChange: "&", getCompleter: "&" diff --git a/public/app/core/components/code_editor/mode-prometheus.js b/public/app/plugins/datasource/prometheus/mode-prometheus.js similarity index 100% rename from public/app/core/components/code_editor/mode-prometheus.js rename to public/app/plugins/datasource/prometheus/mode-prometheus.js diff --git a/public/app/plugins/datasource/prometheus/partials/query.editor.html b/public/app/plugins/datasource/prometheus/partials/query.editor.html index a34a752bd95..9b06d4116f4 100644 --- a/public/app/plugins/datasource/prometheus/partials/query.editor.html +++ b/public/app/plugins/datasource/prometheus/partials/query.editor.html @@ -1,7 +1,7 @@
-
diff --git a/public/app/core/components/code_editor/snippets/prometheus.js b/public/app/plugins/datasource/prometheus/snippets/prometheus.js similarity index 100% rename from public/app/core/components/code_editor/snippets/prometheus.js rename to public/app/plugins/datasource/prometheus/snippets/prometheus.js 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 03/27] 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}} - -