From dbb4a864b5dc8d03f5f97f4d3c7066cd9d3d5f39 Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Tue, 29 Aug 2017 09:15:13 -0700 Subject: [PATCH 1/3] Refetch even when the query has not changed --- src/core_plugins/kibana/public/dashboard/dashboard.js | 11 ++++------- .../kibana/public/discover/controllers/discover.js | 10 +++------- .../kibana/public/visualize/editor/editor.js | 10 +++------- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/core_plugins/kibana/public/dashboard/dashboard.js b/src/core_plugins/kibana/public/dashboard/dashboard.js index 8dd49bfeada97..1e20a9629b2a3 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard.js +++ b/src/core_plugins/kibana/public/dashboard/dashboard.js @@ -189,8 +189,9 @@ app.directive('dashboardApp', function ($injector) { filterBar.removeAll(); dashboardState.getAppState().$newFilters = []; } - - $scope.model.query = query; + $scope.model.query = migrateLegacyQuery(query); + dashboardState.applyFilters($scope.model.query, filterBar.getFilters()); + $scope.refresh(); }; // called by the saved-object-finder when a user clicks a vis @@ -227,11 +228,7 @@ app.directive('dashboardApp', function ($injector) { $scope.indexPatterns = dashboardState.getPanelIndexPatterns(); }; - $scope.$watch('model.query', (newQuery) => { - $scope.model.query = migrateLegacyQuery(newQuery); - dashboardState.applyFilters($scope.model.query, filterBar.getFilters()); - $scope.refresh(); - }); + $scope.$watch('model.query', $scope.updateQuery); $scope.$watchCollection(() => dashboardState.getAppState().$newFilters, function (filters = []) { // need to convert filters generated from user interaction with viz into kuery AST diff --git a/src/core_plugins/kibana/public/discover/controllers/discover.js b/src/core_plugins/kibana/public/discover/controllers/discover.js index b475c24855a41..1c90dedbfdf33 100644 --- a/src/core_plugins/kibana/public/discover/controllers/discover.js +++ b/src/core_plugins/kibana/public/discover/controllers/discover.js @@ -352,11 +352,7 @@ function discoverController( } }); - $scope.$watch('state.query', (newQuery) => { - $state.query = migrateLegacyQuery(newQuery); - - $scope.fetch(); - }); + $scope.$watch('state.query', $scope.updateQuery); $scope.$watchMulti([ 'rows', @@ -465,8 +461,8 @@ function discoverController( if ($state.query.language && $state.query.language !== query.language) { $state.filters = []; } - - $state.query = query; + $state.query = migrateLegacyQuery(query); + $scope.fetch(); }; $scope.searchSource.onBeginSegmentedFetch(function (segmented) { diff --git a/src/core_plugins/kibana/public/visualize/editor/editor.js b/src/core_plugins/kibana/public/visualize/editor/editor.js index a2aa2c64a8171..32d6e3dcc4288 100644 --- a/src/core_plugins/kibana/public/visualize/editor/editor.js +++ b/src/core_plugins/kibana/public/visualize/editor/editor.js @@ -196,11 +196,7 @@ function VisEditor($scope, $route, timefilter, AppState, $window, kbnUrl, courie .then($scope.fetch); }); - $scope.$watch('state.query', (newQuery) => { - $state.query = migrateLegacyQuery(newQuery); - - $scope.fetch(); - }); + $scope.$watch('state.query', $scope.updateQuery); $state.replace(); @@ -242,8 +238,8 @@ function VisEditor($scope, $route, timefilter, AppState, $window, kbnUrl, courie $state.filters = []; $state.$newFilters = []; } - - $state.query = query; + $state.query = migrateLegacyQuery(query); + $scope.fetch(); }; /** From 9c27c3340e352a7516a06f50a57f083452646b16 Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Tue, 29 Aug 2017 15:10:56 -0700 Subject: [PATCH 2/3] Change function name to better represent what it does --- src/core_plugins/kibana/public/dashboard/dashboard.js | 2 +- src/core_plugins/kibana/public/discover/controllers/discover.js | 2 +- src/core_plugins/kibana/public/visualize/editor/editor.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core_plugins/kibana/public/dashboard/dashboard.js b/src/core_plugins/kibana/public/dashboard/dashboard.js index 1e20a9629b2a3..c2e94cc500629 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard.js +++ b/src/core_plugins/kibana/public/dashboard/dashboard.js @@ -183,7 +183,7 @@ app.directive('dashboardApp', function ($injector) { } }; - $scope.updateQuery = function (query) { + $scope.updateQueryAndFetch = function (query) { // reset state if language changes if ($scope.model.query.language && $scope.model.query.language !== query.language) { filterBar.removeAll(); diff --git a/src/core_plugins/kibana/public/discover/controllers/discover.js b/src/core_plugins/kibana/public/discover/controllers/discover.js index 1c90dedbfdf33..4c025efbcf920 100644 --- a/src/core_plugins/kibana/public/discover/controllers/discover.js +++ b/src/core_plugins/kibana/public/discover/controllers/discover.js @@ -456,7 +456,7 @@ function discoverController( .catch(notify.error); }; - $scope.updateQuery = function (query) { + $scope.updateQueryAndFetch = function (query) { // reset state if language changes if ($state.query.language && $state.query.language !== query.language) { $state.filters = []; diff --git a/src/core_plugins/kibana/public/visualize/editor/editor.js b/src/core_plugins/kibana/public/visualize/editor/editor.js index 32d6e3dcc4288..b3199fa733b00 100644 --- a/src/core_plugins/kibana/public/visualize/editor/editor.js +++ b/src/core_plugins/kibana/public/visualize/editor/editor.js @@ -232,7 +232,7 @@ function VisEditor($scope, $route, timefilter, AppState, $window, kbnUrl, courie }); } - $scope.updateQuery = function (query) { + $scope.updateQueryAndFetch = function (query) { // reset state if language changes if ($state.query.language && $state.query.language !== query.language) { $state.filters = []; From ef09fa05c3e9f1d0a9ffce2baf8c6d5b93a2dd3a Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Tue, 29 Aug 2017 16:22:36 -0700 Subject: [PATCH 3/3] Rename all occurrences --- src/core_plugins/kibana/public/dashboard/dashboard.html | 2 +- src/core_plugins/kibana/public/dashboard/dashboard.js | 2 +- src/core_plugins/kibana/public/discover/controllers/discover.js | 2 +- src/core_plugins/kibana/public/discover/index.html | 2 +- src/core_plugins/kibana/public/visualize/editor/editor.html | 2 +- src/core_plugins/kibana/public/visualize/editor/editor.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core_plugins/kibana/public/dashboard/dashboard.html b/src/core_plugins/kibana/public/dashboard/dashboard.html index 87d4eca2c074f..4586d851d2c33 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard.html +++ b/src/core_plugins/kibana/public/dashboard/dashboard.html @@ -39,7 +39,7 @@ diff --git a/src/core_plugins/kibana/public/dashboard/dashboard.js b/src/core_plugins/kibana/public/dashboard/dashboard.js index c2e94cc500629..c51c9b542623b 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard.js +++ b/src/core_plugins/kibana/public/dashboard/dashboard.js @@ -228,7 +228,7 @@ app.directive('dashboardApp', function ($injector) { $scope.indexPatterns = dashboardState.getPanelIndexPatterns(); }; - $scope.$watch('model.query', $scope.updateQuery); + $scope.$watch('model.query', $scope.updateQueryAndFetch); $scope.$watchCollection(() => dashboardState.getAppState().$newFilters, function (filters = []) { // need to convert filters generated from user interaction with viz into kuery AST diff --git a/src/core_plugins/kibana/public/discover/controllers/discover.js b/src/core_plugins/kibana/public/discover/controllers/discover.js index 4c025efbcf920..b07fa43704dc8 100644 --- a/src/core_plugins/kibana/public/discover/controllers/discover.js +++ b/src/core_plugins/kibana/public/discover/controllers/discover.js @@ -352,7 +352,7 @@ function discoverController( } }); - $scope.$watch('state.query', $scope.updateQuery); + $scope.$watch('state.query', $scope.updateQueryAndFetch); $scope.$watchMulti([ 'rows', diff --git a/src/core_plugins/kibana/public/discover/index.html b/src/core_plugins/kibana/public/discover/index.html index 01c00e9a41bcc..6594cf575e4f6 100644 --- a/src/core_plugins/kibana/public/discover/index.html +++ b/src/core_plugins/kibana/public/discover/index.html @@ -20,7 +20,7 @@

diff --git a/src/core_plugins/kibana/public/visualize/editor/editor.html b/src/core_plugins/kibana/public/visualize/editor/editor.html index 66334f7b1a53a..3193ea41387d3 100644 --- a/src/core_plugins/kibana/public/visualize/editor/editor.html +++ b/src/core_plugins/kibana/public/visualize/editor/editor.html @@ -36,7 +36,7 @@ diff --git a/src/core_plugins/kibana/public/visualize/editor/editor.js b/src/core_plugins/kibana/public/visualize/editor/editor.js index b3199fa733b00..9436924445a62 100644 --- a/src/core_plugins/kibana/public/visualize/editor/editor.js +++ b/src/core_plugins/kibana/public/visualize/editor/editor.js @@ -196,7 +196,7 @@ function VisEditor($scope, $route, timefilter, AppState, $window, kbnUrl, courie .then($scope.fetch); }); - $scope.$watch('state.query', $scope.updateQuery); + $scope.$watch('state.query', $scope.updateQueryAndFetch); $state.replace();