mirror of
https://github.com/grafana/grafana.git
synced 2025-09-19 04:45:01 +08:00
Merge pull request #6455 from utkarshcmu/opentsdb_template_fix
Fixed multi-value nested templating for opentsdb
This commit is contained in:
@ -145,6 +145,11 @@ describe('templateSrv', function() {
|
|||||||
expect(result).to.be('test|test2');
|
expect(result).to.be('test|test2');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('multi value and distributed should render distributed string', function() {
|
||||||
|
var result = _templateSrv.formatValue(['test','test2'], 'distributed', { name: 'build' });
|
||||||
|
expect(result).to.be('test,build=test2');
|
||||||
|
});
|
||||||
|
|
||||||
it('slash should be properly escaped in regex format', function() {
|
it('slash should be properly escaped in regex format', function() {
|
||||||
var result = _templateSrv.formatValue('Gi3/14', 'regex');
|
var result = _templateSrv.formatValue('Gi3/14', 'regex');
|
||||||
expect(result).to.be('Gi3\\/14');
|
expect(result).to.be('Gi3\\/14');
|
||||||
|
@ -95,6 +95,9 @@ function (angular, _, kbn) {
|
|||||||
}
|
}
|
||||||
return value.join('|');
|
return value.join('|');
|
||||||
}
|
}
|
||||||
|
case "distributed": {
|
||||||
|
return this.distributeVariable(value, variable.name);
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
return value;
|
return value;
|
||||||
@ -210,6 +213,17 @@ function (angular, _, kbn) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.distributeVariable = function(value, variable) {
|
||||||
|
value = _.map(value, function(val, index) {
|
||||||
|
if (index !== 0) {
|
||||||
|
return variable + "=" + val;
|
||||||
|
} else {
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return value.join(',');
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -244,7 +244,7 @@ function (angular, _, dateMath) {
|
|||||||
|
|
||||||
var interpolated;
|
var interpolated;
|
||||||
try {
|
try {
|
||||||
interpolated = templateSrv.replace(query);
|
interpolated = templateSrv.replace(query, {}, 'distributed');
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
return $q.reject(err);
|
return $q.reject(err);
|
||||||
|
Reference in New Issue
Block a user