Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refetch even when the query has not changed #13759

Merged
merged 5 commits into from
Sep 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I called these methods updateQuery since they only update state. Now that they also fetch results, maybe we should call them something like fetchWithQuery?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 9c27c33

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That name sounds good to me! Did you forget to update all the usages though?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How embarrassing. ef09fa0

$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