importer 2
All checks were successful
Deploy / deploy-staging (push) Successful in 6s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-04-11 03:09:09 +02:00
parent 7400caa687
commit 35a0b10d0c
3 changed files with 214 additions and 3 deletions

View File

@@ -549,6 +549,7 @@
const [debugEntries, setDebugEntries] = useState([]);
const [schemaStatus, setSchemaStatus] = useState(normalizeSchemaStatus(null));
const [initForm, setInitForm] = useState({ drop_existing: false });
const [sqlImportFile, setSqlImportFile] = useState(null);
const [dbCheck, setDbCheck] = useState(null);
const [measurementForm, setMeasurementForm] = useState({
measured_at: '',
@@ -1572,6 +1573,38 @@
}
}
async function importSqlFile() {
if (!sqlImportFile) {
setError('Bitte zuerst eine SQL-Datei auswaehlen.');
setMessage('');
return;
}
setSaving(true);
setError('');
setMessage('');
try {
const body = new FormData();
body.append('sql_file', sqlImportFile);
const result = await request(`${apiBase}/projects/${encodeURIComponent(projectKey)}/sql-import`, {
method: 'POST',
body,
timeoutMs: 30000,
});
setSqlImportFile(null);
setMessage(
`${result.message || 'SQL-Datei wurde importiert.'} ` +
`${result.statement_count || 0} Statements aus ${result.file || 'der Datei'} ausgefuehrt.`
);
await loadSchemaStatus(projectKey);
await loadBootstrap(projectKey);
} catch (err) {
setError(err.message);
} finally {
setSaving(false);
}
}
async function testDatabaseConnection() {
setSaving(true);
setError('');
@@ -2866,6 +2899,27 @@
onClick: importOldData,
disabled: saving,
}, saving ? 'Importiert …' : 'Alte Daten importieren'),
h('div', { key: 'sql-import', className: 'mc-form' }, [
h('label', { className: 'mc-field' }, [
h('span', { className: 'mc-field-label' }, 'SQL-Datei importieren'),
h('input', {
type: 'file',
accept: '.sql,text/sql,application/sql',
onChange: (event) => setSqlImportFile(event.target.files && event.target.files[0] ? event.target.files[0] : null),
}),
]),
h('div', { className: 'mc-text' },
sqlImportFile
? `Ausgewaehlt: ${sqlImportFile.name}`
: 'Fuehrt die ausgewaehlte SQL-Datei direkt in der aktuellen Projekt-Datenbank aus. Bestehende Daten werden dabei nicht automatisch geloescht.'
),
h('button', {
type: 'button',
className: 'mc-button mc-button--secondary',
onClick: importSqlFile,
disabled: saving || !sqlImportFile,
}, saving ? 'Importiert …' : 'SQL-Datei einspielen'),
]),
]),
panel('Datenbank-Test', 'Prueft, ob das Modul die Projekt-Datenbank erreichen und eine einfache Anfrage ausfuehren kann.', [
dbCheck