Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to support grafana 7.x versions #118

Merged
merged 5 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions dist/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,25 @@ function (angular, _, dateMath, moment) {
var _promisesByRefId = simpleHashCopyForPromises(promisesByRefId);
var _targetsByRefId = simpleHashCopyForPromises(targetsByRefId);

//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)
}
else{
opt.targets = targets;
return ds.query(opt);
var ds_res = ds.query(opt);
if(ds_res.then){
return ds_res;
}
else{
return 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){
Expand All @@ -78,7 +85,13 @@ function (angular, _, dateMath, moment) {
var nonHiddenTarget = angular.copy(target);
nonHiddenTarget.hide = false;
opt.targets = [nonHiddenTarget];
return ds.query(opt);
var ds_res = ds.query(opt);
if(ds_res.then){
return ds_res;
}
else{
return ds_res.toPromise();
}
}
});
}
Expand Down
19 changes: 16 additions & 3 deletions src/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,25 @@ function (angular, _, dateMath, moment) {
var _promisesByRefId = simpleHashCopyForPromises(promisesByRefId);
var _targetsByRefId = simpleHashCopyForPromises(targetsByRefId);

//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)
}
else{
opt.targets = targets;
return ds.query(opt);
var ds_res = ds.query(opt);
if(ds_res.then){
return ds_res;
}
else{
return 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){
Expand All @@ -78,7 +85,13 @@ function (angular, _, dateMath, moment) {
var nonHiddenTarget = angular.copy(target);
nonHiddenTarget.hide = false;
opt.targets = [nonHiddenTarget];
return ds.query(opt);
var ds_res = ds.query(opt);
if(ds_res.then){
return ds_res;
}
else{
return ds_res.toPromise();
}
}
});
}
Expand Down