mirror of https://github.com/grafana/grafana
Explore: Align Explore with Dashboards and Panels (#16823)
* Wip: Removes queryTransactions from state * Refactor: Adds back query failures * Refactor: Moves error parsing to datasources * Refactor: Adds back hinting for Prometheus * Refactor: removed commented out code * Refactor: Adds back QueryStatus * Refactor: Adds scanning back to Explore * Fix: Fixes prettier error * Fix: Makes sure there is an error * Merge: Merges with master * Fix: Adds safeStringifyValue to error parsing * Fix: Fixes table result calculations * Refactor: Adds ErrorContainer and generic error handling in Explore * Fix: Fixes so refIds remain consistent * Refactor: Makes it possible to return result even when there are errors * Fix: Fixes digest issue with Angular editors * Refactor: Adds tests for explore utils * Refactor: Breakes current behaviour of always returning a result even if Query fails * Fix: Fixes Prettier error * Fix: Adds back console.log for erroneous querys * Refactor: Changes console.log to console.errorpull/17007/head
parent
8eb78ea931
commit
6dbaa704bc
@ -0,0 +1,32 @@ |
||||
import React, { FunctionComponent } from 'react'; |
||||
import { DataQueryError } from '@grafana/ui'; |
||||
import { FadeIn } from 'app/core/components/Animations/FadeIn'; |
||||
import { getFirstQueryErrorWithoutRefId, getValueWithRefId } from 'app/core/utils/explore'; |
||||
|
||||
interface Props { |
||||
queryErrors: DataQueryError[]; |
||||
} |
||||
|
||||
export const ErrorContainer: FunctionComponent<Props> = props => { |
||||
const { queryErrors } = props; |
||||
const refId = getValueWithRefId(queryErrors); |
||||
const queryError = refId ? null : getFirstQueryErrorWithoutRefId(queryErrors); |
||||
const showError = queryError ? true : false; |
||||
const duration = showError ? 100 : 10; |
||||
const message = queryError ? queryError.message : null; |
||||
|
||||
return ( |
||||
<FadeIn in={showError} duration={duration}> |
||||
<div className="alert-container"> |
||||
<div className="alert-error alert"> |
||||
<div className="alert-icon"> |
||||
<i className="fa fa-exclamation-triangle" /> |
||||
</div> |
||||
<div className="alert-body"> |
||||
<div className="alert-title">{message}</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</FadeIn> |
||||
); |
||||
}; |
||||
@ -0,0 +1,47 @@ |
||||
import React, { PureComponent } from 'react'; |
||||
|
||||
import ElapsedTime from './ElapsedTime'; |
||||
import { PanelData, LoadingState } from '@grafana/ui'; |
||||
|
||||
function formatLatency(value) { |
||||
return `${(value / 1000).toFixed(1)}s`; |
||||
} |
||||
|
||||
interface QueryStatusItemProps { |
||||
queryResponse: PanelData; |
||||
latency: number; |
||||
} |
||||
|
||||
class QueryStatusItem extends PureComponent<QueryStatusItemProps> { |
||||
render() { |
||||
const { queryResponse, latency } = this.props; |
||||
const className = |
||||
queryResponse.state === LoadingState.Done || LoadingState.Error |
||||
? 'query-transaction' |
||||
: 'query-transaction query-transaction--loading'; |
||||
return ( |
||||
<div className={className}> |
||||
{/* <div className="query-transaction__type">{transaction.resultType}:</div> */} |
||||
<div className="query-transaction__duration"> |
||||
{queryResponse.state === LoadingState.Done || LoadingState.Error ? formatLatency(latency) : <ElapsedTime />} |
||||
</div> |
||||
</div> |
||||
); |
||||
} |
||||
} |
||||
|
||||
interface QueryStatusProps { |
||||
queryResponse: PanelData; |
||||
latency: number; |
||||
} |
||||
|
||||
export default class QueryStatus extends PureComponent<QueryStatusProps> { |
||||
render() { |
||||
const { queryResponse, latency } = this.props; |
||||
return ( |
||||
<div className="query-transactions"> |
||||
{queryResponse && <QueryStatusItem queryResponse={queryResponse} latency={latency} />} |
||||
</div> |
||||
); |
||||
} |
||||
} |
||||
@ -1,44 +0,0 @@ |
||||
import React, { PureComponent } from 'react'; |
||||
|
||||
import { QueryTransaction } from 'app/types/explore'; |
||||
import ElapsedTime from './ElapsedTime'; |
||||
|
||||
function formatLatency(value) { |
||||
return `${(value / 1000).toFixed(1)}s`; |
||||
} |
||||
|
||||
interface QueryTransactionStatusItemProps { |
||||
transaction: QueryTransaction; |
||||
} |
||||
|
||||
class QueryTransactionStatusItem extends PureComponent<QueryTransactionStatusItemProps> { |
||||
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 QueryTransactionStatusProps { |
||||
transactions: QueryTransaction[]; |
||||
} |
||||
|
||||
export default class QueryTransactionStatus extends PureComponent<QueryTransactionStatusProps> { |
||||
render() { |
||||
const { transactions } = this.props; |
||||
return ( |
||||
<div className="query-transactions"> |
||||
{transactions.map((t, i) => ( |
||||
<QueryTransactionStatusItem key={`${t.rowIndex}:${t.resultType}`} transaction={t} /> |
||||
))} |
||||
</div> |
||||
); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue