Commit f16bf361 by Ryan McKinley Committed by GitHub

InfluxDB: improve test response (#25785)

parent 57f99471
...@@ -309,16 +309,20 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery, ...@@ -309,16 +309,20 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
return super return super
.query(request) .query(request)
.toPromise() .toPromise()
.then((res: any) => { .then((res: DataQueryResponse) => {
const data: DataQueryResponse = res.data; if (!res || !res.data || res.state !== LoadingState.Done) {
if (data && data.state === LoadingState.Done) { console.log('InfluxDB Error', res);
const buckets = data.data[0].length; return { status: 'error', message: 'Error reading InfluxDB' };
return { status: 'success', message: `Data source is working (${buckets} buckets)` };
} }
console.log('InfluxDB Error', data); const first = res.data[0];
if (first && first.length) {
return { status: 'success', message: `${first.length} buckets found` };
}
console.log('InfluxDB Error', res);
return { status: 'error', message: 'Error reading buckets' }; return { status: 'error', message: 'Error reading buckets' };
}) })
.catch((err: any) => { .catch((err: any) => {
console.log('InfluxDB Error', err);
return { status: 'error', message: err.message }; return { status: 'error', message: err.message };
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment