Преглед изворни кода

show zip fileName in toastr

Yuki Takei пре 6 година
родитељ
комит
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
     // websocket event
-    socket.on('admin:onTerminateForExport', ({ zipFileStats }) => {
+    socket.on('admin:onTerminateForExport', ({ addedZipFileStat }) => {
+      const zipFileStats = this.state.zipFileStats.concat([addedZipFileStat]);
+
       this.setState({
       this.setState({
         isExporting: false,
         isExporting: false,
         isExported: true,
         isExported: true,
@@ -73,7 +75,7 @@ class ExportPage extends React.Component {
       });
       });
 
 
       // TODO: toastSuccess, toastError
       // TODO: toastSuccess, toastError
-      toastr.success(undefined, 'New Exported Data is added', {
+      toastr.success(undefined, `New Exported Data '${addedZipFileStat.fileName}' is added`, {
         closeButton: true,
         closeButton: true,
         progressBar: true,
         progressBar: true,
         newestOnTop: false,
         newestOnTop: false,

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

@@ -232,7 +232,10 @@ class ExportService {
     const zipFile = await this.zipFiles(configs);
     const zipFile = await this.zipFiles(configs);
 
 
     // get stats for the zip file
     // 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
     // TODO: remove broken zip file
   }
   }
@@ -296,6 +299,14 @@ class ExportService {
     this.adminEvent.emit('onProgressForExport', data);
     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
    * zip files into one zip file
    *
    *
@@ -342,10 +353,6 @@ class ExportService {
 
 
     logger.info(`zipped growi data into ${zipFile} (${archive.pointer()} bytes)`);
     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
     // delete json files
     for (const { from } of configs) {
     for (const { from } of configs) {
       fs.unlinkSync(from);
       fs.unlinkSync(from);