Skip to content

Commit

Permalink
Closes #2269 - Restore query and filter from dash.searchSource.getOwn…
Browse files Browse the repository at this point in the history
…('filter')
  • Loading branch information
simianhacker committed Dec 12, 2014
1 parent 728863a commit cb3f82c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/kibana/plugins/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,20 @@ define(function (require) {
var dash = $scope.dash = $route.current.locals.dash;
$scope.$on('$destroy', dash.destroy);

var matchQueryFilter = function (filter) {
return filter.query && filter.query.query_string && !filter.meta;
};

var extractQueryFromFilters = function (filters) {
var filter = _.find(filters, matchQueryFilter);
if (filter) return filter.query;
};

var stateDefaults = {
title: dash.title,
panels: dash.panelsJSON ? JSON.parse(dash.panelsJSON) : [],
query: {query_string: {query: '*'}}
query: extractQueryFromFilters(dash.searchSource.getOwn('filter')) || {query_string: {query: '*'}},
filters: _.reject(dash.searchSource.getOwn('filter'), matchQueryFilter)
};

var $state = $scope.state = new AppState(stateDefaults);
Expand Down

0 comments on commit cb3f82c

Please sign in to comment.