zahmis 5 лет назад
Родитель
Сommit
4b6313a348
2 измененных файлов с 5 добавлено и 3 удалено
  1. 1 1
      src/client/js/components/PageAttachment.jsx
  2. 4 2
      src/server/routes/apiv3/attachment.js

+ 1 - 1
src/client/js/components/PageAttachment.jsx

@@ -38,7 +38,7 @@ class PageAttachment extends React.Component {
 
 
     if (!pageId) { return }
     if (!pageId) { return }
 
 
-    const res = await this.props.appContainer.apiv3Get('/attachment/list', { pageId });
+    const res = await this.props.appContainer.apiv3Get('/attachment/list', { pageId, selectedPage });
     const attachments = res.data.paginateResult.docs;
     const attachments = res.data.paginateResult.docs;
     const totalAttachments = res.data.paginateResult.totalDocs;
     const totalAttachments = res.data.paginateResult.totalDocs;
     const pagingLimit = res.data.paginateResult.limit;
     const pagingLimit = res.data.paginateResult.limit;

+ 4 - 2
src/server/routes/apiv3/attachment.js

@@ -50,7 +50,7 @@ module.exports = (crowi) => {
    *              type: string
    *              type: string
    */
    */
   router.get('/list', accessTokenParser, loginRequired, validator.retrieveAttachments, apiV3FormValidator, async(req, res) => {
   router.get('/list', accessTokenParser, loginRequired, validator.retrieveAttachments, apiV3FormValidator, async(req, res) => {
-    // const offset = +req.query.offset || 0;
+
 
 
     try {
     try {
       const pageId = req.query.pageId;
       const pageId = req.query.pageId;
@@ -63,11 +63,13 @@ module.exports = (crowi) => {
 
 
       // directly get paging-size from db. not to delivery from client side.
       // directly get paging-size from db. not to delivery from client side.
       const pageLimitationS = await crowi.configManager.getConfig('crowi', 'customize:showPageLimitationS') || 10;
       const pageLimitationS = await crowi.configManager.getConfig('crowi', 'customize:showPageLimitationS') || 10;
+      const selectedPage = req.query.selectedPage;
+      const offset = (selectedPage - 1) * pageLimitationS;
       const paginateResult = await Attachment.paginate(
       const paginateResult = await Attachment.paginate(
         { page: pageId },
         { page: pageId },
         {
         {
           limit: pageLimitationS,
           limit: pageLimitationS,
-          // offset,
+          offset,
           populate: {
           populate: {
             path: 'creator',
             path: 'creator',
             select: User.USER_PUBLIC_FIELDS,
             select: User.USER_PUBLIC_FIELDS,