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

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

@@ -18,7 +18,7 @@ class PageAttachment extends React.Component {
     this.state = {
       activePage: 1,
       totalAttachments: 0,
-      limit: Infinity,
+      limit: 10,
       attachments: [],
       inUse: {},
       attachmentToDelete: null,
@@ -34,11 +34,11 @@ class PageAttachment extends React.Component {
 
   async handlePage(selectedPage) {
     const { pageId } = this.props.pageContainer.state;
-    const activePage = selectedPage;
+    const page = selectedPage;
 
     if (!pageId) { return }
 
-    const res = await this.props.appContainer.apiv3Get('/attachment/list', { pageId, selectedPage });
+    const res = await this.props.appContainer.apiv3Get('/attachment/list', { pageId, page });
     const attachments = res.data.paginateResult.docs;
     const totalAttachments = res.data.paginateResult.totalDocs;
     const pagingLimit = res.data.paginateResult.limit;
@@ -49,7 +49,7 @@ class PageAttachment extends React.Component {
       inUse[attachment._id] = this.checkIfFileInUse(attachment);
     }
     this.setState({
-      activePage,
+      activePage: selectedPage,
       totalAttachments,
       limit: pagingLimit,
       attachments,

+ 6 - 6
src/server/routes/apiv3/attachment.js

@@ -26,12 +26,12 @@ module.exports = (crowi) => {
   const validator = {
     retrieveAttachments: [
       query('pageId').isMongoId().withMessage('pageId is required'),
-      query('pageLimitationS').custom((value) => {
+      query('limit').custom((value) => {
         if (value == null) {
           return 10;
         }
         if (value > 100) {
-          throw new Error('You should set less than 100 or not to set pageLimitationS.');
+          throw new Error('You should set less than 100 or not to set limit.');
         }
         return value;
       }),
@@ -57,9 +57,9 @@ module.exports = (crowi) => {
    */
   router.get('/list', accessTokenParser, loginRequired, validator.retrieveAttachments, apiV3FormValidator, async(req, res) => {
 
-    const pageLimitationS = req.query.pageLimitationS || await crowi.configManager.getConfig('crowi', 'customize:showPageLimitationS') || 10;
-    const selectedPage = req.query.selectedPage;
-    const offset = (selectedPage - 1) * pageLimitationS;
+    const limit = req.query.limit || await crowi.configManager.getConfig('crowi', 'customize:showPageLimitationS') || 10;
+    const page = req.query.page;
+    const offset = (page - 1) * limit;
 
     try {
       const pageId = req.query.pageId;
@@ -75,7 +75,7 @@ module.exports = (crowi) => {
       const paginateResult = await Attachment.paginate(
         { page: pageId },
         {
-          limit: pageLimitationS,
+          limit,
           offset,
           populate: {
             path: 'creator',