From fb9f9548829f2d4cecf35cda933700e5c2fa1bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 10 Aug 2015 07:59:27 +0200 Subject: [PATCH] fix(graphite): Fix for bug when using series ref (#A-Z) and referenced series is hidden in query editor. fixes #2484 --- CHANGELOG.md | 1 + public/app/plugins/datasource/graphite/datasource.js | 6 ++++-- public/test/specs/graphiteDatasource-specs.js | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db92105c031..2157a33eb01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [Issue #2446](https://github.com/grafana/grafana/issues/2446). InfluxDB: Fix for using template vars inside alias field (InfluxDB 0.9) - [Issue #2460](https://github.com/grafana/grafana/issues/2460). SinglestatPanel: Fix to handle series with no data points - [Issue #2461](https://github.com/grafana/grafana/issues/2461). LDAP: Fix for ldap users with empty email address +- [Issue #2484](https://github.com/grafana/grafana/issues/2484). Graphite: Fix bug when using series ref (#A-Z) and referenced series is hidden in query editor. # 2.1.0 (2015-08-04) diff --git a/public/app/plugins/datasource/graphite/datasource.js b/public/app/plugins/datasource/graphite/datasource.js index a3255584879..e9f2a6efe5d 100644 --- a/public/app/plugins/datasource/graphite/datasource.js +++ b/public/app/plugins/datasource/graphite/datasource.js @@ -270,7 +270,7 @@ function (angular, _, $, config, kbn, moment) { for (i = 0; i < options.targets.length; i++) { target = options.targets[i]; - if (!target.target || target.hide) { + if (!target.target) { continue; } @@ -278,7 +278,9 @@ function (angular, _, $, config, kbn, moment) { targetValue = targetValue.replace(regex, nestedSeriesRegexReplacer); targets[this._seriesRefLetters[i]] = targetValue; - clean_options.push("target=" + encodeURIComponent(targetValue)); + if (!target.hide) { + clean_options.push("target=" + encodeURIComponent(targetValue)); + } } _.each(options, function (value, key) { diff --git a/public/test/specs/graphiteDatasource-specs.js b/public/test/specs/graphiteDatasource-specs.js index b82d2a4a7cd..b13889dcbbf 100644 --- a/public/test/specs/graphiteDatasource-specs.js +++ b/public/test/specs/graphiteDatasource-specs.js @@ -79,6 +79,13 @@ define([ expect(results[2]).to.be('target=asPercent(series1%2Cseries2)'); }); + it('should replace target placeholder for hidden series', function() { + var results = ctx.ds.buildGraphiteParams({ + targets: [{target: 'series1', hide: true}, {target: 'sumSeries(#A)', hide: true}, {target: 'asPercent(#A,#B)'}] + }); + expect(results[0]).to.be('target=' + encodeURIComponent('asPercent(series1,sumSeries(series1))')); + }); + it('should replace target placeholder when nesting query references', function() { var results = ctx.ds.buildGraphiteParams({ targets: [{target: 'series1'}, {target: 'sumSeries(#A)'}, {target: 'asPercent(#A,#B)'}]