From 10012f8ffe8cfbec62c37d7e99c7758c8a86ab6d Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Thu, 15 Mar 2018 17:23:28 +0900 Subject: [PATCH] support [[var]] notation --- .../datasource/prometheus/completer.ts | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/public/app/plugins/datasource/prometheus/completer.ts b/public/app/plugins/datasource/prometheus/completer.ts index 32d12e47ac1..ff8e0acc6df 100644 --- a/public/app/plugins/datasource/prometheus/completer.ts +++ b/public/app/plugins/datasource/prometheus/completer.ts @@ -13,14 +13,24 @@ export class PromCompleter { this.labelQueryCache = {}; this.labelNameCache = {}; this.labelValueCache = {}; - this.templateVariableCompletions = this.templateSrv.variables.map(variable => { - return { - caption: '$' + variable.name, - value: '$' + variable.name, - meta: 'variable.other', - score: Number.MAX_VALUE, - }; - }); + this.templateVariableCompletions = _.flatten( + this.templateSrv.variables.map(variable => { + return [ + { + caption: '$' + variable.name, + value: '$' + variable.name, + meta: 'variable.other', + score: Number.MAX_VALUE, + }, + { + caption: '[[' + variable.name + ']', + value: '[[' + variable.name + ']', + meta: 'variable.other', + score: Number.MAX_VALUE, + }, + ]; + }) + ); } getCompletions(editor, session, pos, prefix, callback) {