+ {progressT( + item.state === "running" ? "current" : "last", + { phase: progressT(item.phase) }, + )} + {item.state === "running" && + item.phaseStartedAt && + ` · ${progressT("elapsed", { seconds: Math.max(0, Math.floor((Date.now() - Date.parse(item.phaseStartedAt)) / 1000)) })}`} + {item.sourceAttempt && ` · ${item.sourceAttempt}`} +
+ )} + {item.recoveredSource && ( ++ {progressT("recovered", { + source: item.recoveredSource.sourceName, + revision: item.recoveredSource.revision, + })} +
+ )} {item.error && ({item.error} diff --git a/src/components/admin/studio/import-review.tsx b/src/components/admin/studio/import-review.tsx index c1361636..385f1997 100644 --- a/src/components/admin/studio/import-review.tsx +++ b/src/components/admin/studio/import-review.tsx @@ -66,6 +66,7 @@ export function ImportReview({ setUploading(null); } } + const progressT = useTranslations("pages.admin.importProgress"); const inspection = useFurnitureInspection( items.map((item) => item.classname), ); @@ -166,8 +167,7 @@ export function ImportReview({ Source files not found by preliminary check: {check.classname}
- You can continue. The importer will try the original furniture - files and verify them before creating its SQL entry. + {progressT("recoveryHint")}
))} diff --git a/src/lib/furni/import-job.ts b/src/lib/furni/import-job.ts index 1494bab3..8b5c2414 100644 --- a/src/lib/furni/import-job.ts +++ b/src/lib/furni/import-job.ts @@ -1,4 +1,14 @@ import type { SourceFurni } from "@/lib/services/clone-import"; +export const IMPORT_PHASES = [ + "validating", + "downloading", + "converting", + "checking_sources", + "writing_db", + "writing_furnidata", + "translating", +] as const; +export type ImportPhase = (typeof IMPORT_PHASES)[number]; export interface ImportJobItem { id: number; classname: string; @@ -34,6 +44,14 @@ export interface ImportJob { | "failed" | "cancelled" | "interrupted"; + phase?: ImportPhase; + phaseStartedAt?: string; + sourceAttempt?: string; + recoveredSource?: { + sourceId: string; + sourceName: string; + revision: number; + }; error?: string; warnings?: string[]; itemId?: number; diff --git a/src/lib/services/clone-import.ts b/src/lib/services/clone-import.ts index 4f8ba421..e163b533 100644 --- a/src/lib/services/clone-import.ts +++ b/src/lib/services/clone-import.ts @@ -247,7 +247,7 @@ export function __resetItemsBaseAllocatorForTests(): void { export async function cloneSingleFurni(params: { source: CloneSource; entry: SourceFurni; - onProgress?: (status: string) => void; + onProgress?: (status: string) => void | Promise