Report renderer progress and detect stalled jobs
This commit is contained in:
@@ -3,6 +3,8 @@ import { useEffect, useState } from "react";
|
||||
import Image from "next/image";
|
||||
import { api } from "./StartGame";
|
||||
import type { DatasetManifest } from "@/shared/protocol";
|
||||
import type { ProcessingJob } from "@/shared/processing-progress";
|
||||
import { ProcessingProgress } from "./ProcessingProgress";
|
||||
type Draft = {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -13,6 +15,7 @@ type Draft = {
|
||||
map: string | null;
|
||||
manifest: DatasetManifest;
|
||||
previews: { id: string; image: string | null }[];
|
||||
upload_jobs: ProcessingJob | null;
|
||||
};
|
||||
export function DraftEditor({ id }: { id: string }) {
|
||||
const [draft, setDraft] = useState<Draft | null>(null),
|
||||
@@ -29,6 +32,7 @@ export function DraftEditor({ id }: { id: string }) {
|
||||
api<Draft>("datasets/" + id)
|
||||
.then((d) => {
|
||||
if (disposed) return;
|
||||
setError("");
|
||||
setDraft(d);
|
||||
setName(d.name);
|
||||
setDescription(d.description);
|
||||
@@ -37,7 +41,10 @@ export function DraftEditor({ id }: { id: string }) {
|
||||
timer = setTimeout(load, 5000);
|
||||
})
|
||||
.catch((e) => {
|
||||
if (!disposed) setError(e.message);
|
||||
if (!disposed) {
|
||||
setError(e.message);
|
||||
timer = setTimeout(load, 5000);
|
||||
}
|
||||
});
|
||||
load();
|
||||
return () => {
|
||||
@@ -89,6 +96,7 @@ export function DraftEditor({ id }: { id: string }) {
|
||||
return (
|
||||
<>
|
||||
<span className="badge">{draft.state}</span>
|
||||
<ProcessingProgress job={draft.upload_jobs} />
|
||||
{["uploading", "processing"].includes(draft.state) && (
|
||||
<p role="status" className="success-message">
|
||||
{draft.state === "uploading"
|
||||
|
||||
Reference in New Issue
Block a user