From ef6ba7bc3d76f9add086b41e819bbda5c8a95dd7 Mon Sep 17 00:00:00 2001 From: German Yepes Date: Thu, 27 Jan 2022 12:41:52 -0300 Subject: [PATCH] fix: support grafana 8.3.x --- dist/datasource.js | 9 ++++++++- src/datasource.js | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/dist/datasource.js b/dist/datasource.js index 528cb6f..3d9749d 100644 --- a/dist/datasource.js +++ b/dist/datasource.js @@ -48,10 +48,17 @@ function (angular, _, dateMath, moment) { console.log(options); var _this = this; - var sets = _.groupBy(options.targets, 'datasource'); var promisesByRefId = {}; var promises = []; var targetsByRefId = {}; + var sets; + + if (typeof (options.targets[0].datasource) === 'object') { + sets = _.groupBy(options.targets, target => target.datasource.uid); + } else { + sets = _.groupBy(options.targets, 'datasource'); + } + _.forEach(sets, function (targets, dsName) { // Grafana (8.x.x) sends datasource name as undefined with mixed plugin made as default datasource // https://github.com/grafana/grafana/issues/36508 diff --git a/src/datasource.js b/src/datasource.js index 528cb6f..3d9749d 100644 --- a/src/datasource.js +++ b/src/datasource.js @@ -48,10 +48,17 @@ function (angular, _, dateMath, moment) { console.log(options); var _this = this; - var sets = _.groupBy(options.targets, 'datasource'); var promisesByRefId = {}; var promises = []; var targetsByRefId = {}; + var sets; + + if (typeof (options.targets[0].datasource) === 'object') { + sets = _.groupBy(options.targets, target => target.datasource.uid); + } else { + sets = _.groupBy(options.targets, 'datasource'); + } + _.forEach(sets, function (targets, dsName) { // Grafana (8.x.x) sends datasource name as undefined with mixed plugin made as default datasource // https://github.com/grafana/grafana/issues/36508