From 3d1c43d331b7c23430e82d9724b659aeb893abfb Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 22 Aug 2019 16:48:56 +0200 Subject: [PATCH] [ML] Fixes retaining the swimlane selection on a timefilter refresh. --- x-pack/legacy/plugins/ml/public/explorer/explorer.js | 4 ++++ .../plugins/ml/public/explorer/explorer_controller.js | 9 +-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/explorer/explorer.js b/x-pack/legacy/plugins/ml/public/explorer/explorer.js index c7f740a19bd81..7896c2c46a50c 100644 --- a/x-pack/legacy/plugins/ml/public/explorer/explorer.js +++ b/x-pack/legacy/plugins/ml/public/explorer/explorer.js @@ -267,6 +267,7 @@ export const Explorer = injectI18n(injectObservablesAsProps( stateUpdate.indexPattern = indexPattern; this.updateExplorer(stateUpdate, true); + return; } // Listen for changes to job selection. @@ -313,17 +314,20 @@ export const Explorer = injectI18n(injectObservablesAsProps( } this.updateExplorer(stateUpdate, true); + return; } // RELOAD reloads full Anomaly Explorer and clears the selection. if (action === EXPLORER_ACTION.RELOAD) { this.props.appStateHandler(APP_STATE_ACTION.CLEAR_SELECTION); this.updateExplorer({ ...payload, ...getClearedSelectedAnomaliesState() }, true); + return; } // REDRAW reloads Anomaly Explorer and tries to retain the selection. if (action === EXPLORER_ACTION.REDRAW) { this.updateExplorer({}, false); + return; } } else if (this.previousSwimlaneLimit !== this.props.swimlaneLimit) { this.previousSwimlaneLimit = this.props.swimlaneLimit; diff --git a/x-pack/legacy/plugins/ml/public/explorer/explorer_controller.js b/x-pack/legacy/plugins/ml/public/explorer/explorer_controller.js index 0b83e4d313f13..b1dcd55aed599 100644 --- a/x-pack/legacy/plugins/ml/public/explorer/explorer_controller.js +++ b/x-pack/legacy/plugins/ml/public/explorer/explorer_controller.js @@ -198,7 +198,7 @@ module.controller('MlExplorerController', function ( subscriptions.add(mlTimefilterRefresh$.subscribe(() => { if ($scope.jobSelectionUpdateInProgress === false) { - explorer$.next({ action: EXPLORER_ACTION.RELOAD }); + explorer$.next({ action: EXPLORER_ACTION.REDRAW }); } })); @@ -209,13 +209,6 @@ module.controller('MlExplorerController', function ( } }); - // Add a watcher for auto-refresh of the time filter to refresh all the data. - subscriptions.add(mlTimefilterRefresh$.subscribe(() => { - if ($scope.jobSelectionUpdateInProgress === false) { - explorer$.next({ action: EXPLORER_ACTION.RELOAD }); - } - })); - subscriptions.add(subscribeAppStateToObservable(AppState, 'mlShowCharts', showCharts$, () => $rootScope.$applyAsync())); subscriptions.add(subscribeAppStateToObservable(AppState, 'mlSelectInterval', interval$, () => $rootScope.$applyAsync())); subscriptions.add(subscribeAppStateToObservable(AppState, 'mlSelectSeverity', severity$, () => $rootScope.$applyAsync()));