mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
Adding in global search id counter so that async search responses can be discarded if a newer search is being processed. This prevents older search results from clobbering a newer search that happened to complete faster.
This commit is contained in:
parent
3df592c702
commit
6152a5e3c2
@ -17,6 +17,7 @@ function (angular, _, config, $) {
|
||||
$scope.results = {dashboards: [], tags: [], metrics: []};
|
||||
$scope.query = { query: 'title:' };
|
||||
$scope.db = datasourceSrv.getGrafanaDB();
|
||||
$scope.currentSearchId = 0;
|
||||
|
||||
$timeout(function() {
|
||||
$scope.giveSearchFocus = $scope.giveSearchFocus + 1;
|
||||
@ -75,8 +76,18 @@ function (angular, _, config, $) {
|
||||
};
|
||||
|
||||
$scope.searchDashboards = function(queryString) {
|
||||
// bookeeping for determining stale search requests
|
||||
var searchId = $scope.currentSearchId + 1;
|
||||
$scope.currentSearchId = searchId > $scope.currentSearchId ? searchId : $scope.currentSearchId;
|
||||
|
||||
return $scope.db.searchDashboards(queryString)
|
||||
.then(function(results) {
|
||||
// since searches are async, it's possible that these results are not for the latest search. throw
|
||||
// them away if so
|
||||
if (searchId < $scope.currentSearchId) {
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.tagsOnly = results.tagsOnly;
|
||||
$scope.results.dashboards = results.dashboards;
|
||||
$scope.results.tags = results.tags;
|
||||
|
Loading…
Reference in New Issue
Block a user