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

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

@@ -46,14 +46,14 @@ class ExportAsZip extends React.Component {
 
   async export() {
     // TODO use appContainer.apiv3.post
-    const res = await this.props.appContainer.apiPost('/v3/export', { collections: Array.from(this.state.collections) });
+    const { zipFileStat } = await this.props.appContainer.apiPost('/v3/export', { collections: Array.from(this.state.collections) });
     // TODO toastSuccess, toastError
     this.setState((prevState) => {
       return {
-        files: {
-          ...prevState.files,
-          [res.collection]: res.file,
-        },
+        zipFileStats: [
+          ...prevState.zipFileStats,
+          zipFileStat,
+        ],
       };
     });
   }
@@ -61,6 +61,12 @@ class ExportAsZip extends React.Component {
   async deleteZipFile(zipFile) {
     // TODO use appContainer.apiv3.delete
     await this.props.appContainer.apiRequest('delete', `/v3/export/${zipFile}`, {});
+
+    this.setState((prevState) => {
+      return {
+        zipFileStats: prevState.zipFileStats.filter(stat => stat.fileName !== zipFile),
+      };
+    });
     // TODO toastSuccess, toastError
   }
 

+ 4 - 3
src/server/routes/apiv3/export.js

@@ -14,7 +14,7 @@ const router = express.Router();
  */
 
 module.exports = (crowi) => {
-  const { exportService } = crowi;
+  const { growiBridgeService, exportService } = crowi;
 
   /**
    * @swagger
@@ -98,12 +98,13 @@ module.exports = (crowi) => {
       configs.push({ from: metaJson, as: path.basename(metaJson) });
       // exec zip
       const zipFile = await exportService.zipFiles(configs);
+      // get stats for the zip file
+      const zipFileStat = await growiBridgeService.parseZipFile(zipFile);
 
       // TODO: use res.apiv3
       return res.status(200).json({
         ok: true,
-        // collection: [Model.collection.collectionName],
-        file: path.basename(zipFile),
+        zipFileStat,
       });
     }
     catch (err) {