Skip to content

Commit

Permalink
Refetch even when the query has not changed (#13759)
Browse files Browse the repository at this point in the history
* Refetch even when the query has not changed

* Change function name to better represent what it does

* Rename all occurrences
  • Loading branch information
lukasolson authored Sep 7, 2017
1 parent 52cee7d commit d331a7e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/core_plugins/kibana/public/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<query-bar
query="model.query"
app-name="'dashboard'"
on-submit="updateQuery($query)"
on-submit="updateQueryAndFetch($query)"
>
</query-bar>
</div>
Expand Down
13 changes: 5 additions & 8 deletions src/core_plugins/kibana/public/dashboard/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,15 @@ 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();
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
Expand Down Expand Up @@ -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.updateQueryAndFetch);

$scope.$watchCollection(() => dashboardState.getAppState().$newFilters, function (filters = []) {
// need to convert filters generated from user interaction with viz into kuery AST
Expand Down
12 changes: 4 additions & 8 deletions src/core_plugins/kibana/public/discover/controllers/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,7 @@ function discoverController(
}
});

$scope.$watch('state.query', (newQuery) => {
$state.query = migrateLegacyQuery(newQuery);

$scope.fetch();
});
$scope.$watch('state.query', $scope.updateQueryAndFetch);

$scope.$watchMulti([
'rows',
Expand Down Expand Up @@ -460,13 +456,13 @@ 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 = [];
}

$state.query = query;
$state.query = migrateLegacyQuery(query);
$scope.fetch();
};

$scope.searchSource.onBeginSegmentedFetch(function (segmented) {
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/kibana/public/discover/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1 tabindex="0" id="kui_local_breadcrumb" class="kuiLocalBreadcrumb">
<query-bar
query="state.query"
app-name="'discover'"
on-submit="updateQuery($query)"
on-submit="updateQueryAndFetch($query)"
>
</query-bar>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<query-bar
query="state.query"
app-name="'visualize'"
on-submit="updateQuery($query)"
on-submit="updateQueryAndFetch($query)"
disable-auto-focus="true"
>
</query-bar>
Expand Down
12 changes: 4 additions & 8 deletions src/core_plugins/kibana/public/visualize/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.updateQueryAndFetch);

$state.replace();

Expand Down Expand Up @@ -236,14 +232,14 @@ 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 = [];
$state.$newFilters = [];
}

$state.query = query;
$state.query = migrateLegacyQuery(query);
$scope.fetch();
};

/**
Expand Down

0 comments on commit d331a7e

Please sign in to comment.