From 8f0eb130d5b8cb96c3c0cb5398239dcd5df33b7c Mon Sep 17 00:00:00 2001 From: amper43 Date: Mon, 13 Jan 2020 19:13:06 +0300 Subject: [PATCH 1/4] fix --- src/module.ts | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/module.ts b/src/module.ts index c1d42fa..c441e25 100644 --- a/src/module.ts +++ b/src/module.ts @@ -60,19 +60,34 @@ class Ctrl extends PanelCtrl { 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}`); + let datasourceId: string; + console.log(data); + + if(requestConfig.data !== undefined && requestConfig.data.queries !== undefined) { + + 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 datasourceIdRegExp = requestConfig.url.match(/proxy\/(\d+)/); + if(datasourceIdRegExp === null) { + throw new Error(`Cannot find datasource id in url ${requestConfig.url}`); + } + + let datasourceId = datasourceIdRegExp[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 = {}; From df307231271d41bbd4561d6c07c6986e5cb753c4 Mon Sep 17 00:00:00 2001 From: amper43 Date: Mon, 13 Jan 2020 19:15:19 +0300 Subject: [PATCH 2/4] fix --- src/module.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/module.ts b/src/module.ts index c441e25..57a292a 100644 --- a/src/module.ts +++ b/src/module.ts @@ -60,8 +60,6 @@ class Ctrl extends PanelCtrl { appEvents.on('ds-request-response', data => { let requestConfig = data.config; - let datasourceId: string; - console.log(data); if(requestConfig.data !== undefined && requestConfig.data.queries !== undefined) { From f2d815fd163602bfcb47f5d5b30c1bfb7e873e5b Mon Sep 17 00:00:00 2001 From: amper43 Date: Mon, 13 Jan 2020 19:41:36 +0300 Subject: [PATCH 3/4] fix --- src/module.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/module.ts b/src/module.ts index 57a292a..97c08ee 100644 --- a/src/module.ts +++ b/src/module.ts @@ -59,9 +59,11 @@ class Ctrl extends PanelCtrl { this.timeSrv = $injector.get('timeSrv'); appEvents.on('ds-request-response', data => { - let requestConfig = data.config; + const requestConfig = data.config; + const isSqlDatasource = requestConfig.data !== undefined && + requestConfig.data.queries !== undefined; - if(requestConfig.data !== undefined && requestConfig.data.queries !== undefined) { + if(isSqlDatasource) { for(let query of requestConfig.data.queries) { this._datasourceRequests[query.datasourceId] = { @@ -72,12 +74,12 @@ class Ctrl extends PanelCtrl { }; } } else { - let datasourceIdRegExp = requestConfig.url.match(/proxy\/(\d+)/); - if(datasourceIdRegExp === null) { + let matched = requestConfig.url.match(/proxy\/(\d+)/); + if(matched === null) { throw new Error(`Cannot find datasource id in url ${requestConfig.url}`); } - let datasourceId = datasourceIdRegExp[1]; + let datasourceId = matched[1]; this._datasourceRequests[datasourceId] = { url: requestConfig.url, From 2c14f52cd129fb80e2812ceda2afb434f2aeb3f1 Mon Sep 17 00:00:00 2001 From: amper43 Date: Tue, 21 Jan 2020 18:28:26 +0300 Subject: [PATCH 4/4] fix according review --- src/module.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/module.ts b/src/module.ts index 97c08ee..05df6b5 100644 --- a/src/module.ts +++ b/src/module.ts @@ -64,7 +64,6 @@ class Ctrl extends PanelCtrl { requestConfig.data.queries !== undefined; if(isSqlDatasource) { - for(let query of requestConfig.data.queries) { this._datasourceRequests[query.datasourceId] = { url: query.url, @@ -78,9 +77,7 @@ class Ctrl extends PanelCtrl { 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,