mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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 #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)
|
||||
|
||||
**Data sources**
|
||||
|
@ -68,7 +68,7 @@ function (angular, app, _, $) {
|
||||
else {
|
||||
// need to have long delay because the blur
|
||||
// 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) {
|
||||
if (value === segment.value) {
|
||||
console.log('cancel blur');
|
||||
clearTimeout(cancelBlur);
|
||||
$input.focus();
|
||||
return value;
|
||||
|
@ -10,18 +10,26 @@ function (_) {
|
||||
|
||||
function renderTagCondition (tag, index) {
|
||||
var str = "";
|
||||
var operator = (tag.operator || '=');
|
||||
var operator = tag.operator;
|
||||
var value = tag.value;
|
||||
if (index > 0) {
|
||||
str = (tag.condition || 'AND') + ' ';
|
||||
}
|
||||
|
||||
if (tag.value && (operator === '=~' || operator === '!~') && /^\/.*\/$/.test(tag.value)) {
|
||||
return str + '"' + tag.key + '"' + ' ' + operator + ' ' + tag.value;
|
||||
} else if (tag.value && /^\/.*\/$/.test(tag.value)) {
|
||||
return str + '"' + tag.key + '"' + ' =~ ' + tag.value;
|
||||
if (!operator) {
|
||||
if (/^\/.*\/$/.test(tag.value)) {
|
||||
operator = '=~';
|
||||
} 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;
|
||||
|
@ -31,17 +31,19 @@ function (angular, _, InfluxQueryBuilder) {
|
||||
|
||||
$scope.tagSegments = [];
|
||||
_.each(target.tags, function(tag) {
|
||||
if (!tag.operator) {
|
||||
if (/^\/.*\/$/.test(tag.value)) {
|
||||
tag.operator = "=~";
|
||||
} else {
|
||||
tag.operator = '=';
|
||||
}
|
||||
}
|
||||
|
||||
if (tag.condition) {
|
||||
$scope.tagSegments.push(MetricSegment.newCondition(tag.condition));
|
||||
}
|
||||
$scope.tagSegments.push(new MetricSegment({value: tag.key, type: 'key', cssClass: 'query-segment-key' }));
|
||||
if (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(MetricSegment.newOperator(tag.operator));
|
||||
$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');
|
||||
});
|
||||
|
||||
it('should set tag operator', function() {
|
||||
expect(ctx.scope.target.tags[0].operator).to.be('=');
|
||||
});
|
||||
|
||||
it('should add plus button for another filter', function() {
|
||||
expect(ctx.scope.tagSegments[3].fake).to.be(true);
|
||||
});
|
||||
@ -74,6 +78,7 @@ define([
|
||||
|
||||
it('should update operator', function() {
|
||||
expect(ctx.scope.tagSegments[1].value).to.be('=~');
|
||||
expect(ctx.scope.target.tags[0].operator).to.be('=~');
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user