Cancel Discover fetch requests if a new one is submitted (#39963)

* Cancel discover fetch requests if a nnew one is submitted

* Add comment

* Remove unused translations
This commit is contained in:
Lukas Olson 2019-07-10 14:01:12 -07:00
parent b50c4c4dfe
commit bb6d66851a
3 changed files with 20 additions and 43 deletions

View file

@ -543,15 +543,9 @@ function discoverController(
$scope.updateDataSource()
.then(function () {
$scope.$listen(timefilter, 'fetch', function () {
$scope.fetch();
});
$scope.$listen(timefilter, 'refreshIntervalUpdate', () => {
$scope.updateRefreshInterval();
});
$scope.$listen(timefilter, 'timeUpdate', () => {
$scope.updateTime();
});
$scope.$listen(timefilter, 'autoRefreshFetch', $scope.fetch);
$scope.$listen(timefilter, 'refreshIntervalUpdate', $scope.updateRefreshInterval);
$scope.$listen(timefilter, 'timeUpdate', $scope.updateTime);
$scope.$watchCollection('state.sort', function (sort) {
if (!sort) return;
@ -710,20 +704,30 @@ function discoverController(
$scope.updateTime();
// Abort any in-progress requests before fetching again
$scope.searchSource.cancelQueued();
$scope.updateDataSource()
.then(setupVisualization)
.then(function () {
$state.save();
$scope.fetchStatus = fetchStatuses.LOADING;
logInspectorRequest();
return courier.fetch();
return $scope.searchSource.fetch();
})
.then(onResults)
.catch((error) => {
toastNotifications.addError(error, {
title: i18n.translate('kbn.discover.discoverError', {
defaultMessage: 'Discover error',
}),
});
const fetchError = getPainlessError(error);
if (fetchError) {
$scope.fetchError = fetchError;
} else {
toastNotifications.addError(error, {
title: i18n.translate('kbn.discover.errorLoadingData', {
defaultMessage: 'Error loading data',
}),
});
}
});
};
@ -769,8 +773,6 @@ function discoverController(
});
$scope.fetchStatus = fetchStatuses.COMPLETE;
return $scope.searchSource.onResults().then(onResults);
}
let inspectorRequest;
@ -796,29 +798,6 @@ function discoverController(
.ok({ json: resp });
}
function startSearching() {
return $scope.searchSource.onResults()
.then(onResults)
.catch((error) => {
const fetchError = getPainlessError(error);
if (fetchError) {
$scope.fetchError = fetchError;
} else {
toastNotifications.addError(error, {
title: i18n.translate('kbn.discover.errorLoadingData', {
defaultMessage: 'Error loading data',
}),
});
}
// Restart. This enables auto-refresh functionality.
startSearching();
});
}
startSearching();
$scope.updateTime = function () {
$scope.timeRange = {
from: dateMath.parse(timefilter.getTime().from),

View file

@ -1533,7 +1533,6 @@
"kbn.discover.bucketIntervalTooltip.tooManyBucketsText": "バケットが多すぎます",
"kbn.discover.discoverBreadcrumbTitle": "ディスカバリ",
"kbn.discover.discoverDescription": "ドキュメントにクエリをかけたりフィルターを適用することで、データをインタラクティブに閲覧できます。",
"kbn.discover.discoverError": "ディスカバリエラー",
"kbn.discover.discoverTitle": "ディスカバー",
"kbn.discover.documentsAriaLabel": "ドキュメント",
"kbn.discover.errorLoadingData": "データの読み込み中にエラーが発生",

View file

@ -1534,7 +1534,6 @@
"kbn.discover.bucketIntervalTooltip.tooManyBucketsText": "过多的存储桶",
"kbn.discover.discoverBreadcrumbTitle": "Discover",
"kbn.discover.discoverDescription": "通过查询和筛选原始文档来以交互方式浏览您的数据。",
"kbn.discover.discoverError": "Discover 错误",
"kbn.discover.discoverTitle": "Discover",
"kbn.discover.documentsAriaLabel": "文档",
"kbn.discover.errorLoadingData": "加载数据时出错",
@ -10917,4 +10916,4 @@
"xpack.watcher.watchActions.logging.logTextIsRequiredValidationMessage": "“日志文本”必填。",
"xpack.watcher.watcherDescription": "通过创建、管理和监测警报来检测数据中的更改。"
}
}
}