mizozobu 6 лет назад
Родитель
Сommit
f8fbdc389e

+ 2 - 2
src/client/js/components/Admin/Export/ExportAsZip.jsx

@@ -23,7 +23,7 @@ class ExportPage extends React.Component {
   }
 
   async componentDidMount() {
-    const res = await this.props.appContainer.apiGet('/v3/export', {});
+    const res = await this.props.appContainer.apiGet('/v3/export/status', {});
 
     this.setState({ files: res.files });
   }
@@ -94,7 +94,7 @@ class ExportPage extends React.Component {
           })}
         </form>
         <button type="button" className="btn btn-sm btn-default" onClick={this.exportMultiple}>Generate</button>
-        <a href="/_api/v3/export/download">
+        <a href="/_api/v3/export">
           <button type="button" className="btn btn-sm btn-primary ml-2">Download</button>
         </a>
         {/* <button type="button" className="btn btn-sm btn-danger ml-2" onClick={this.deleteZipFile}>Clear</button> */}

+ 6 - 15
src/server/routes/apiv3/export.js

@@ -19,25 +19,19 @@ module.exports = (crowi) => {
   /**
    * @swagger
    *
-   *  /export:
+   *  /export/status:
    *    get:
    *      tags: [Export]
    *      description: get mongodb collections names and zip files for them
    *      produces:
    *        - application/json
-   *      parameters:
-   *        - name: collectionName
-   *          in: path
-   *          description: collection name
-   *          schema:
-   *            type: string
    *      responses:
    *        200:
-   *          description: export cache info
+   *          description: export cache status
    *          content:
    *            application/json:
    */
-  router.get('/', async(req, res) => {
+  router.get('/status', async(req, res) => {
     const files = exportService.getStatus();
 
     // TODO: use res.apiv3
@@ -59,7 +53,7 @@ module.exports = (crowi) => {
    *          content:
    *            application/zip:
    */
-  router.get('/download', async(req, res) => {
+  router.get('/', async(req, res) => {
     // TODO: add express validator
     try {
       return res.download(exportService.zipFile);
@@ -118,21 +112,18 @@ module.exports = (crowi) => {
    *  /export:
    *    delete:
    *      tags: [Export]
-   *      description: unlink a json and zip file for a single collection
+   *      description: unlink all json and zip files for exports
    *      produces:
    *        - application/json
    *      responses:
    *        200:
-   *          description: the json and zip file are removed
+   *          description: the json and zip file are deleted
    *          content:
    *            application/json:
    */
   // router.delete('/', async(req, res) => {
   //   // TODO: add express validator
   //   try {
-  //     const { collectionName } = req.params;
-  //     // get model for collection
-  //     const Model = exportService.getModelFromCollectionName(collectionName);
   //     // remove .json and .zip for collection
   //     // TODO: use res.apiv3
   //     return res.status(200).send({ status: 'DONE' });