diff --git a/x-pack/legacy/plugins/ml/public/timeseriesexplorer/_timeseriesexplorer.scss b/x-pack/legacy/plugins/ml/public/timeseriesexplorer/_timeseriesexplorer.scss index f4366ec13fda3..aa172cf000d5f 100644 --- a/x-pack/legacy/plugins/ml/public/timeseriesexplorer/_timeseriesexplorer.scss +++ b/x-pack/legacy/plugins/ml/public/timeseriesexplorer/_timeseriesexplorer.scss @@ -333,3 +333,12 @@ } } } + +/* Hides the progress bar's background so it doesn't look like it increases the thickness + of the horizontal bar below the tab menu elements in its inactive state. */ +.mlTimeSeriesExplorerProgress { + background-color: $euiColorEmptyShade; + &::-moz-progress-bar, &::-webkit-progress-bar { + background-color: $euiColorEmptyShade; + } +} diff --git a/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.js b/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.js index ab29e0ba303a9..ca15be6cad167 100644 --- a/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.js +++ b/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.js @@ -22,6 +22,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiFormRow, + EuiProgress, EuiSelect, EuiSpacer, EuiText, @@ -103,6 +104,7 @@ function getTimeseriesexplorerDefaultState() { focusAnnotationData: [], focusChartData: undefined, focusForecastData: undefined, + fullRefresh: true, hasResults: false, jobs: [], // Counter to keep track of what data sets have been loaded. @@ -127,9 +129,14 @@ function getTimeseriesexplorerDefaultState() { }; } -const TimeSeriesExplorerPage = ({ children, jobSelectorProps, resizeRef }) => ( +const TimeSeriesExplorerPage = ({ children, jobSelectorProps, loading, resizeRef }) => ( + {/* Show animated progress bar while loading */} + {loading && ()} + {/* Show a progress bar with progress 0% when not loading. + If we'd just show no progress bar when not loading it would result in a flickering height effect. */} + {!loading && ()}
{children} @@ -466,8 +473,8 @@ export class TimeSeriesExplorer extends React.Component { }); } - refresh = () => { - if (this.state.loading) { + refresh = (fullRefresh = true) => { + if (this.state.loading && fullRefresh === false) { return; } @@ -485,17 +492,22 @@ export class TimeSeriesExplorer extends React.Component { this.contextChartSelectedInitCallDone = false; + // Only when `fullRefresh` is true we'll reset all data + // and show the loading spinner within the page. this.setState({ - chartDetails: undefined, - contextChartData: undefined, - contextForecastData: undefined, - focusChartData: undefined, - focusForecastData: undefined, + fullRefresh, loadCounter: currentLoadCounter + 1, loading: true, - modelPlotEnabled: isModelPlotEnabled(currentSelectedJob, +currentDetectorId, currentEntities), - hasResults: false, - dataNotChartable: false + ...(fullRefresh ? { + chartDetails: undefined, + contextChartData: undefined, + contextForecastData: undefined, + focusChartData: undefined, + focusForecastData: undefined, + modelPlotEnabled: isModelPlotEnabled(currentSelectedJob, +currentDetectorId, currentEntities), + hasResults: false, + dataNotChartable: false + } : {}), }, () => { const { detectorId, entities, loadCounter, jobs, modelPlotEnabled, selectedJob } = this.state; const detectorIndex = +detectorId; @@ -797,7 +809,7 @@ export class TimeSeriesExplorer extends React.Component { this.subscriptions.add(annotationsRefresh$.subscribe(this.refresh)); this.subscriptions.add(interval$.subscribe(tableControlsListener)); this.subscriptions.add(severity$.subscribe(tableControlsListener)); - this.subscriptions.add(mlTimefilterRefresh$.subscribe(this.refresh)); + this.subscriptions.add(mlTimefilterRefresh$.subscribe(() => this.refresh(false))); // Listen for changes to job selection. this.subscriptions.add(this.jobSelectService.subscribe(({ selection: selectedJobIds }) => { @@ -927,6 +939,7 @@ export class TimeSeriesExplorer extends React.Component { focusAnnotationData, focusChartData, focusForecastData, + fullRefresh, hasResults, jobs, loading, @@ -1005,7 +1018,7 @@ export class TimeSeriesExplorer extends React.Component { this.previousShowModelBounds = showModelBounds; return ( - +
@@ -1045,7 +1058,7 @@ export class TimeSeriesExplorer extends React.Component {
- {(loading === true) && ( + {(fullRefresh && loading === true) && ( )} - {(jobs.length > 0 && loading === false && hasResults === false) && ( + {(jobs.length > 0 && (fullRefresh === false || loading === false) && hasResults === false) && ( )} - {(jobs.length > 0 && loading === false && hasResults === true) && ( + {(jobs.length > 0 && (fullRefresh === false || loading === false) && hasResults === true) && ( {i18n.translate('xpack.ml.timeSeriesExplorer.singleTimeSeriesAnalysisTitle', {