@@ -139,7 +139,7 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
139139
140140 async query ( options : DataQueryRequest < MyQuery > ) : Promise < DataQueryResponse > {
141141 return Promise . all (
142- options . targets . map ( target => {
142+ options . targets . map ( ( target ) => {
143143 return this . createQuery ( defaults ( target , defaultQuery ) , options . range , options . scopedVars ) ;
144144 } )
145145 ) . then ( ( results : any ) => {
@@ -312,8 +312,12 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
312312 const docs : any [ ] = DataSource . getDocs ( response . results . data , query . dataPath ) ;
313313
314314 for ( const doc of docs ) {
315- for ( const fieldName in doc ) {
316- metricFindValues . push ( { text : doc [ fieldName ] } ) ;
315+ if ( '__text' in doc && '__value' in doc ) {
316+ metricFindValues . push ( { text : doc [ '__text' ] , value : doc [ '__value' ] } ) ;
317+ } else {
318+ for ( const fieldName in doc ) {
319+ metricFindValues . push ( { text : doc [ fieldName ] } ) ;
320+ }
317321 }
318322 }
319323
@@ -322,7 +326,7 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
322326
323327 getVariables ( ) {
324328 const variables : { [ id : string ] : TextValuePair } = { } ;
325- Object . values ( getTemplateSrv ( ) . getVariables ( ) ) . forEach ( variable => {
329+ Object . values ( getTemplateSrv ( ) . getVariables ( ) ) . forEach ( ( variable ) => {
326330 if ( ! supportedVariableTypes . includes ( variable . type ) ) {
327331 console . warn ( `Variable of type "${ variable . type } " is not supported` ) ;
328332
@@ -334,7 +338,7 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
334338 let variableValue = supportedVariable . current . value ;
335339 if ( variableValue === '$__all' || isEqual ( variableValue , [ '$__all' ] ) ) {
336340 if ( supportedVariable . allValue === null || supportedVariable . allValue === '' ) {
337- variableValue = supportedVariable . options . slice ( 1 ) . map ( textValuePair => textValuePair . value ) ;
341+ variableValue = supportedVariable . options . slice ( 1 ) . map ( ( textValuePair ) => textValuePair . value ) ;
338342 } else {
339343 variableValue = supportedVariable . allValue ;
340344 }
0 commit comments