From 1a38c45dde08335086d0c432a40255e30b4d1607 Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Fri, 14 Sep 2018 16:09:43 +0200 Subject: [PATCH] Hotfix for Explore (empty page after running query) Since #13212 adhoc filters are being gathered, in Explore the template service has no variables set and then throws when iterating over them. --- .../app/features/templating/template_srv.ts | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/public/app/features/templating/template_srv.ts b/public/app/features/templating/template_srv.ts index def9fda1f56..70fd287402f 100644 --- a/public/app/features/templating/template_srv.ts +++ b/public/app/features/templating/template_srv.ts @@ -50,18 +50,20 @@ export class TemplateSrv { getAdhocFilters(datasourceName) { let filters = []; - for (let i = 0; i < this.variables.length; i++) { - const variable = this.variables[i]; - if (variable.type !== 'adhoc') { - continue; - } + if (this.variables) { + for (let i = 0; i < this.variables.length; i++) { + const variable = this.variables[i]; + if (variable.type !== 'adhoc') { + continue; + } - // null is the "default" datasource - if (variable.datasource === null || variable.datasource === datasourceName) { - filters = filters.concat(variable.filters); - } else if (variable.datasource.indexOf('$') === 0) { - if (this.replace(variable.datasource) === datasourceName) { + // null is the "default" datasource + if (variable.datasource === null || variable.datasource === datasourceName) { filters = filters.concat(variable.filters); + } else if (variable.datasource.indexOf('$') === 0) { + if (this.replace(variable.datasource) === datasourceName) { + filters = filters.concat(variable.filters); + } } } }