|
|
|
@ -2,6 +2,7 @@ import _ from 'lodash'; |
|
|
|
|
import ResponseParser from './response_parser'; |
|
|
|
|
import MysqlQuery from 'app/plugins/datasource/mysql/mysql_query'; |
|
|
|
|
import { getBackendSrv } from '@grafana/runtime'; |
|
|
|
|
import { ScopedVars } from '@grafana/data'; |
|
|
|
|
import { TemplateSrv } from 'app/features/templating/template_srv'; |
|
|
|
|
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv'; |
|
|
|
|
//Types
|
|
|
|
@ -27,7 +28,8 @@ export class MysqlDatasource { |
|
|
|
|
interpolateVariable = (value: string, variable: any) => { |
|
|
|
|
if (typeof value === 'string') { |
|
|
|
|
if (variable.multi || variable.includeAll) { |
|
|
|
|
return this.queryModel.quoteLiteral(value); |
|
|
|
|
const result = this.queryModel.quoteLiteral(value); |
|
|
|
|
return result; |
|
|
|
|
} else { |
|
|
|
|
return value; |
|
|
|
|
} |
|
|
|
@ -43,14 +45,17 @@ export class MysqlDatasource { |
|
|
|
|
return quotedValues.join(','); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
interpolateVariablesInQueries(queries: MysqlQueryForInterpolation[]): MysqlQueryForInterpolation[] { |
|
|
|
|
interpolateVariablesInQueries( |
|
|
|
|
queries: MysqlQueryForInterpolation[], |
|
|
|
|
scopedVars: ScopedVars |
|
|
|
|
): MysqlQueryForInterpolation[] { |
|
|
|
|
let expandedQueries = queries; |
|
|
|
|
if (queries && queries.length > 0) { |
|
|
|
|
expandedQueries = queries.map(query => { |
|
|
|
|
const expandedQuery = { |
|
|
|
|
...query, |
|
|
|
|
datasource: this.name, |
|
|
|
|
rawSql: this.templateSrv.replace(query.rawSql, {}, this.interpolateVariable), |
|
|
|
|
rawSql: this.templateSrv.replace(query.rawSql, scopedVars, this.interpolateVariable), |
|
|
|
|
}; |
|
|
|
|
return expandedQuery; |
|
|
|
|
}); |
|
|
|
|