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

pass global filters from editor #26009

Merged
merged 3 commits into from
Nov 22, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
saved-obj="savedVis"
ui-state="uiState"
time-range="timeRange"
filters="globalFilters"
class="visEditor__content"
/>

Expand Down
15 changes: 1 addition & 14 deletions src/core_plugins/kibana/public/visualize/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,6 @@ function VisEditor(
// SearchSource is a promise-based stream of search results that can inherit from other search sources.
const { vis, searchSource } = savedVis;

// adds top level search source to the stack to which global filters are applied
const getTopLevelSearchSource = (searchSource) => {
if (searchSource.getParent()) return getTopLevelSearchSource(searchSource.getParent());
return searchSource;
};

const topLevelSearchSource = getTopLevelSearchSource(searchSource);
const globalFiltersSearchSource = searchSource.create();
globalFiltersSearchSource.setField('index', searchSource.getField('index'));
topLevelSearchSource.setParent(globalFiltersSearchSource);


$scope.vis = vis;

const $appStatus = this.appStatus = {
Expand Down Expand Up @@ -338,10 +326,9 @@ function VisEditor(
// update the searchSource when query updates
$scope.fetch = function () {
$state.save();
const globalFilters = queryFilter.getGlobalFilters();
savedVis.searchSource.setField('query', $state.query);
savedVis.searchSource.setField('filter', $state.filters);
globalFiltersSearchSource.setField('filter', globalFilters);
$scope.globalFilters = queryFilter.getGlobalFilters();
$scope.vis.forceReload();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

import { debounce } from 'lodash';
import { uiModules } from 'ui/modules';
import 'angular-sanitize';
import { VisEditorTypesRegistryProvider } from 'ui/registry/vis_editor_types';
Expand All @@ -31,7 +32,8 @@ uiModules
scope: {
savedObj: '=',
uiState: '=?',
timeRange: '='
timeRange: '=',
filters: '=',
},
link: function ($scope, element) {
const editorType = $scope.savedObj.vis.type.editor;
Expand All @@ -43,6 +45,7 @@ uiModules
editor.render({
uiState: $scope.uiState,
timeRange: $scope.timeRange,
filters: $scope.filters,
appState: getAppState(),
});
};
Expand All @@ -56,8 +59,9 @@ uiModules
editor.destroy();
});

$scope.$watch('timeRange', $scope.renderFunction);

$scope.$watchGroup(['timeRange', 'filters'], debounce(() => {
$scope.renderFunction();
}, 100));
}
};
});
6 changes: 4 additions & 2 deletions src/ui/public/vis/editors/default/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const defaultEditor = function ($rootScope, $compile, i18n) {
}
}

render({ uiState, timeRange, appState }) {
render({ uiState, timeRange, filters, appState }) {
let $scope;

const updateScope = () => {
Expand Down Expand Up @@ -166,12 +166,14 @@ const defaultEditor = function ($rootScope, $compile, i18n) {
uiState: uiState,
listenOnChange: false,
timeRange: timeRange,
filters: filters,
appState: appState,
});
});
} else {
this._handler.update({
timeRange: timeRange
timeRange: timeRange,
filters: filters,
});
}

Expand Down