Skip to content

Commit

Permalink
updating discovery to accept explicitly passed in query and filters
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed May 21, 2018
1 parent 0d7d243 commit fac3e08
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ export class SearchEmbeddable extends Embeddable {
pushContainerStateParamsToScope() {
// If there is column or sort data on the panel, that means the original columns or sort settings have
// been overridden in a dashboard.

this.searchScope.columns = this.customization.columns || this.savedSearch.columns;
this.searchScope.sort = this.customization.sort || this.savedSearch.sort;
this.searchScope.sharedItemTitle = this.panelTitle;

this.searchScope.searchSource.getParent().set('filter', this.filters);
this.searchScope.searchSource.getParent().set('query', this.query);
}

onContainerStateChanged(containerState) {
this.customization = containerState.embeddableCustomization || {};
this.filters = containerState.filters;
this.query = containerState.query;
this.panelTitle = '';
if (!containerState.hidePanelTitles) {
this.panelTitle = containerState.customTitle !== undefined ?
Expand All @@ -58,11 +64,11 @@ export class SearchEmbeddable extends Embeddable {
initializeSearchScope() {
this.searchScope = this.$rootScope.$new();

this.pushContainerStateParamsToScope();

this.searchScope.description = this.savedSearch.description;
this.searchScope.searchSource = this.savedSearch.searchSource;

this.pushContainerStateParamsToScope();

this.searchScope.setSortOrder = (columnName, direction) => {
this.searchScope.sort = this.customization.sort = [columnName, direction];
this.emitEmbeddableStateChange(this.getEmbeddableState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ module.factory('SavedSearch', function (courier) {
hits: 0,
sort: [],
version: 1
}
},
afterESResp: this._afterEsResp
});

this.showInRecenltyAccessed = true;
Expand All @@ -49,5 +50,16 @@ module.factory('SavedSearch', function (courier) {
return `/app/kibana#/discover/${this.id}`;
};

SavedSearch.prototype._afterEsResp = function () {
const baseSearchSource = this.searchSource.clone();
baseSearchSource.inherits(false);
baseSearchSource.set('filter', []);
baseSearchSource.set('query', null);

this.searchSource.inherits(baseSearchSource);

return this.searchSource;
};

return SavedSearch;
});

0 comments on commit fac3e08

Please sign in to comment.