Add pagination to admin pages
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Râu Cao 2023-03-01 17:08:36 +08:00
parent 3aad27c7bd
commit cbbb4c6e47
Signed by: raucao
GPG Key ID: 15E65F399D084BA9
6 changed files with 11 additions and 6 deletions

View File

@ -5,7 +5,8 @@ class Admin::DonationsController < Admin::BaseController
# GET /donations
# GET /donations.json
def index
@donations = Donation.all.order('created_at desc')
@pagy, @donations = pagy(Donation.all.order('created_at desc'))
@stats = {
overall_sats: @donations.all.sum("amount_sats"),
donor_count: Donation.distinct.count(:user_id)

View File

@ -1,7 +1,8 @@
class Admin::InvitationsController < Admin::BaseController
def index
@current_section = :invitations
@invitations_used = Invitation.used.order('used_at desc')
@pagy, @invitations_used = pagy(Invitation.used.order('used_at desc'))
@stats = {
available: Invitation.unused.count,
accepted: @invitations_used.length,

View File

@ -6,7 +6,7 @@ class Admin::UsersController < Admin::BaseController
ldap = LdapService.new
@ou = params[:ou] || "kosmos.org"
@orgs = ldap.fetch_organizations
@users = User.where(ou: @ou).order(cn: :asc).to_a
@pagy, @users = pagy(User.where(ou: @ou).order(cn: :asc))
@stats = {
users_confirmed: User.where(ou: @ou).confirmed.count,

View File

@ -21,7 +21,7 @@
<section>
<% if @donations.any? %>
<h3>Recent Donations</h3>
<table class="divided">
<table class="divided mb-8">
<thead>
<tr>
<th>User</th>
@ -52,6 +52,7 @@
<% end %>
</tbody>
</table>
<%== pagy_nav @pagy %>
<% else %>
<p>
No donations yet.

View File

@ -24,7 +24,7 @@
<% if @invitations_used.any? %>
<section>
<h3>Recently Accepted</h3>
<table class="divided">
<table class="divided mb-8">
<thead>
<tr>
<th>Token</th>
@ -44,6 +44,7 @@
<% end %>
</tbody>
</table>
<%== pagy_nav @pagy %>
</section>
<% end %>
<% end %>

View File

@ -30,7 +30,7 @@
<% end %>
<section>
<table class="divided">
<table class="divided mb-8">
<thead>
<tr>
<th>UID</th>
@ -49,5 +49,6 @@
<% end %>
</tbody>
</table>
<%== pagy_nav @pagy %>
</section>
<% end %>