mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Existing querying was grouped together before handed over to the datasource. This slowed down result display to however long the slowest query took. - create one query transaction per result viewer (graph, table, etc.) and query row - track latencies for each transaction - show results as soon as they are being received - loading indicator on graph and query button to indicate that queries are still running and that results are incomplete - properly discard transactions when removing or changing queries
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import React, { PureComponent } from 'react';
|
|
|
|
import { QueryTransaction as QueryTransactionModel } from 'app/types/explore';
|
|
import ElapsedTime from './ElapsedTime';
|
|
|
|
function formatLatency(value) {
|
|
return `${(value / 1000).toFixed(1)}s`;
|
|
}
|
|
|
|
interface QueryTransactionProps {
|
|
transaction: QueryTransactionModel;
|
|
}
|
|
|
|
class QueryTransaction extends PureComponent<QueryTransactionProps> {
|
|
render() {
|
|
const { transaction } = this.props;
|
|
const className = transaction.done ? 'query-transaction' : 'query-transaction query-transaction--loading';
|
|
return (
|
|
<div className={className}>
|
|
<div className="query-transaction__type">{transaction.resultType}:</div>
|
|
<div className="query-transaction__duration">
|
|
{transaction.done ? formatLatency(transaction.latency) : <ElapsedTime />}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
interface QueryTransactionsProps {
|
|
transactions: QueryTransactionModel[];
|
|
}
|
|
|
|
export default class QueryTransactions extends PureComponent<QueryTransactionsProps> {
|
|
render() {
|
|
const { transactions } = this.props;
|
|
return (
|
|
<div className="query-transactions">
|
|
{transactions.map((t, i) => <QueryTransaction key={`${t.query}:${t.resultType}`} transaction={t} />)}
|
|
</div>
|
|
);
|
|
}
|
|
}
|