diff --git a/backend/src/app.ts b/backend/src/app.ts index ccdf91d..6450863 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -20,14 +20,21 @@ app.get('/api/character/:characterId', async (req, res) => { app.post('/api/character', jsonParser, async (req, res) => { const page = req.body.page - const orderBy = req.body.orderBy + const orderBy = req.body.orderBy ? obp.parse(req.body.orderBy) : ['id'] const count = req.body.count + const filter = req.body.filter ? fp.parse(req.body.filter) : {} const characterData = await Character.findAll({ offset: page * count, - limit: count + limit: count, + order: orderBy, + where: filter }) - const pageCount = Math.ceil((await Character.count()) / count) + const pageCount = Math.ceil( + (await Character.count({ + where: filter + })) / count + ) res.setHeader('Content-Type', 'application/json') res.json({ characterData, pageCount }) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 0833ea6..e37e74e 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -2,6 +2,7 @@ + Server Stats Games Characters GMs diff --git a/frontend/src/vues/CharacterList.vue b/frontend/src/vues/CharacterList.vue index 621b1ea..1a332ae 100644 --- a/frontend/src/vues/CharacterList.vue +++ b/frontend/src/vues/CharacterList.vue @@ -1,4 +1,11 @@