Просмотр исходного кода

Merge branch 'apiv3-for-attachment.js-and-change-name-to-attachments.js' into add-pagination-in-endpoint-of-attachment

zahmis 5 лет назад
Родитель
Сommit
e35354d0e5

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

@@ -32,14 +32,11 @@ class PageAttachment extends React.Component {
       return;
     }
 
-    this.props.appContainer.apiv3Get('/attachment/list', { pageId })
+    this.props.appContainer.apiv3Get('/attachments/list', { pageId })
       .then((res) => {
         const attachments = res.data.attachments;
         const inUse = {};
 
-        console.log(res);
-        console.log(res.data.attachments);
-
         for (const attachment of attachments) {
           inUse[attachment._id] = this.checkIfFileInUse(attachment);
         }

+ 5 - 2
src/server/routes/apiv3/attachment.js → src/server/routes/apiv3/attachments.js

@@ -1,6 +1,6 @@
 const loggerFactory = require('@alias/logger');
 
-const logger = loggerFactory('growi:routes:apiv3:attachment'); // eslint-disable-line no-unused-vars
+const logger = loggerFactory('growi:routes:apiv3:attachments'); // eslint-disable-line no-unused-vars
 
 const express = require('express');
 
@@ -23,7 +23,7 @@ module.exports = (crowi) => {
   /**
    * @swagger
    *
-   *    /attachment/list:
+   *    /attachments/list:
    *      get:
    *        tags: [Attachment]
    *        description: Get attachment list
@@ -42,6 +42,7 @@ module.exports = (crowi) => {
 
     try {
       const pageId = req.query.pageId;
+
       // check whether accessible
       const isAccessible = await Page.isAccessiblePageByViewer(pageId, req.user);
       if (!isAccessible) {
@@ -50,7 +51,9 @@ module.exports = (crowi) => {
       }
 
       const attachments = await Attachment.find({ page: pageId });
+
       return res.apiv3({ attachments });
+
     }
     catch (err) {
       logger.error('Attachment not found', err);

+ 1 - 1
src/server/routes/apiv3/index.js

@@ -44,7 +44,7 @@ module.exports = (crowi) => {
   router.use('/share-links', require('./share-links')(crowi));
 
   router.use('/bookmarks', require('./bookmarks')(crowi));
-  router.use('/attachment', require('./attachment')(crowi));
+  router.use('/attachments', require('./attachments')(crowi));
 
   return router;
 };