mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-07 19:10:12 +08:00
feat: add pagination buttons
This commit is contained in:
1 parent
fa36b63fbe
commit
3b68693177
8 files changed
+52
-19
No files matched your search
@@ -8,12 +8,15 @@ export async function commandListController(req, res) {
|
||||
const itemsPerPage = 100
|
||||
|
||||
try {
|
||||
const payload = await errorCommands(
|
||||
new Pagination(order, itemsPerPage, nextKey)
|
||||
)
|
||||
const pagination = new Pagination(order, itemsPerPage, nextKey)
|
||||
const payload = await errorCommands(pagination)
|
||||
const newNextKey = payload[payload.length - 1]?._id
|
||||
|
||||
res.render('commands', { errorCommands: payload, nextKey: newNextKey })
|
||||
res.render('commands', {
|
||||
errorCommands: payload,
|
||||
nextKey: newNextKey,
|
||||
order: pagination.getOrder(),
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
res.status(500).send('Error fetching data')
|
||||
|
||||
@@ -6,15 +6,15 @@ export async function sessionListController(req, res) {
|
||||
const itemsPerPage = 50
|
||||
|
||||
try {
|
||||
// const totalSessions = await sessionCount()
|
||||
// const maxPages = Math.ceil(totalSessions / itemsPerPage)
|
||||
|
||||
const sessions = await sessionList(
|
||||
new Pagination(order, itemsPerPage, nextKey)
|
||||
)
|
||||
const pagination = new Pagination(order, itemsPerPage, nextKey)
|
||||
const sessions = await sessionList(pagination)
|
||||
const newNextKey = sessions[sessions.length - 1]?._id
|
||||
|
||||
res.render('sessions', { sessions, nextKey: newNextKey })
|
||||
res.render('sessions', {
|
||||
sessions,
|
||||
nextKey: newNextKey,
|
||||
order: pagination.getOrder(),
|
||||
})
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
res.status(500).send('Error fetching session data')
|
||||
|
||||
@@ -6,10 +6,15 @@ export async function userListController(req, res) {
|
||||
const itemsPerPage = 50
|
||||
|
||||
try {
|
||||
const users = await userList(new Pagination(order, itemsPerPage, nextKey))
|
||||
const pagination = new Pagination(order, itemsPerPage, nextKey)
|
||||
const users = await userList(pagination)
|
||||
const newNextKey = users[users.length - 1]?._id
|
||||
|
||||
res.render('users', { users, nextKey: newNextKey })
|
||||
res.render('users', {
|
||||
users,
|
||||
nextKey: newNextKey,
|
||||
order: pagination.getOrder(),
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
res.status(500).send('Error fetching user data')
|
||||
|
||||
Reference in new issue
Block a user