|
@@ -1,17 +1,13 @@
|
|
|
-import React, { Fragment } from 'react';
|
|
|
|
|
|
|
+import React from 'react';
|
|
|
|
|
|
|
|
-import PropTypes from 'prop-types';
|
|
|
|
|
import { useTranslation } from 'next-i18next';
|
|
import { useTranslation } from 'next-i18next';
|
|
|
|
|
+import PropTypes from 'prop-types';
|
|
|
import * as toastr from 'toastr';
|
|
import * as toastr from 'toastr';
|
|
|
|
|
|
|
|
|
|
|
|
|
-import AdminSocketIoContainer from '~/client/services/AdminSocketIoContainer';
|
|
|
|
|
-import AppContainer from '~/client/services/AppContainer';
|
|
|
|
|
-import { apiDelete, apiGet } from '~/client/util/apiv1-client';
|
|
|
|
|
-
|
|
|
|
|
-import { withUnstatedContainers } from '../UnstatedUtils';
|
|
|
|
|
// import { toastSuccess, toastError } from '~/client/util/apiNotification';
|
|
// import { toastSuccess, toastError } from '~/client/util/apiNotification';
|
|
|
-
|
|
|
|
|
|
|
+import { apiDelete, apiGet } from '~/client/util/apiv1-client';
|
|
|
|
|
+import { useAdminSocket } from '~/stores/socket-io';
|
|
|
|
|
|
|
|
import LabeledProgressBar from './Common/LabeledProgressBar';
|
|
import LabeledProgressBar from './Common/LabeledProgressBar';
|
|
|
import ArchiveFilesTable from './ExportArchiveData/ArchiveFilesTable';
|
|
import ArchiveFilesTable from './ExportArchiveData/ArchiveFilesTable';
|
|
@@ -70,45 +66,47 @@ class ExportArchiveDataPage extends React.Component {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
setupWebsocketEventHandler() {
|
|
setupWebsocketEventHandler() {
|
|
|
- const socket = this.props.adminSocketIoContainer.getSocket();
|
|
|
|
|
-
|
|
|
|
|
- // websocket event
|
|
|
|
|
- socket.on('admin:onProgressForExport', ({ currentCount, totalCount, progressList }) => {
|
|
|
|
|
- this.setState({
|
|
|
|
|
- isExporting: true,
|
|
|
|
|
- progressList,
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- // websocket event
|
|
|
|
|
- socket.on('admin:onStartZippingForExport', () => {
|
|
|
|
|
- this.setState({
|
|
|
|
|
- isZipping: true,
|
|
|
|
|
|
|
+ const { socket } = this.props;
|
|
|
|
|
+
|
|
|
|
|
+ if (socket != null) {
|
|
|
|
|
+ // websocket event
|
|
|
|
|
+ socket.on('admin:onProgressForExport', ({ currentCount, totalCount, progressList }) => {
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ isExporting: true,
|
|
|
|
|
+ progressList,
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- // websocket event
|
|
|
|
|
- socket.on('admin:onTerminateForExport', ({ addedZipFileStat }) => {
|
|
|
|
|
- const zipFileStats = this.state.zipFileStats.concat([addedZipFileStat]);
|
|
|
|
|
|
|
|
|
|
- this.setState({
|
|
|
|
|
- isExporting: false,
|
|
|
|
|
- isZipping: false,
|
|
|
|
|
- isExported: true,
|
|
|
|
|
- zipFileStats,
|
|
|
|
|
|
|
+ // websocket event
|
|
|
|
|
+ socket.on('admin:onStartZippingForExport', () => {
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ isZipping: true,
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- // TODO: toastSuccess, toastError
|
|
|
|
|
- toastr.success(undefined, `New Archive Data '${addedZipFileStat.fileName}' is added`, {
|
|
|
|
|
- closeButton: true,
|
|
|
|
|
- progressBar: true,
|
|
|
|
|
- newestOnTop: false,
|
|
|
|
|
- showDuration: '100',
|
|
|
|
|
- hideDuration: '100',
|
|
|
|
|
- timeOut: '1200',
|
|
|
|
|
- extendedTimeOut: '150',
|
|
|
|
|
|
|
+ // websocket event
|
|
|
|
|
+ socket.on('admin:onTerminateForExport', ({ addedZipFileStat }) => {
|
|
|
|
|
+ const zipFileStats = this.state.zipFileStats.concat([addedZipFileStat]);
|
|
|
|
|
+
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ isExporting: false,
|
|
|
|
|
+ isZipping: false,
|
|
|
|
|
+ isExported: true,
|
|
|
|
|
+ zipFileStats,
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // TODO: toastSuccess, toastError
|
|
|
|
|
+ toastr.success(undefined, `New Archive Data '${addedZipFileStat.fileName}' is added`, {
|
|
|
|
|
+ closeButton: true,
|
|
|
|
|
+ progressBar: true,
|
|
|
|
|
+ newestOnTop: false,
|
|
|
|
|
+ showDuration: '100',
|
|
|
|
|
+ hideDuration: '100',
|
|
|
|
|
+ timeOut: '1200',
|
|
|
|
|
+ extendedTimeOut: '150',
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
- });
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onZipFileStatAdd(newStat) {
|
|
onZipFileStatAdd(newStat) {
|
|
@@ -250,18 +248,14 @@ class ExportArchiveDataPage extends React.Component {
|
|
|
|
|
|
|
|
ExportArchiveDataPage.propTypes = {
|
|
ExportArchiveDataPage.propTypes = {
|
|
|
t: PropTypes.func.isRequired, // i18next
|
|
t: PropTypes.func.isRequired, // i18next
|
|
|
- appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
|
|
|
- adminSocketIoContainer: PropTypes.instanceOf(AdminSocketIoContainer).isRequired,
|
|
|
|
|
|
|
+ socket: PropTypes.object,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const ExportArchiveDataPageWrapperFC = (props) => {
|
|
const ExportArchiveDataPageWrapperFC = (props) => {
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
- return <ExportArchiveDataPage t={t} {...props} />;
|
|
|
|
|
-};
|
|
|
|
|
|
|
+ const { data: socket } = useAdminSocket();
|
|
|
|
|
|
|
|
-/**
|
|
|
|
|
- * Wrapper component for using unstated
|
|
|
|
|
- */
|
|
|
|
|
-const ExportArchiveDataPageWrapper = withUnstatedContainers(ExportArchiveDataPageWrapperFC, [AppContainer, AdminSocketIoContainer]);
|
|
|
|
|
|
|
+ return <ExportArchiveDataPage t={t} socket={socket} {...props} />;
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
-export default ExportArchiveDataPageWrapper;
|
|
|
|
|
|
|
+export default ExportArchiveDataPageWrapperFC;
|