@@ -20,6 +20,7 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
2020 }
2121
2222 async query ( options : DataQueryRequest < MyQuery > ) : Promise < DataQueryResponse > {
23+ const moment = require ( 'moment' ) ;
2324 const promises = options . targets . map ( ( query ) =>
2425 this . doRequest ( query , options ) . then ( ( response ) => {
2526 const frame = new MutableDataFrame ( {
@@ -39,8 +40,14 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
3940 response . results . forEach ( ( result : any ) => {
4041 // console.log(`DEBUG: result=${JSON.stringify(result)}`);
4142 let row : any [ ] = [ ] ;
43+
4244 response . fields . forEach ( ( field : any ) => {
43- row . push ( result [ field ] ) ;
45+ if ( field === 'Time' ) {
46+ let time = moment ( result [ '_time' ] ) . format ( 'YYYY-MM-DDTHH:mm:ssZ' ) ;
47+ row . push ( time ) ;
48+ } else {
49+ row . push ( result [ field ] ) ;
50+ }
4451 } ) ;
4552 frame . appendRow ( row ) ;
4653 } ) ;
@@ -172,6 +179,18 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
172179 offset = offset + count ;
173180 }
174181
182+ if ( fields . includes ( '_time' ) ) {
183+ fields . push ( 'Time' ) ;
184+ }
185+
186+ const index = fields . indexOf ( '_raw' , 0 ) ;
187+ if ( index > - 1 ) {
188+ fields . splice ( index , 1 ) ;
189+ fields = fields . reverse ( ) ;
190+ fields . push ( '_raw' ) ;
191+ fields = fields . reverse ( ) ;
192+ }
193+
175194 return { fields : fields , results : results } ;
176195 }
177196
0 commit comments