mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix(graphite): minor fix to query editor when using summarize function with no metric segments, only series ref, fixes #2788
This commit is contained in:
parent
6f9c306260
commit
b37f9a7db0
@ -367,6 +367,14 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
|
case 'true': {
|
||||||
|
type = 'bool';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'false': {
|
||||||
|
type = 'bool';
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
type = "identifier";
|
type = "identifier";
|
||||||
}
|
}
|
||||||
@ -379,7 +387,7 @@ define([
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Extract a numeric literal out of the next sequence of
|
* Extract a numeric literal out of the next sequence of
|
||||||
* characters or return 'null' if its not possible. This method
|
* characters or return 'null' if its not possible. This method
|
||||||
* supports all numeric literals described in section 7.8.3
|
* supports all numeric literals described in section 7.8.3
|
||||||
|
@ -156,6 +156,17 @@ define([
|
|||||||
return node;
|
return node;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
boolExpression: function() {
|
||||||
|
if (!this.match('bool')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: 'bool',
|
||||||
|
value: this.consumeToken().value === 'true',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
functionParameters: function () {
|
functionParameters: function () {
|
||||||
if (this.match(')') || this.match('')) {
|
if (this.match(')') || this.match('')) {
|
||||||
return [];
|
return [];
|
||||||
@ -165,6 +176,7 @@ define([
|
|||||||
this.functionCall() ||
|
this.functionCall() ||
|
||||||
this.numericLiteral() ||
|
this.numericLiteral() ||
|
||||||
this.seriesRefExpression() ||
|
this.seriesRefExpression() ||
|
||||||
|
this.boolExpression() ||
|
||||||
this.metricExpression() ||
|
this.metricExpression() ||
|
||||||
this.stringLiteral();
|
this.stringLiteral();
|
||||||
|
|
||||||
|
@ -87,6 +87,7 @@ function (angular, _, config, gfunc, Parser) {
|
|||||||
case 'series-ref':
|
case 'series-ref':
|
||||||
addFunctionParameter(func, astNode.value, index, $scope.segments.length > 0);
|
addFunctionParameter(func, astNode.value, index, $scope.segments.length > 0);
|
||||||
break;
|
break;
|
||||||
|
case 'bool':
|
||||||
case 'string':
|
case 'string':
|
||||||
case 'number':
|
case 'number':
|
||||||
if ((index-1) >= func.def.params.length) {
|
if ((index-1) >= func.def.params.length) {
|
||||||
|
@ -109,6 +109,14 @@ define([
|
|||||||
expect(tokens[4].value).to.be('0.002');
|
expect(tokens[4].value).to.be('0.002');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle bool parameters', function() {
|
||||||
|
var lexer = new Lexer("alias(metric, true, false)");
|
||||||
|
var tokens = lexer.tokenize();
|
||||||
|
expect(tokens[4].type).to.be('bool');
|
||||||
|
expect(tokens[4].value).to.be('true');
|
||||||
|
expect(tokens[6].type).to.be('bool');
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -165,6 +165,15 @@ define([
|
|||||||
expect(rootNode.params[1].value).to.be('#B');
|
expect(rootNode.params[1].value).to.be('#B');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('series parameters, issue 2788', function() {
|
||||||
|
var parser = new Parser("summarize(diffSeries(#A, #B), '10m', 'sum', false)");
|
||||||
|
var rootNode = parser.getAst();
|
||||||
|
expect(rootNode.type).to.be('function');
|
||||||
|
expect(rootNode.params[0].type).to.be('function');
|
||||||
|
expect(rootNode.params[1].value).to.be('10m');
|
||||||
|
expect(rootNode.params[3].type).to.be('bool');
|
||||||
|
});
|
||||||
|
|
||||||
it('should parse metric expression with ip number segments', function() {
|
it('should parse metric expression with ip number segments', function() {
|
||||||
var parser = new Parser('5.10.123.5');
|
var parser = new Parser('5.10.123.5');
|
||||||
var rootNode = parser.getAst();
|
var rootNode = parser.getAst();
|
||||||
|
Loading…
Reference in New Issue
Block a user