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) {
|
function paginate(set: unknown[], page: number, pageSize: number = 20) {
|
||||||
return {
|
return {
|
||||||
page,
|
page,
|
||||||
pageCount: Math.ceil(set.length / pageSize),
|
|
||||||
items: set.slice((page - 1) * pageSize, page * 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,
|
nextPage: page * pageSize < set.length ? page + 1 : null,
|
||||||
prevPage: page > 1 ? page - 1 : null,
|
prevPage: page > 1 ? page - 1 : null,
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
<% if (users.length === 0) { %>
|
<% if (users.length === 0) { %>
|
||||||
<p>No users found.</p>
|
<p>No users found.</p>
|
||||||
<% } %>
|
<% } else { %>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -47,6 +47,9 @@
|
||||||
<% } %>
|
<% } %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<p>Showing <%= page * pageSize - pageSize + 1 %> to <%= users.length + page * pageSize - pageSize %> of <%= totalCount %> users.</p>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.querySelectorAll("td.actions a.ban").forEach(function (a) {
|
document.querySelectorAll("td.actions a.ban").forEach(function (a) {
|
||||||
a.addEventListener("click", function (e) {
|
a.addEventListener("click", function (e) {
|
||||||
|
|
Loading…
Reference in New Issue