Skip to content

Commit

Permalink
Merge pull request #34 from CorpGlory/mysql-postgresql-support-#33
Browse files Browse the repository at this point in the history
MySQL / PostgreSQL support #33
  • Loading branch information
amper43 authored Jan 21, 2020
2 parents dd50612 + 2c14f52 commit 4d4d8ff
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down

0 comments on commit 4d4d8ff

Please sign in to comment.