Przeglądaj źródła

fix(graphite): Fix for bug when using series ref (#A-Z) and referenced series is hidden in query editor. fixes #2484

Torkel Ödegaard 10 lat temu
rodzic
commit
fb9f954882

+ 1 - 0
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)
 

+ 4 - 2
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) {

+ 7 - 0
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)'}]