Add an explicit Client.getAllUsers function

This commit is contained in:
Johannes Zellner
2022-02-14 14:55:04 +01:00
parent b4bbdda730
commit 2ec4ad934d
5 changed files with 34 additions and 12 deletions

View File

@@ -1388,14 +1388,36 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
});
};
Client.prototype.getUsers = function (search, active, page, perPage, callback) {
if (typeof search === 'function') {
callback = search;
search = '';
page = 1;
perPage = 5000;
Client.prototype.getAllUsers = function (callback) {
var page = 1;
var perPage = 3;
var users = [];
function fetchMore() {
var config = {
params: {
page: page,
per_page: perPage
}
};
get('/api/v1/users', config, function (error, data, status) {
if (error) return callback(error);
if (status !== 200) return callback(new ClientError(status, data));
if (data.users.length === 0) return callback(null, users);
users = users.concat(data.users);
page++;
fetchMore();
});
}
fetchMore();
};
Client.prototype.getUsers = function (search, active, page, perPage, callback) {
var config = {
params: {
page: page,
@@ -1404,7 +1426,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
};
if (search) config.params.search = search;
if (active !== null && typeof active !== 'undefined') config.params.active = active ? 'true' : 'false';
if (active !== null) config.params.active = active ? 'true' : 'false';
get('/api/v1/users', config, function (error, data, status) {
if (error) return callback(error);