diff --git a/src/App.tsx b/src/App.tsx index 2bb9b3c1..c10cc224 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3693,6 +3693,7 @@ export default function App() { fileName={importState.fileName} isDwg={importState.isDwg} loading={importState.loading ?? false} + progress={importState.progress} parsed={importState.parsed} project={project} activeCategoryCode={activeCategoryCode} diff --git a/src/i18n/de.ts b/src/i18n/de.ts index 65cb529a..a52d78cc 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -1582,6 +1582,12 @@ export const de = { "import.loading.heading": "DXF-Datei", "import.loading.hint": "DXF wird gelesen … Bei sehr grossen Dateien (z. B. ein Kataster-Import einer ganzen Stadt) kann das einen Moment dauern.", + "import.loading.phase.structure": "Analysiere Dateistruktur …", + "import.loading.phase.parseSingle": "Parse Geometrie …", + "import.loading.phase.parseParallel": "Parse Geometrie (über {n} Kerne verteilt) …", + "import.applying.heading": "Importiere ins Projekt", + "import.applying.hint": + "Geometrie wird ins Projekt eingehängt und Grundriss/3D neu aufgebaut … Bei sehr vielen Elementen kann das einen Moment dauern.", "import.confirm": "Importieren", "import.cancel": "Abbrechen", "import.badge.floor": "Geschoss", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 87e9f338..5dc75bf6 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -1570,6 +1570,12 @@ export const en: Record = { "import.loading.heading": "DXF file", "import.loading.hint": "Reading DXF … this can take a moment for very large files (e.g. a cadastral import of an entire city).", + "import.loading.phase.structure": "Analyzing file structure …", + "import.loading.phase.parseSingle": "Parsing geometry …", + "import.loading.phase.parseParallel": "Parsing geometry (spread across {n} cores) …", + "import.applying.heading": "Importing into project", + "import.applying.hint": + "Attaching geometry to the project and rebuilding plan/3D … this can take a moment for very many elements.", "import.confirm": "Import", "import.cancel": "Cancel", "import.badge.floor": "Floor", diff --git a/src/state/useDialogState.ts b/src/state/useDialogState.ts index 8b73fa93..16eece78 100644 --- a/src/state/useDialogState.ts +++ b/src/state/useDialogState.ts @@ -40,6 +40,8 @@ export function useDialogState() { parsed: DxfImportResult | null; // true, solange DWG noch geparst wird (WASM lädt/läuft). loading?: boolean; + // Grober Phasenname während `loading` (nur DXF), s. ImportDialog.tsx. + progress?: string; } | null>(null); // Modaler PDF-Export-Dialog (Grundriss → Vektor-PDF). true = offen. const [exportOpen, setExportOpen] = useState(false); diff --git a/src/state/useProjectFileActions.ts b/src/state/useProjectFileActions.ts index 65e35ff3..527037b7 100644 --- a/src/state/useProjectFileActions.ts +++ b/src/state/useProjectFileActions.ts @@ -113,6 +113,9 @@ export type ImportDialogState = { isDwg: boolean; parsed: DxfImportResult | null; loading?: boolean; + /** Grober Phasenname während `loading` (DXF via `parseDxfAsync`'s + * `onProgress`) — rein informativ, s. `ImportDialog.tsx`. */ + progress?: string; } | null; export function useProjectFileActions( @@ -234,7 +237,9 @@ export function useProjectFileActions( setImportState({ fileName: file.name, isDwg: false, parsed: null, loading: true }); const r = new FileReader(); r.onload = () => { - parseDxfAsync(String(r.result ?? "")) + parseDxfAsync(String(r.result ?? ""), (progress) => { + setImportState({ fileName: file.name, isDwg: false, parsed: null, loading: true, progress }); + }) .then((parsed) => { setImportState({ fileName: file.name, isDwg: false, parsed, loading: false }); }) diff --git a/src/ui/ImportDialog.tsx b/src/ui/ImportDialog.tsx index ad6bad94..4a858647 100644 --- a/src/ui/ImportDialog.tsx +++ b/src/ui/ImportDialog.tsx @@ -47,6 +47,22 @@ export interface ImportDecision { parsed: DxfImportResult; } +/** + * Übersetzt den groben Phasencode aus `parseDxfAsync`'s `onProgress` + * (`"structure"` | `"parse-single"` | `"parse-parallel:"`) in einen + * sichtbaren Status-Text. `null` = noch keine Phase bekannt (ganz am Anfang, + * bevor der erste Fortschritts-Callback feuert) — der Aufrufer zeigt dann + * den generischen `import.loading.hint`. + */ +function dxfProgressText(progress: string | undefined): string | null { + if (!progress) return null; + if (progress === "structure") return t("import.loading.phase.structure"); + if (progress === "parse-single") return t("import.loading.phase.parseSingle"); + const m = /^parse-parallel:(\d+)$/.exec(progress); + if (m) return t("import.loading.phase.parseParallel", { n: m[1] }); + return null; +} + /** i18n-Badge-Key je Zeichnungsebenen-Art. */ function kindBadgeKey(kind: DrawingLevelKind): TranslationKey { switch (kind) { @@ -86,6 +102,10 @@ export interface ImportDialogProps { isDwg: boolean; /** true, solange eine DWG-Datei noch geparst wird (WASM lädt/läuft). */ loading?: boolean; + /** Grober Phasenname während `loading` (nur DXF, s. `dxfParserAsync.ts`'s + * `onProgress`) — `"structure"`, `"parse-single"` oder + * `"parse-parallel:"`; `undefined` = noch keine Phase bekannt/DWG. */ + progress?: string; /** Geparstes Ergebnis (null während Laden / bei DWG-Parse-Fehler). */ parsed: DxfImportResult | null; project: Project; @@ -98,6 +118,7 @@ export function ImportDialog({ fileName, isDwg, loading = false, + progress, parsed, project, activeCategoryCode, @@ -135,9 +156,18 @@ export function ImportDialog({ ); const [importMeshes, setImportMeshes] = useState(true); const [placement, setPlacement] = useState<"origin" | "viewCenter">("origin"); + // Zwischen Klick auf „Importieren" und dem (synchronen, u. U. mehrere + // Sekunden dauernden — Drawings ins Projekt einhängen + Plan/3D neu bauen) + // `onImport`: zeigt einen Ladehinweis, STATT sofort zu blockieren (Nutzer- + // Report 2026-10-09: nach Klick auf „Importieren" keine Rückmeldung, nicht + // unterscheidbar von einem Hänger). `setTimeout` statt direktem Aufruf gibt + // dem Browser einen Frame, um diesen Zustand VOR dem schweren synchronen + // Teil zu malen — sonst würde React den State-Update-Commit gar nicht mehr + // vor dem Block zum Zug kommen lassen. + const [applying, setApplying] = useState(false); const canImport = - !isDwg && !loading && (hasDrawings || (hasMeshes && importMeshes)); + !isDwg && !loading && !applying && (hasDrawings || (hasMeshes && importMeshes)); const onConfirm = () => { if (!parsed || !canImport) return; @@ -145,7 +175,8 @@ export function ImportDialog({ targetKind === "existing" ? ({ kind: "existing", levelId: existingLevelId } as const) : ({ kind: "new", name: newName } as const); - onImport({ target, categoryMode, importMeshes, placement, parsed }); + setApplying(true); + setTimeout(() => onImport({ target, categoryMode, importMeshes, placement, parsed }), 0); }; return ( @@ -177,15 +208,29 @@ export function ImportDialog({ - {loading ? ( + {applying ? ( + // Klick auf „Importieren" ist erfolgt, `onImport` (synchron, + // Drawings einhängen + Plan/3D neu bauen) läuft gleich — derselbe + // Ladehinweis wie beim Parsen, damit dieser Schritt nicht wie ein + // Hänger aussieht (s. Kommentar bei `applying` oben). +
+
{t("import.applying.heading")}
+
{t("import.applying.hint")}
+
+ ) : loading ? ( // Datei wird gelesen/geparst (DWG: WASM; DXF: Web Worker, s. - // dxfParserAsync.ts) → Ladehinweis, nur Abbrechen. + // dxfParserAsync.ts) → Ladehinweis, nur Abbrechen. `progress` + // (nur DXF) macht die Phase sichtbar (Nutzer-Report 2026-10-09: + // "keine Rückmeldung, kein Status" — ohne das sieht ein mehrere + // Sekunden dauernder Import wie ein Hänger aus).
{t(isDwg ? "import.dwg.heading" : "import.loading.heading")}
- {t(isDwg ? "import.dwg.loading" : "import.loading.hint")} + {isDwg + ? t("import.dwg.loading") + : dxfProgressText(progress) ?? t("import.loading.hint")}
) : isDwg ? ( @@ -358,7 +403,7 @@ export function ImportDialog({