From fc70d93f24b667c1320d62096806c155b117a9d6 Mon Sep 17 00:00:00 2001 From: Craig Ching Date: Wed, 7 Oct 2020 17:27:29 -0500 Subject: [PATCH 1/5] Fixes the plugin for grafana 7.1.x --- dist/datasource.js | 4 ++-- src/datasource.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/datasource.js b/dist/datasource.js index cf62c29..e3241f5 100644 --- a/dist/datasource.js +++ b/dist/datasource.js @@ -64,7 +64,7 @@ function (angular, _, dateMath, moment) { } else{ opt.targets = targets; - return ds.query(opt); + return ds.query(opt).toPromise(); } }); @@ -78,7 +78,7 @@ function (angular, _, dateMath, moment) { var nonHiddenTarget = angular.copy(target); nonHiddenTarget.hide = false; opt.targets = [nonHiddenTarget]; - return ds.query(opt); + return ds.query(opt).toPromise(); } }); } diff --git a/src/datasource.js b/src/datasource.js index cf62c29..e3241f5 100644 --- a/src/datasource.js +++ b/src/datasource.js @@ -64,7 +64,7 @@ function (angular, _, dateMath, moment) { } else{ opt.targets = targets; - return ds.query(opt); + return ds.query(opt).toPromise(); } }); @@ -78,7 +78,7 @@ function (angular, _, dateMath, moment) { var nonHiddenTarget = angular.copy(target); nonHiddenTarget.hide = false; opt.targets = [nonHiddenTarget]; - return ds.query(opt); + return ds.query(opt).toPromise(); } }); } From 6e3ec66cd5a1bdf40beac91e7f185a91d5cc624b Mon Sep 17 00:00:00 2001 From: shilpa Date: Thu, 7 Jan 2021 04:05:25 -0800 Subject: [PATCH 2/5] fix_to_support_grafana_7.x_versions --- dist/datasource.js | 16 ++++++++++++++-- src/datasource.js | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/dist/datasource.js b/dist/datasource.js index e3241f5..a71a481 100644 --- a/dist/datasource.js +++ b/dist/datasource.js @@ -64,7 +64,13 @@ function (angular, _, dateMath, moment) { } else{ opt.targets = targets; - return ds.query(opt).toPromise(); + ds_res = ds.query(opt); + if(ds_res.then){ + return ds_res; + } + else{ + return ds_res.toPromise(); + } } }); @@ -78,7 +84,13 @@ function (angular, _, dateMath, moment) { var nonHiddenTarget = angular.copy(target); nonHiddenTarget.hide = false; opt.targets = [nonHiddenTarget]; - return ds.query(opt).toPromise(); + ds_res = ds.query(opt); + if(ds_res.then){ + return ds_res; + } + else{ + return ds_res.toPromise(); + } } }); } diff --git a/src/datasource.js b/src/datasource.js index e3241f5..a71a481 100644 --- a/src/datasource.js +++ b/src/datasource.js @@ -64,7 +64,13 @@ function (angular, _, dateMath, moment) { } else{ opt.targets = targets; - return ds.query(opt).toPromise(); + ds_res = ds.query(opt); + if(ds_res.then){ + return ds_res; + } + else{ + return ds_res.toPromise(); + } } }); @@ -78,7 +84,13 @@ function (angular, _, dateMath, moment) { var nonHiddenTarget = angular.copy(target); nonHiddenTarget.hide = false; opt.targets = [nonHiddenTarget]; - return ds.query(opt).toPromise(); + ds_res = ds.query(opt); + if(ds_res.then){ + return ds_res; + } + else{ + return ds_res.toPromise(); + } } }); } From 215118f6cccdea5e36c7ea1970d1bec8d66df9b3 Mon Sep 17 00:00:00 2001 From: shilpa Date: Thu, 7 Jan 2021 04:16:28 -0800 Subject: [PATCH 3/5] adding comments --- dist/datasource.js | 3 ++- src/datasource.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/datasource.js b/dist/datasource.js index a71a481..48deffa 100644 --- a/dist/datasource.js +++ b/dist/datasource.js @@ -58,6 +58,7 @@ function (angular, _, dateMath, moment) { var _promisesByRefId = simpleHashCopyForPromises(promisesByRefId); var _targetsByRefId = simpleHashCopyForPromises(targetsByRefId); + //grafana 7.x requires to return the ds as promise. Since older plugins doesnt converts to promise Added ds_res.toPromise(). promise = _this.datasourceSrv.get(dsName).then(function (ds) { if (ds.meta.id === _this.meta.id) { return _this._doQuery(targets, _promisesByRefId, opt, _targetsByRefId) @@ -75,7 +76,7 @@ function (angular, _, dateMath, moment) { }); - + //grafana 7.x requires to return the ds as promise. Since older plugins doesnt converts to promise Added ds_res.toPromise(). _.forEach(targets,function(target){ var nonHiddenTargetPromise = promise; if(target.hide===true){ diff --git a/src/datasource.js b/src/datasource.js index a71a481..48deffa 100644 --- a/src/datasource.js +++ b/src/datasource.js @@ -58,6 +58,7 @@ function (angular, _, dateMath, moment) { var _promisesByRefId = simpleHashCopyForPromises(promisesByRefId); var _targetsByRefId = simpleHashCopyForPromises(targetsByRefId); + //grafana 7.x requires to return the ds as promise. Since older plugins doesnt converts to promise Added ds_res.toPromise(). promise = _this.datasourceSrv.get(dsName).then(function (ds) { if (ds.meta.id === _this.meta.id) { return _this._doQuery(targets, _promisesByRefId, opt, _targetsByRefId) @@ -75,7 +76,7 @@ function (angular, _, dateMath, moment) { }); - + //grafana 7.x requires to return the ds as promise. Since older plugins doesnt converts to promise Added ds_res.toPromise(). _.forEach(targets,function(target){ var nonHiddenTargetPromise = promise; if(target.hide===true){ From 4862e9e55173d376b255bed0e29cbe6f9e69deee Mon Sep 17 00:00:00 2001 From: shilpa Date: Thu, 7 Jan 2021 04:20:45 -0800 Subject: [PATCH 4/5] adding comments --- dist/datasource.js | 4 ++-- src/datasource.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/datasource.js b/dist/datasource.js index 48deffa..a907dc5 100644 --- a/dist/datasource.js +++ b/dist/datasource.js @@ -58,7 +58,7 @@ function (angular, _, dateMath, moment) { var _promisesByRefId = simpleHashCopyForPromises(promisesByRefId); var _targetsByRefId = simpleHashCopyForPromises(targetsByRefId); - //grafana 7.x requires to return the ds as promise. Since older plugins doesnt converts to promise Added ds_res.toPromise(). + //grafana 7.x requires ds_res as promise. Since older plugins doesnt converts to promise, added ds_res.toPromise(). promise = _this.datasourceSrv.get(dsName).then(function (ds) { if (ds.meta.id === _this.meta.id) { return _this._doQuery(targets, _promisesByRefId, opt, _targetsByRefId) @@ -76,7 +76,7 @@ function (angular, _, dateMath, moment) { }); - //grafana 7.x requires to return the ds as promise. Since older plugins doesnt converts to promise Added ds_res.toPromise(). + //grafana 7.x requires ds_res as promise. Since older plugins doesnt converts to promise, added ds_res.toPromise(). _.forEach(targets,function(target){ var nonHiddenTargetPromise = promise; if(target.hide===true){ diff --git a/src/datasource.js b/src/datasource.js index 48deffa..a907dc5 100644 --- a/src/datasource.js +++ b/src/datasource.js @@ -58,7 +58,7 @@ function (angular, _, dateMath, moment) { var _promisesByRefId = simpleHashCopyForPromises(promisesByRefId); var _targetsByRefId = simpleHashCopyForPromises(targetsByRefId); - //grafana 7.x requires to return the ds as promise. Since older plugins doesnt converts to promise Added ds_res.toPromise(). + //grafana 7.x requires ds_res as promise. Since older plugins doesnt converts to promise, added ds_res.toPromise(). promise = _this.datasourceSrv.get(dsName).then(function (ds) { if (ds.meta.id === _this.meta.id) { return _this._doQuery(targets, _promisesByRefId, opt, _targetsByRefId) @@ -76,7 +76,7 @@ function (angular, _, dateMath, moment) { }); - //grafana 7.x requires to return the ds as promise. Since older plugins doesnt converts to promise Added ds_res.toPromise(). + //grafana 7.x requires ds_res as promise. Since older plugins doesnt converts to promise, added ds_res.toPromise(). _.forEach(targets,function(target){ var nonHiddenTargetPromise = promise; if(target.hide===true){ From 232ccb98e7f445c180c42b67b9678e226949d14a Mon Sep 17 00:00:00 2001 From: shilpa Date: Thu, 7 Jan 2021 04:25:52 -0800 Subject: [PATCH 5/5] ds_res fix --- dist/datasource.js | 4 ++-- src/datasource.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/datasource.js b/dist/datasource.js index a907dc5..429e0e1 100644 --- a/dist/datasource.js +++ b/dist/datasource.js @@ -65,7 +65,7 @@ function (angular, _, dateMath, moment) { } else{ opt.targets = targets; - ds_res = ds.query(opt); + var ds_res = ds.query(opt); if(ds_res.then){ return ds_res; } @@ -85,7 +85,7 @@ function (angular, _, dateMath, moment) { var nonHiddenTarget = angular.copy(target); nonHiddenTarget.hide = false; opt.targets = [nonHiddenTarget]; - ds_res = ds.query(opt); + var ds_res = ds.query(opt); if(ds_res.then){ return ds_res; } diff --git a/src/datasource.js b/src/datasource.js index a907dc5..429e0e1 100644 --- a/src/datasource.js +++ b/src/datasource.js @@ -65,7 +65,7 @@ function (angular, _, dateMath, moment) { } else{ opt.targets = targets; - ds_res = ds.query(opt); + var ds_res = ds.query(opt); if(ds_res.then){ return ds_res; } @@ -85,7 +85,7 @@ function (angular, _, dateMath, moment) { var nonHiddenTarget = angular.copy(target); nonHiddenTarget.hide = false; opt.targets = [nonHiddenTarget]; - ds_res = ds.query(opt); + var ds_res = ds.query(opt); if(ds_res.then){ return ds_res; }