mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Panel: Cancel panel query via loading spinner (#25954)
* Panel: Cancel panel query via loading spinne * Removed unused icon
This commit is contained in:
parent
83df83fa42
commit
650ab72c88
@ -87,10 +87,16 @@ export class PanelHeader extends Component<Props, State> {
|
||||
});
|
||||
};
|
||||
|
||||
onCancelQuery = () => {
|
||||
this.props.panel.getQueryRunner().cancelQuery();
|
||||
};
|
||||
|
||||
private renderLoadingState(): JSX.Element {
|
||||
return (
|
||||
<div className="panel-loading">
|
||||
<Icon className="fa-spin" name="fa fa-spinner" />
|
||||
<div className="panel-loading" onClick={this.onCancelQuery}>
|
||||
<Tooltip content="Cancel query">
|
||||
<Icon className="panel-loading__spinner spin-counter-clock" name="sync" />
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import {
|
||||
applyFieldOverrides,
|
||||
DataConfigSource,
|
||||
TimeZone,
|
||||
LoadingState,
|
||||
} from '@grafana/data';
|
||||
|
||||
export interface QueryRunnerOptions<
|
||||
@ -198,6 +199,22 @@ export class PanelQueryRunner {
|
||||
});
|
||||
}
|
||||
|
||||
cancelQuery() {
|
||||
if (!this.subscription) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.subscription.unsubscribe();
|
||||
|
||||
// If we have an old result with loading state, send it with done state
|
||||
if (this.lastResult && this.lastResult.state === LoadingState.Loading) {
|
||||
this.subject.next({
|
||||
...this.lastResult,
|
||||
state: LoadingState.Done,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
resendLastResult = () => {
|
||||
if (this.lastResult) {
|
||||
this.subject.next(this.lastResult);
|
||||
|
@ -78,6 +78,10 @@ $panel-header-no-title-zindex: 1;
|
||||
z-index: $panel-header-z-index + 1;
|
||||
font-size: $font-size-lg;
|
||||
color: $text-color-weak;
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.panel-empty {
|
||||
|
@ -34,3 +34,16 @@
|
||||
transition: max-height 250ms ease-in-out;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes spin-counter-clock {
|
||||
0% {
|
||||
transform: rotate(359deg);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
}
|
||||
|
||||
.spin-counter-clock {
|
||||
animation: spin-counter-clock 3s infinite linear;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user