mirror of https://github.com/grafana/grafana.git
refactor(influxdb): refactoring of PR 2477, added unit tests, #2477
This commit is contained in:
parent
ca6476a57f
commit
e7fc72067a
|
@ -8,6 +8,9 @@
|
||||||
- [Issue #2461](https://github.com/grafana/grafana/issues/2461). LDAP: Fix for ldap users with empty email address
|
- [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.
|
- [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.
|
||||||
|
|
||||||
|
**Enhancements**
|
||||||
|
- [Issue #2477](https://github.com/grafana/grafana/issues/2477). InfluxDB: Added more condition operators (`<`, `>`, `<>`, `!~`), thx @thuck
|
||||||
|
|
||||||
# 2.1.0 (2015-08-04)
|
# 2.1.0 (2015-08-04)
|
||||||
|
|
||||||
**Data sources**
|
**Data sources**
|
||||||
|
|
|
@ -68,7 +68,7 @@ function (angular, app, _, $) {
|
||||||
else {
|
else {
|
||||||
// need to have long delay because the blur
|
// need to have long delay because the blur
|
||||||
// happens long before the click event on the typeahead options
|
// happens long before the click event on the typeahead options
|
||||||
cancelBlur = setTimeout($scope.switchToLink, 50);
|
cancelBlur = setTimeout($scope.switchToLink, 100);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -92,6 +92,7 @@ function (angular, app, _, $) {
|
||||||
|
|
||||||
$scope.updater = function(value) {
|
$scope.updater = function(value) {
|
||||||
if (value === segment.value) {
|
if (value === segment.value) {
|
||||||
|
console.log('cancel blur');
|
||||||
clearTimeout(cancelBlur);
|
clearTimeout(cancelBlur);
|
||||||
$input.focus();
|
$input.focus();
|
||||||
return value;
|
return value;
|
||||||
|
|
|
@ -10,18 +10,26 @@ function (_) {
|
||||||
|
|
||||||
function renderTagCondition (tag, index) {
|
function renderTagCondition (tag, index) {
|
||||||
var str = "";
|
var str = "";
|
||||||
var operator = (tag.operator || '=');
|
var operator = tag.operator;
|
||||||
|
var value = tag.value;
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
str = (tag.condition || 'AND') + ' ';
|
str = (tag.condition || 'AND') + ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.value && (operator === '=~' || operator === '!~') && /^\/.*\/$/.test(tag.value)) {
|
if (!operator) {
|
||||||
return str + '"' + tag.key + '"' + ' ' + operator + ' ' + tag.value;
|
if (/^\/.*\/$/.test(tag.value)) {
|
||||||
} else if (tag.value && /^\/.*\/$/.test(tag.value)) {
|
operator = '=~';
|
||||||
return str + '"' + tag.key + '"' + ' =~ ' + tag.value;
|
} else {
|
||||||
|
operator = '=';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return str + '"' + tag.key + '" ' + operator + " '" + tag.value + "'";
|
// quote value unless regex
|
||||||
|
if (operator !== '=~' && operator !== '!~') {
|
||||||
|
value = "'" + value + "'";
|
||||||
|
}
|
||||||
|
|
||||||
|
return str + '"' + tag.key + '" ' + operator + ' ' + value;
|
||||||
}
|
}
|
||||||
|
|
||||||
var p = InfluxQueryBuilder.prototype;
|
var p = InfluxQueryBuilder.prototype;
|
||||||
|
|
|
@ -31,17 +31,19 @@ function (angular, _, InfluxQueryBuilder) {
|
||||||
|
|
||||||
$scope.tagSegments = [];
|
$scope.tagSegments = [];
|
||||||
_.each(target.tags, function(tag) {
|
_.each(target.tags, function(tag) {
|
||||||
|
if (!tag.operator) {
|
||||||
|
if (/^\/.*\/$/.test(tag.value)) {
|
||||||
|
tag.operator = "=~";
|
||||||
|
} else {
|
||||||
|
tag.operator = '=';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tag.condition) {
|
if (tag.condition) {
|
||||||
$scope.tagSegments.push(MetricSegment.newCondition(tag.condition));
|
$scope.tagSegments.push(MetricSegment.newCondition(tag.condition));
|
||||||
}
|
}
|
||||||
$scope.tagSegments.push(new MetricSegment({value: tag.key, type: 'key', cssClass: 'query-segment-key' }));
|
$scope.tagSegments.push(new MetricSegment({value: tag.key, type: 'key', cssClass: 'query-segment-key' }));
|
||||||
if (tag.operator) {
|
|
||||||
$scope.tagSegments.push(MetricSegment.newOperator(tag.operator));
|
$scope.tagSegments.push(MetricSegment.newOperator(tag.operator));
|
||||||
} else if (/^\/.*\/$/.test(tag.value)) {
|
|
||||||
$scope.tagSegments.push(MetricSegment.newOperator('=~'));
|
|
||||||
} else {
|
|
||||||
$scope.tagSegments.push(MetricSegment.newOperator('='));
|
|
||||||
}
|
|
||||||
$scope.tagSegments.push(new MetricSegment({value: tag.value, type: 'value', cssClass: 'query-segment-value'}));
|
$scope.tagSegments.push(new MetricSegment({value: tag.value, type: 'value', cssClass: 'query-segment-value'}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,10 @@ define([
|
||||||
expect(ctx.scope.target.tags[0].value).to.be('server1');
|
expect(ctx.scope.target.tags[0].value).to.be('server1');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should set tag operator', function() {
|
||||||
|
expect(ctx.scope.target.tags[0].operator).to.be('=');
|
||||||
|
});
|
||||||
|
|
||||||
it('should add plus button for another filter', function() {
|
it('should add plus button for another filter', function() {
|
||||||
expect(ctx.scope.tagSegments[3].fake).to.be(true);
|
expect(ctx.scope.tagSegments[3].fake).to.be(true);
|
||||||
});
|
});
|
||||||
|
@ -74,6 +78,7 @@ define([
|
||||||
|
|
||||||
it('should update operator', function() {
|
it('should update operator', function() {
|
||||||
expect(ctx.scope.tagSegments[1].value).to.be('=~');
|
expect(ctx.scope.tagSegments[1].value).to.be('=~');
|
||||||
|
expect(ctx.scope.target.tags[0].operator).to.be('=~');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue