|
|
@@ -97,6 +97,10 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
|
|
|
* Local ID cache to compare requested vs selected datasource
|
|
|
*/
|
|
|
requestedDatasourceId: string;
|
|
|
+ /**
|
|
|
+ * Timepicker to control scanning
|
|
|
+ */
|
|
|
+ timepickerRef: React.RefObject<TimePicker>;
|
|
|
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
@@ -122,6 +126,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
|
|
|
history: [],
|
|
|
queryTransactions: [],
|
|
|
range: initialRange,
|
|
|
+ scanning: false,
|
|
|
showingGraph: true,
|
|
|
showingLogs: true,
|
|
|
showingStartPage: false,
|
|
|
@@ -132,6 +137,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
|
|
|
};
|
|
|
}
|
|
|
this.modifiedQueries = initialQueries.slice();
|
|
|
+ this.timepickerRef = React.createRef();
|
|
|
}
|
|
|
|
|
|
async componentDidMount() {
|
|
|
@@ -317,11 +323,14 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- onChangeTime = (nextRange: RawTimeRange) => {
|
|
|
+ onChangeTime = (nextRange: RawTimeRange, scanning?: boolean) => {
|
|
|
const range: RawTimeRange = {
|
|
|
...nextRange,
|
|
|
};
|
|
|
- this.setState({ range }, () => this.onSubmit());
|
|
|
+ if (this.state.scanning && !scanning) {
|
|
|
+ this.stopScanOlder();
|
|
|
+ }
|
|
|
+ this.setState({ range, scanning }, () => this.onSubmit());
|
|
|
};
|
|
|
|
|
|
onClickClear = () => {
|
|
|
@@ -496,6 +505,18 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
|
|
|
);
|
|
|
};
|
|
|
|
|
|
+ onStartScanOlder = () => {
|
|
|
+ this.setState({ scanning: true }, this.scanOlder);
|
|
|
+ };
|
|
|
+
|
|
|
+ scanOlder = () => {
|
|
|
+ this.timepickerRef.current.move(-1, true);
|
|
|
+ };
|
|
|
+
|
|
|
+ stopScanOlder = () => {
|
|
|
+ // Stop ongoing scan transactions
|
|
|
+ };
|
|
|
+
|
|
|
onSubmit = () => {
|
|
|
const { showingLogs, showingGraph, showingTable, supportsGraph, supportsLogs, supportsTable } = this.state;
|
|
|
// Keep table queries first since they need to return quickly
|
|
|
@@ -563,6 +584,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
|
|
|
done: false,
|
|
|
latency: 0,
|
|
|
options: queryOptions,
|
|
|
+ scanning: this.state.scanning,
|
|
|
};
|
|
|
|
|
|
// Using updater style because we might be modifying queryTransactions in quick succession
|
|
|
@@ -599,7 +621,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
|
|
|
}
|
|
|
|
|
|
this.setState(state => {
|
|
|
- const { history, queryTransactions } = state;
|
|
|
+ const { history, queryTransactions, scanning } = state;
|
|
|
|
|
|
// Transaction might have been discarded
|
|
|
const transaction = queryTransactions.find(qt => qt.id === transactionId);
|
|
|
@@ -629,6 +651,14 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
|
|
|
|
|
|
const nextHistory = updateHistory(history, datasourceId, queries);
|
|
|
|
|
|
+ if (_.size(result) === 0 && scanning) {
|
|
|
+ // Keep scanning if this was the last scanning transaction
|
|
|
+ const other = nextQueryTransactions.find(qt => qt.scanning && !qt.done);
|
|
|
+ if (!other) {
|
|
|
+ setTimeout(this.scanOlder, 1000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return {
|
|
|
history: nextHistory,
|
|
|
queryTransactions: nextQueryTransactions,
|
|
|
@@ -740,6 +770,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
|
|
|
initialQueries,
|
|
|
queryTransactions,
|
|
|
range,
|
|
|
+ scanning,
|
|
|
showingGraph,
|
|
|
showingLogs,
|
|
|
showingStartPage,
|
|
|
@@ -822,7 +853,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
|
|
|
</button>
|
|
|
</div>
|
|
|
) : null}
|
|
|
- <TimePicker range={range} onChangeTime={this.onChangeTime} />
|
|
|
+ <TimePicker ref={this.timepickerRef} range={range} onChangeTime={this.onChangeTime} />
|
|
|
<div className="navbar-buttons">
|
|
|
<button className="btn navbar-button navbar-button--no-icon" onClick={this.onClickClear}>
|
|
|
Clear All
|
|
|
@@ -898,7 +929,9 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
|
|
|
loading={logsLoading}
|
|
|
position={position}
|
|
|
onChangeTime={this.onChangeTime}
|
|
|
+ onStartScanOlder={this.onStartScanOlder}
|
|
|
range={range}
|
|
|
+ scanning={scanning}
|
|
|
/>
|
|
|
</Panel>
|
|
|
)}
|