mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
added limit checks to up/down arrow key selection of search results
This commit is contained in:
parent
9f60745e57
commit
4a9380cc95
@ -31,10 +31,10 @@ function (angular, _, config, $) {
|
|||||||
$scope.emitAppEvent('hide-dash-editor');
|
$scope.emitAppEvent('hide-dash-editor');
|
||||||
}
|
}
|
||||||
if (evt.keyCode === 40) {
|
if (evt.keyCode === 40) {
|
||||||
$scope.selectedIndex++;
|
$scope.moveSelection(1);
|
||||||
}
|
}
|
||||||
if (evt.keyCode === 38) {
|
if (evt.keyCode === 38) {
|
||||||
$scope.selectedIndex--;
|
$scope.moveSelection(-1);
|
||||||
}
|
}
|
||||||
if (evt.keyCode === 13) {
|
if (evt.keyCode === 13) {
|
||||||
if ($scope.tagsOnly) {
|
if ($scope.tagsOnly) {
|
||||||
@ -56,6 +56,10 @@ function (angular, _, config, $) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.moveSelection = function(direction) {
|
||||||
|
$scope.selectedIndex = Math.max(Math.min($scope.selectedIndex + direction, $scope.resultCount - 1), 0);
|
||||||
|
};
|
||||||
|
|
||||||
$scope.goToDashboard = function(id) {
|
$scope.goToDashboard = function(id) {
|
||||||
$location.path("/dashboard/db/" + id);
|
$location.path("/dashboard/db/" + id);
|
||||||
};
|
};
|
||||||
@ -76,6 +80,7 @@ function (angular, _, config, $) {
|
|||||||
$scope.tagsOnly = results.tagsOnly;
|
$scope.tagsOnly = results.tagsOnly;
|
||||||
$scope.results.dashboards = results.dashboards;
|
$scope.results.dashboards = results.dashboards;
|
||||||
$scope.results.tags = results.tags;
|
$scope.results.tags = results.tags;
|
||||||
|
$scope.resultCount = results.tagsOnly ? results.tags.length : results.dashboards.length;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user