ui progress db import
This commit is contained in:
parent
57319507bb
commit
275b5125c1
1 changed files with 19 additions and 1 deletions
|
|
@ -950,17 +950,34 @@ const MigrationTab: React.FC = () => {
|
||||||
// --- Restore: Validate (uploads file to server, streams to disk) ---
|
// --- Restore: Validate (uploads file to server, streams to disk) ---
|
||||||
const importTokenRef = useRef('');
|
const importTokenRef = useRef('');
|
||||||
|
|
||||||
|
const [uploadProgress, setUploadProgress] = useState('');
|
||||||
|
|
||||||
const _validateFile = async (file: File) => {
|
const _validateFile = async (file: File) => {
|
||||||
setValidating(true);
|
setValidating(true);
|
||||||
setValidation(null);
|
setValidation(null);
|
||||||
|
setUploadProgress('');
|
||||||
importTokenRef.current = '';
|
importTokenRef.current = '';
|
||||||
|
|
||||||
|
const fileMb = (file.size / (1024 * 1024)).toFixed(1);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
const res = await api.post('/api/admin/database-health/migration/upload-import', formData, {
|
const res = await api.post('/api/admin/database-health/migration/upload-import', formData, {
|
||||||
headers: { 'Content-Type': 'multipart/form-data' },
|
headers: { 'Content-Type': 'multipart/form-data' },
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
|
onUploadProgress: (e) => {
|
||||||
|
if (e.total) {
|
||||||
|
const pct = Math.round((e.loaded / e.total) * 100);
|
||||||
|
const loadedMb = (e.loaded / (1024 * 1024)).toFixed(1);
|
||||||
|
setUploadProgress(pct < 100
|
||||||
|
? t('Upload: {loaded} / {total} MB ({pct}%)', { loaded: loadedMb, total: fileMb, pct })
|
||||||
|
: t('Validierung laeuft ({total} MB)...', { total: fileMb }),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
setUploadProgress('');
|
||||||
importTokenRef.current = res.data.token || '';
|
importTokenRef.current = res.data.token || '';
|
||||||
setValidation({
|
setValidation({
|
||||||
valid: res.data.valid,
|
valid: res.data.valid,
|
||||||
|
|
@ -974,6 +991,7 @@ const MigrationTab: React.FC = () => {
|
||||||
systemObjectsFound: res.data.systemObjectsFound || [],
|
systemObjectsFound: res.data.systemObjectsFound || [],
|
||||||
});
|
});
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
|
setUploadProgress('');
|
||||||
const detail = err?.response?.data?.detail;
|
const detail = err?.response?.data?.detail;
|
||||||
setValidation({
|
setValidation({
|
||||||
valid: false, summary: [], systemObjectsFound: [],
|
valid: false, summary: [], systemObjectsFound: [],
|
||||||
|
|
@ -1221,7 +1239,7 @@ const MigrationTab: React.FC = () => {
|
||||||
{validating && (
|
{validating && (
|
||||||
<div className={styles.loadingContainer} style={{ padding: '1rem' }}>
|
<div className={styles.loadingContainer} style={{ padding: '1rem' }}>
|
||||||
<div className={styles.spinner} />
|
<div className={styles.spinner} />
|
||||||
<span>{t('Validierung laeuft...')}</span>
|
<span>{uploadProgress || t('Validierung laeuft...')}</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue