Skip to content

Commit

Permalink
Merge pull request #163 from Vertamedia/issue-159
Browse files Browse the repository at this point in the history
Update rawQuery value for targets
  • Loading branch information
gimm3fuel authored Jan 15, 2020
2 parents acd0d89 + 5c45b32 commit 0c1a51c
Show file tree
Hide file tree
Showing 4 changed files with 56,146 additions and 24 deletions.
56,157 changes: 56,135 additions & 22 deletions dist/module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/module.js.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class ClickHouseDatasource {
xHeaderUser: string;
xHeaderKey: string;
useYandexCloudAuthorization: boolean;
targetsRef: any;

/** @ngInject */
constructor(instanceSettings,
Expand All @@ -47,6 +48,7 @@ export class ClickHouseDatasource {
this.xHeaderUser = instanceSettings.jsonData.xHeaderUser;
this.xHeaderKey = instanceSettings.jsonData.xHeaderKey;
this.useYandexCloudAuthorization = instanceSettings.jsonData.useYandexCloudAuthorization;
this.targetsRef = {};
}

_getRequestOptions(query: string, usePOST?: boolean, requestId?: string) {
Expand Down Expand Up @@ -161,7 +163,11 @@ export class ClickHouseDatasource {
let queryAST = new Scanner(stmt).toAST();
keys = queryAST['group by'] || [];
} catch (err) {
console.log('AST parser error: ', err)
console.log('AST parser error: ', err);
}

if (this.targetsRef && this.targetsRef[target.refId]) {
this.targetsRef[target.refId].rawQuery = stmt;
}

return {
Expand Down
3 changes: 3 additions & 0 deletions src/query_ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class SqlQueryCtrl extends QueryCtrl {
super($scope, $injector);

this.queryModel = new SqlQuery(this.target, templateSrv, this.panel.scopedVars);
if (this.datasource.targetsRef) {
this.datasource.targetsRef[this.target.refId] = this.target;
}

let defaultDatabaseSegment = {fake: true, value: '-- database --'};
if (this.datasource.defaultDatabase.length > 0) {
Expand Down

0 comments on commit 0c1a51c

Please sign in to comment.