Skip to content
Merged
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 @@ -238,28 +238,9 @@ function discoverController(
$scope.state = { ...newState };

// detect changes that should trigger fetching of new data
const changes = ['interval', 'sort', 'index', 'query'].filter(
const changes = ['interval', 'sort', 'query'].filter(
prop => !_.isEqual(newStatePartial[prop], oldStatePartial[prop])
);
if (changes.indexOf('index') !== -1) {
try {
$scope.indexPattern = await indexPatterns.get(newStatePartial.index);
$scope.opts.timefield = getTimeField();
$scope.enableTimeRangeSelector = !!$scope.opts.timefield;
// is needed to rerender the histogram
$scope.vis = undefined;

// Taking care of sort when switching index pattern:
// Old indexPattern: sort by A
// If A is not available in the new index pattern, sort has to be adapted and propagated to URL
const sort = getSortArray(newStatePartial.sort, $scope.indexPattern);
if (newStatePartial.sort && !_.isEqual(sort, newStatePartial.sort)) {
return await replaceUrlAppState({ sort });
}
} catch (e) {
toastNotifications.addWarning({ text: getIndexPatternWarning(newStatePartial.index) });
}
}

if (changes.length) {
$fetchObservable.next();
Expand All @@ -268,8 +249,9 @@ function discoverController(
}
});

$scope.setIndexPattern = id => {
setAppState({ index: id });
$scope.setIndexPattern = async id => {
await replaceUrlAppState({ index: id });
$route.reload();
};

// update data source when filters update
Expand Down