|
@@ -16,6 +16,7 @@ import { Themes } from 'app/core/components/Tooltip/Popper';
|
|
|
interface RenderProps {
|
|
interface RenderProps {
|
|
|
loading: LoadingState;
|
|
loading: LoadingState;
|
|
|
timeSeries: TimeSeries[];
|
|
timeSeries: TimeSeries[];
|
|
|
|
|
+ onRenderError: () => void;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export interface Props {
|
|
export interface Props {
|
|
@@ -35,6 +36,7 @@ export interface Props {
|
|
|
export interface State {
|
|
export interface State {
|
|
|
isFirstLoad: boolean;
|
|
isFirstLoad: boolean;
|
|
|
loading: LoadingState;
|
|
loading: LoadingState;
|
|
|
|
|
+ errorMessage: string;
|
|
|
response: DataQueryResponse;
|
|
response: DataQueryResponse;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -53,6 +55,7 @@ export class DataPanel extends Component<Props, State> {
|
|
|
|
|
|
|
|
this.state = {
|
|
this.state = {
|
|
|
loading: LoadingState.NotStarted,
|
|
loading: LoadingState.NotStarted,
|
|
|
|
|
+ errorMessage: '',
|
|
|
response: {
|
|
response: {
|
|
|
data: [],
|
|
data: [],
|
|
|
},
|
|
},
|
|
@@ -92,7 +95,7 @@ export class DataPanel extends Component<Props, State> {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this.setState({ loading: LoadingState.Loading });
|
|
|
|
|
|
|
+ this.setState({ loading: LoadingState.Loading, errorMessage: '' });
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
const ds = await this.dataSourceSrv.get(datasource);
|
|
const ds = await this.dataSourceSrv.get(datasource);
|
|
@@ -130,10 +133,24 @@ export class DataPanel extends Component<Props, State> {
|
|
|
});
|
|
});
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
console.log('Loading error', err);
|
|
console.log('Loading error', err);
|
|
|
- this.setState({ loading: LoadingState.Error, isFirstLoad: false });
|
|
|
|
|
|
|
+ this.onError('Request Error');
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ onError = (errorMessage: string) => {
|
|
|
|
|
+ if (this.state.loading !== LoadingState.Error || this.state.errorMessage !== errorMessage) {
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ loading: LoadingState.Error,
|
|
|
|
|
+ isFirstLoad: false,
|
|
|
|
|
+ errorMessage: errorMessage
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ onRenderError = () => {
|
|
|
|
|
+ this.onError('Error rendering panel');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
render() {
|
|
render() {
|
|
|
const { queries } = this.props;
|
|
const { queries } = this.props;
|
|
|
const { response, loading, isFirstLoad } = this.state;
|
|
const { response, loading, isFirstLoad } = this.state;
|
|
@@ -158,13 +175,14 @@ export class DataPanel extends Component<Props, State> {
|
|
|
{this.props.children({
|
|
{this.props.children({
|
|
|
timeSeries,
|
|
timeSeries,
|
|
|
loading,
|
|
loading,
|
|
|
|
|
+ onRenderError: this.onRenderError
|
|
|
})}
|
|
})}
|
|
|
</>
|
|
</>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private renderLoadingStates(): JSX.Element {
|
|
private renderLoadingStates(): JSX.Element {
|
|
|
- const { loading } = this.state;
|
|
|
|
|
|
|
+ const { loading, errorMessage } = this.state;
|
|
|
if (loading === LoadingState.Loading) {
|
|
if (loading === LoadingState.Loading) {
|
|
|
return (
|
|
return (
|
|
|
<div className="panel-loading">
|
|
<div className="panel-loading">
|
|
@@ -174,7 +192,7 @@ export class DataPanel extends Component<Props, State> {
|
|
|
} else if (loading === LoadingState.Error) {
|
|
} else if (loading === LoadingState.Error) {
|
|
|
return (
|
|
return (
|
|
|
<Tooltip
|
|
<Tooltip
|
|
|
- content="Request Error"
|
|
|
|
|
|
|
+ content={errorMessage}
|
|
|
className="popper__manager--block"
|
|
className="popper__manager--block"
|
|
|
refClassName={`panel-info-corner panel-info-corner--error`}
|
|
refClassName={`panel-info-corner panel-info-corner--error`}
|
|
|
placement="bottom-start"
|
|
placement="bottom-start"
|