Commit f0554a0f authored by Francesc Guasch's avatar Francesc Guasch
Browse files

Merge branch 'robertperez-upc-feat/1500_listusers/develop' into develop

parents 331bdb67 df61f9d4
......@@ -129,6 +129,9 @@ my $WS = Ravada::WebSocket->new(ravada => $RAVADA);
my %ALLOWED_ANONYMOUS_WS = map { $_ => 1 } qw(list_bases_anonymous list_alerts);
my %LDAP_ATTRIBUTES;
# TOODO: config this variable
my $LIMIT_SHOW_USERS = 25;
init();
############################################################################3
......@@ -2238,8 +2241,16 @@ sub admin {
return access_denied($c) if !$USER->is_admin && !$USER->can_manage_users && !$USER->can_grant;
$c->stash(list_users => []);
$c->stash(name => $c->param('name' or ''));
$c->stash(message => '');
if ( $c->param('name') ) {
$c->stash(list_users => $RAVADA->list_users($c->param('name') ))
} else {
my $users = $RAVADA->list_users();
if (($users) && (scalar(@$users) < $LIMIT_SHOW_USERS)) {
$c->stash(list_users => $users);
} else {
$c->stash(message => "There are ".scalar(@$users)." users. Type a search pattern to list them");
}
}
}
if ($page eq 'machines') {
......
......@@ -11,10 +11,14 @@
<h2 class="display-5"><%=l 'Users' %></h2>
<div class="card-title">
<form method="post" action="/admin/users">
<input type="text" name="name" placeholder="<%=l 'Users' %>">
<input type="text" name="name" placeholder="<%=l 'Users' %>"
value="<%= $name %>">
<input type="submit" value="<%=l 'Search' %>">
<button type="button" style="float: right; margin: 0 10px;" class="btn btn-success" onclick = "location='/users/register'"><%=l 'New user' %></button>
</form>
% if ($message) {
<%=l $message %>
% }
</div>
</div>
<div class="card-body">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment