adds pagination info below user table
This commit is contained in:
parent
dc32e41ab5
commit
81ceee7897
|
@ -37,8 +37,10 @@ const UserSchemaWithToken = UserSchema.extend({
|
|||
function paginate(set: unknown[], page: number, pageSize: number = 20) {
|
||||
return {
|
||||
page,
|
||||
pageCount: Math.ceil(set.length / pageSize),
|
||||
items: set.slice((page - 1) * pageSize, page * pageSize),
|
||||
pageSize,
|
||||
pageCount: Math.ceil(set.length / pageSize),
|
||||
totalCount: set.length,
|
||||
nextPage: page * pageSize < set.length ? page + 1 : null,
|
||||
prevPage: page > 1 ? page - 1 : null,
|
||||
};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<% if (users.length === 0) { %>
|
||||
<p>No users found.</p>
|
||||
<% } %>
|
||||
<% } else { %>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -47,6 +47,9 @@
|
|||
<% } %>
|
||||
</ul>
|
||||
|
||||
<p>Showing <%= page * pageSize - pageSize + 1 %> to <%= users.length + page * pageSize - pageSize %> of <%= totalCount %> users.</p>
|
||||
<% } %>
|
||||
|
||||
<script>
|
||||
document.querySelectorAll("td.actions a.ban").forEach(function (a) {
|
||||
a.addEventListener("click", function (e) {
|
||||
|
|
Loading…
Reference in New Issue