mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-29 10:24:20 +01:00
defer member search in admin panel to optimize requesting
This commit is contained in:
parent
660a8abe8b
commit
5c57bcc7c6
@ -225,8 +225,11 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce',
|
||||
* Callback when the search field content changes: reload the search results
|
||||
*/
|
||||
$scope.updateTextSearch = function () {
|
||||
if (searchTimeout) clearTimeout(searchTimeout);
|
||||
searchTimeout = setTimeout(function() {
|
||||
resetSearchMember();
|
||||
return memberSearch();
|
||||
memberSearch();
|
||||
}, 500);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -252,6 +255,11 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce',
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Will temporize the search query to prevent overloading the API
|
||||
*/
|
||||
var searchTimeout = null;
|
||||
|
||||
/**
|
||||
* Iterate through the provided array and return the index of the requested admin
|
||||
* @param admins {Array} full list of users with role 'admin'
|
||||
@ -267,13 +275,13 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce',
|
||||
*/
|
||||
var resetSearchMember = function () {
|
||||
$scope.member.noMore = false;
|
||||
return $scope.member.page = 1;
|
||||
$scope.member.page = 1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Run a search query with the current parameters set ($scope.member[searchText,order,page])
|
||||
* and affect or append the result in $scope.members, depending on the concat parameter
|
||||
* @param concat {boolean} if true, the result will be append to $scope.members instead of being affected
|
||||
* @param [concat] {boolean} if true, the result will be append to $scope.members instead of being affected
|
||||
*/
|
||||
var memberSearch = function (concat) {
|
||||
Member.list({
|
||||
|
Loading…
Reference in New Issue
Block a user