Yuki Takei 6 лет назад
Родитель
Сommit
fe4f30e46e
2 измененных файлов с 16 добавлено и 7 удалено
  1. 4 2
      src/client/js/components/Admin/Export/ExportPage.jsx
  2. 12 5
      src/server/service/export.js

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

@@ -65,7 +65,9 @@ class ExportPage extends React.Component {
     });
 
     // websocket event
-    socket.on('admin:onTerminateForExport', ({ zipFileStats }) => {
+    socket.on('admin:onTerminateForExport', ({ addedZipFileStat }) => {
+      const zipFileStats = this.state.zipFileStats.concat([addedZipFileStat]);
+
       this.setState({
         isExporting: false,
         isExported: true,
@@ -73,7 +75,7 @@ class ExportPage extends React.Component {
       });
 
       // TODO: toastSuccess, toastError
-      toastr.success(undefined, 'New Exported Data is added', {
+      toastr.success(undefined, `New Exported Data '${addedZipFileStat.fileName}' is added`, {
         closeButton: true,
         progressBar: true,
         newestOnTop: false,

+ 12 - 5
src/server/service/export.js

@@ -232,7 +232,10 @@ class ExportService {
     const zipFile = await this.zipFiles(configs);
 
     // get stats for the zip file
-    return this.growiBridgeService.parseZipFile(zipFile);
+    const addedZipFileStat = await this.growiBridgeService.parseZipFile(zipFile);
+
+    // send terminate event
+    this.emitTerminateEvent(addedZipFileStat);
 
     // TODO: remove broken zip file
   }
@@ -296,6 +299,14 @@ class ExportService {
     this.adminEvent.emit('onProgressForExport', data);
   }
 
+  /**
+   * emit terminate event
+   * @param {object} zipFileStat added zip file status data
+   */
+  emitTerminateEvent(zipFileStat) {
+    this.adminEvent.emit('onTerminateForExport', { addedZipFileStat: zipFileStat });
+  }
+
   /**
    * zip files into one zip file
    *
@@ -342,10 +353,6 @@ class ExportService {
 
     logger.info(`zipped growi data into ${zipFile} (${archive.pointer()} bytes)`);
 
-    // send terminate event
-    const { zipFileStats } = await this.getStatus();
-    this.adminEvent.emit('onTerminateForExport', { zipFileStats });
-
     // delete json files
     for (const { from } of configs) {
       fs.unlinkSync(from);