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 {
|
private renderLoadingState(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<div className="panel-loading">
|
<div className="panel-loading" onClick={this.onCancelQuery}>
|
||||||
<Icon className="fa-spin" name="fa fa-spinner" />
|
<Tooltip content="Cancel query">
|
||||||
|
<Icon className="panel-loading__spinner spin-counter-clock" name="sync" />
|
||||||
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import {
|
|||||||
applyFieldOverrides,
|
applyFieldOverrides,
|
||||||
DataConfigSource,
|
DataConfigSource,
|
||||||
TimeZone,
|
TimeZone,
|
||||||
|
LoadingState,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
|
|
||||||
export interface QueryRunnerOptions<
|
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 = () => {
|
resendLastResult = () => {
|
||||||
if (this.lastResult) {
|
if (this.lastResult) {
|
||||||
this.subject.next(this.lastResult);
|
this.subject.next(this.lastResult);
|
||||||
|
@ -78,6 +78,10 @@ $panel-header-no-title-zindex: 1;
|
|||||||
z-index: $panel-header-z-index + 1;
|
z-index: $panel-header-z-index + 1;
|
||||||
font-size: $font-size-lg;
|
font-size: $font-size-lg;
|
||||||
color: $text-color-weak;
|
color: $text-color-weak;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.panel-empty {
|
.panel-empty {
|
||||||
|
@ -34,3 +34,16 @@
|
|||||||
transition: max-height 250ms ease-in-out;
|
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