Commit 09b5d575 authored by Joel Alarcón's avatar Joel Alarcón Committed by Francesc Guasch
Browse files

feat(frontend): display all users by default when <= 20

* 224_all_users: feat: display all users by default when total users <= 20. issue #224.

* 224_all_users: feat: user list now is ordered by name instead of id. issue #224
parent b2fb4655
...@@ -446,7 +446,7 @@ Returns a reference to a list of the users ...@@ -446,7 +446,7 @@ Returns a reference to a list of the users
=cut =cut
sub list_users($self,$name=undef) { sub list_users($self,$name=undef) {
my $sth = $CONNECTOR->dbh->prepare("SELECT id, name FROM users "); my $sth = $CONNECTOR->dbh->prepare("SELECT id, name FROM users ORDER BY name");
$sth->execute(); $sth->execute();
my @users = (); my @users = ();
...@@ -459,6 +459,31 @@ sub list_users($self,$name=undef) { ...@@ -459,6 +459,31 @@ sub list_users($self,$name=undef) {
return \@users; return \@users;
} }
=head2 list_users_all
Returns a reference to a list of all the users if the total <= 20.
=cut
sub list_users_all {
my @users = ();
my $sth_aux = $CONNECTOR->dbh->prepare("SELECT COUNT(*) FROM users");
$sth_aux->execute();
my ($row_aux) = $sth_aux->fetchrow();
$sth_aux->finish;
if ($row_aux <= 20) {
my $sth = $CONNECTOR->dbh->prepare("SELECT id, name FROM users ORDER BY name");
$sth->execute();
while ( my $row = $sth->fetchrow_hashref) {
push @users, ($row);
}
$sth->finish;
}
return \@users;
}
=head2 create_domain =head2 create_domain
Request the creation of a new domain or virtual machine Request the creation of a new domain or virtual machine
......
...@@ -980,6 +980,9 @@ sub admin { ...@@ -980,6 +980,9 @@ sub admin {
if ( $c->param('name') ) { if ( $c->param('name') ) {
$c->stash(list_users => $RAVADA->list_users($c->param('name') )) $c->stash(list_users => $RAVADA->list_users($c->param('name') ))
} }
else {
$c->stash(list_users => $RAVADA->list_users_all());
}
} }
if ($page eq 'machines') { if ($page eq 'machines') {
$c->stash(hide_clones => 0 ); $c->stash(hide_clones => 0 );
......
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