diff --git a/src/panel-triggers/editor.js b/src/panel-triggers/editor.js index 97d2b85..d8f2736 100644 --- a/src/panel-triggers/editor.js +++ b/src/panel-triggers/editor.js @@ -61,13 +61,8 @@ class TriggerPanelEditorCtrl { }; _.defaults(this, scopeDefaults); - // Get zabbix data sources - var datasources = _.filter(this.datasourceSrv.getMetricSources(), datasource => { - return datasource.meta.id === 'alexanderzobnin-zabbix-datasource'; - }); - this.datasources = _.map(datasources, 'name'); - // Set default datasource + this.datasources = _.map(this.getZabbixDataSources(), 'name'); if (!this.panel.datasource) { this.panel.datasource = this.datasources[0]; } @@ -170,6 +165,13 @@ class TriggerPanelEditorCtrl { isVariable(str) { return utils.isTemplateVariable(str, this.templateSrv.variables); } + + getZabbixDataSources() { + let ZABBIX_DS_ID = 'alexanderzobnin-zabbix-datasource'; + return _.filter(this.datasourceSrv.getMetricSources(), datasource => { + return datasource.meta.id === ZABBIX_DS_ID && datasource.value; + }); + } } // Get list of metric names for bs-typeahead directive