diff --git a/public/app/features/templating/partials/editor.html b/public/app/features/templating/partials/editor.html
index a1dab0a6c36..63ecd00adcf 100644
--- a/public/app/features/templating/partials/editor.html
+++ b/public/app/features/templating/partials/editor.html
@@ -186,7 +186,7 @@
All format
-
+
@@ -217,7 +217,7 @@
Multi format
-
+
diff --git a/public/app/features/templating/templateSrv.js b/public/app/features/templating/templateSrv.js
index 0880df1a0c4..48aa4edde85 100644
--- a/public/app/features/templating/templateSrv.js
+++ b/public/app/features/templating/templateSrv.js
@@ -46,6 +46,9 @@ function (angular, _) {
case "lucene": {
return '(' + value.join(' OR ') + ')';
}
+ case "pipe": {
+ return value.join('|');
+ }
default: {
return '{' + value.join(',') + '}';
}
diff --git a/public/app/features/templating/templateValuesSrv.js b/public/app/features/templating/templateValuesSrv.js
index a3300853065..5ec9ae85e4a 100644
--- a/public/app/features/templating/templateValuesSrv.js
+++ b/public/app/features/templating/templateValuesSrv.js
@@ -271,6 +271,10 @@ function (angular, _, kbn) {
}).join('|') + ')';
break;
}
+ case 'pipe': {
+ allValue = _.pluck(variable.options, 'text').join('|');
+ break;
+ }
default: {
allValue = '{';
allValue += _.pluck(variable.options, 'text').join(',');
diff --git a/public/test/specs/templateSrv-specs.js b/public/test/specs/templateSrv-specs.js
index 1b43adff63e..36f303e55c6 100644
--- a/public/test/specs/templateSrv-specs.js
+++ b/public/test/specs/templateSrv-specs.js
@@ -81,6 +81,16 @@ define([
expect(result).to.be('(test|test2)');
});
+ it('multi value and pipe should render pipe string', function() {
+ var result = _templateSrv.renderVariableValue({
+ multiFormat: 'pipe',
+ current: {
+ value: ['test','test2'],
+ }
+ });
+ expect(result).to.be('test|test2');
+ });
+
});
describe('can check if variable exists', function() {
diff --git a/public/test/specs/templateValuesSrv-specs.js b/public/test/specs/templateValuesSrv-specs.js
index feb13c37130..4c5b7e19a69 100644
--- a/public/test/specs/templateValuesSrv-specs.js
+++ b/public/test/specs/templateValuesSrv-specs.js
@@ -349,6 +349,17 @@ define([
});
});
+ describeUpdateVariable('with include all pipe all values', function(scenario) {
+ scenario.setup(function() {
+ scenario.variable = { type: 'query', query: 'apps.*', name: 'test', includeAll: true, allFormat: 'pipe' };
+ scenario.queryResult = [{text: 'backend1'}, {text: 'backend2'}, { text: 'backend3'}];
+ });
+
+ it('should add pipe delimited string', function() {
+ expect(scenario.variable.options[0].value).to.be('backend1|backend2|backend3');
+ });
+ });
+
});
});