diff --git a/src/module.ts b/src/module.ts index c1d42fa..05df6b5 100644 --- a/src/module.ts +++ b/src/module.ts @@ -59,20 +59,32 @@ class Ctrl extends PanelCtrl { this.timeSrv = $injector.get('timeSrv'); appEvents.on('ds-request-response', data => { - let requestConfig = data.config; - let datasourceIdRegExp = requestConfig.url.match(/proxy\/(\d+)/); - if(datasourceIdRegExp === null) { - throw new Error(`Cannot find datasource id in url ${requestConfig.url}`); + const requestConfig = data.config; + const isSqlDatasource = requestConfig.data !== undefined && + requestConfig.data.queries !== undefined; + + if(isSqlDatasource) { + for(let query of requestConfig.data.queries) { + this._datasourceRequests[query.datasourceId] = { + url: query.url, + method: query.method, + data: query.data, + params: query.params + }; + } + } else { + let matched = requestConfig.url.match(/proxy\/(\d+)/); + if(matched === null) { + throw new Error(`Cannot find datasource id in url ${requestConfig.url}`); + } + let datasourceId = matched[1]; + this._datasourceRequests[datasourceId] = { + url: requestConfig.url, + method: requestConfig.method, + data: requestConfig.data, + params: requestConfig.params + }; } - - let datasourceId = datasourceIdRegExp[1]; - - this._datasourceRequests[datasourceId] = { - url: requestConfig.url, - method: requestConfig.method, - data: requestConfig.data, - params: requestConfig.params - }; }); this.showRows = {};