|
@@ -20,13 +20,28 @@ const G2GDataTransfer = (): JSX.Element => {
|
|
|
const { data: socket } = useAdminSocket();
|
|
const { data: socket } = useAdminSocket();
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
- const [collections, setCollections] = useState<any[]>([]);
|
|
|
|
|
|
|
+ const [startTransferKey, setStartTransferKey] = useState('');
|
|
|
|
|
+ const [collections, setCollections] = useState<string[]>([]);
|
|
|
|
|
+ const [selectedCollections, setSelectedCollections] = useState<Set<string>>(new Set());
|
|
|
|
|
+ const [optionsMap, setOptionsMap] = useState<any>({});
|
|
|
const [isShowExportForm, setShowExportForm] = useState(false);
|
|
const [isShowExportForm, setShowExportForm] = useState(false);
|
|
|
const [isExporting, setExporting] = useState(false);
|
|
const [isExporting, setExporting] = useState(false);
|
|
|
// TODO: データのエクスポートが完了したことが分かるようにする
|
|
// TODO: データのエクスポートが完了したことが分かるようにする
|
|
|
const [isExported, setExported] = useState(false);
|
|
const [isExported, setExported] = useState(false);
|
|
|
|
|
|
|
|
- const fetchData = useCallback(async() => {
|
|
|
|
|
|
|
+ const updateSelectedCollections = (newSelectedCollections: Set<string>) => {
|
|
|
|
|
+ setSelectedCollections(newSelectedCollections);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const updateOptionsMap = (newOptionsMap: any) => {
|
|
|
|
|
+ setOptionsMap(newOptionsMap);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const onChangeTransferKeyHandler = useCallback((e) => {
|
|
|
|
|
+ setStartTransferKey(e.target.value);
|
|
|
|
|
+ }, []);
|
|
|
|
|
+
|
|
|
|
|
+ const setCollectionsAndSelectedCollections = useCallback(async() => {
|
|
|
const [{ data: collectionsData }, { data: statusData }] = await Promise.all([
|
|
const [{ data: collectionsData }, { data: statusData }] = await Promise.all([
|
|
|
apiv3Get<{collections: any[]}>('/mongo/collections', {}),
|
|
apiv3Get<{collections: any[]}>('/mongo/collections', {}),
|
|
|
apiv3Get<{status: { zipFileStats: any[], isExporting: boolean, progressList: any[] }}>('/export/status', {}),
|
|
apiv3Get<{status: { zipFileStats: any[], isExporting: boolean, progressList: any[] }}>('/export/status', {}),
|
|
@@ -38,6 +53,7 @@ const G2GDataTransfer = (): JSX.Element => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
setCollections(filteredCollections);
|
|
setCollections(filteredCollections);
|
|
|
|
|
+ setSelectedCollections(new Set(filteredCollections));
|
|
|
setExporting(statusData.status.isExporting);
|
|
setExporting(statusData.status.isExporting);
|
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
|
@@ -74,15 +90,19 @@ const G2GDataTransfer = (): JSX.Element => {
|
|
|
generateTransferKeyWithThrottle();
|
|
generateTransferKeyWithThrottle();
|
|
|
}, [generateTransferKeyWithThrottle]);
|
|
}, [generateTransferKeyWithThrottle]);
|
|
|
|
|
|
|
|
- const transferData = () => {
|
|
|
|
|
- // データ移行の処理
|
|
|
|
|
|
|
+ const startTransfer = (e) => {
|
|
|
|
|
+ e.preventDefault();
|
|
|
|
|
+
|
|
|
|
|
+ // console.log(startTransferKey);
|
|
|
|
|
+ // console.log(selectedCollections);
|
|
|
|
|
+ // console.log(optionsMap);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
- fetchData();
|
|
|
|
|
|
|
+ setCollectionsAndSelectedCollections();
|
|
|
|
|
|
|
|
setupWebsocketEventHandler();
|
|
setupWebsocketEventHandler();
|
|
|
- }, [fetchData, setupWebsocketEventHandler]);
|
|
|
|
|
|
|
+ }, [setCollectionsAndSelectedCollections, setupWebsocketEventHandler]);
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div data-testid="admin-export-archive-data">
|
|
<div data-testid="admin-export-archive-data">
|
|
@@ -94,14 +114,26 @@ const G2GDataTransfer = (): JSX.Element => {
|
|
|
|
|
|
|
|
{collections.length !== 0 && (
|
|
{collections.length !== 0 && (
|
|
|
<div className={isShowExportForm ? '' : 'd-none'}>
|
|
<div className={isShowExportForm ? '' : 'd-none'}>
|
|
|
- <G2GDataTransferExportForm allCollectionNames={collections} />
|
|
|
|
|
|
|
+ <G2GDataTransferExportForm
|
|
|
|
|
+ allCollectionNames={collections}
|
|
|
|
|
+ selectedCollections={selectedCollections}
|
|
|
|
|
+ updateSelectedCollections={updateSelectedCollections}
|
|
|
|
|
+ optionsMap={optionsMap}
|
|
|
|
|
+ updateOptionsMap={updateOptionsMap}
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
)}
|
|
)}
|
|
|
|
|
|
|
|
- <form onSubmit={transferData}>
|
|
|
|
|
|
|
+ <form onSubmit={startTransfer}>
|
|
|
<div className="form-group row mt-3">
|
|
<div className="form-group row mt-3">
|
|
|
<div className="col-9">
|
|
<div className="col-9">
|
|
|
- <input className="form-control" type="text" placeholder={t('admin:g2g_data_transfer.paste_transfer_key')} />
|
|
|
|
|
|
|
+ <input
|
|
|
|
|
+ className="form-control"
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ placeholder={t('admin:g2g_data_transfer.paste_transfer_key')}
|
|
|
|
|
+ onChange={onChangeTransferKeyHandler}
|
|
|
|
|
+ required
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
<div className="col-3">
|
|
<div className="col-3">
|
|
|
<button type="submit" className="btn btn-primary w-100">{t('admin:g2g_data_transfer.start_transfer')}</button>
|
|
<button type="submit" className="btn btn-primary w-100">{t('admin:g2g_data_transfer.start_transfer')}</button>
|