Refresh the homepage and improve export and draft guidance
This commit is contained in:
33
lib/api.ts
33
lib/api.ts
@@ -294,7 +294,7 @@ export async function handle(request: NextRequest, path: string[]) {
|
||||
.single(),
|
||||
);
|
||||
const endpoint = new URL(
|
||||
"/storage/v1/upload/resumable",
|
||||
"/storage/v1/upload/resumable/sign",
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL,
|
||||
);
|
||||
endpoint.hostname = endpoint.hostname.replace(
|
||||
@@ -315,6 +315,7 @@ export async function handle(request: NextRequest, path: string[]) {
|
||||
path: a.path,
|
||||
objectName,
|
||||
token: signed.token,
|
||||
apiKey: process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY,
|
||||
endpoint: endpoint.toString(),
|
||||
};
|
||||
}),
|
||||
@@ -368,7 +369,9 @@ export async function handle(request: NextRequest, path: string[]) {
|
||||
previews: await Promise.all(
|
||||
manifest.viewpoints.map(async (p: { id: string }) => ({
|
||||
id: p.id,
|
||||
image: await mediaUrl(`${d.id}/${p.id}/preview.webp`),
|
||||
image: d.map_path
|
||||
? await mediaUrl(`${d.id}/${p.id}/preview.webp`)
|
||||
: null,
|
||||
})),
|
||||
),
|
||||
});
|
||||
@@ -441,20 +444,28 @@ export async function handle(request: NextRequest, path: string[]) {
|
||||
return NextResponse.json({ ok: true });
|
||||
}
|
||||
if (method === "POST" && path[2] === "cancel") {
|
||||
if (!["uploading", "processing"].includes(d.state))
|
||||
throw new Error("This dataset is not uploading or processing");
|
||||
const cancelled = await client
|
||||
.from("upload_jobs")
|
||||
.update({ state: "cancelled" })
|
||||
.eq("dataset_id", d.id)
|
||||
.in("state", ["queued", "running"])
|
||||
.select("id")
|
||||
.maybeSingle();
|
||||
if (cancelled.error) throw new Error(cancelled.error.message);
|
||||
required(
|
||||
await client
|
||||
.from("upload_jobs")
|
||||
.update({ state: "cancelled" })
|
||||
.eq("dataset_id", d.id)
|
||||
.in("state", ["queued", "running"])
|
||||
.from("datasets")
|
||||
.update({
|
||||
state: "failed",
|
||||
rejection_reason: "Processing cancelled",
|
||||
})
|
||||
.eq("id", d.id)
|
||||
.in("state", ["uploading", "processing"])
|
||||
.select("id")
|
||||
.single(),
|
||||
);
|
||||
await client
|
||||
.from("datasets")
|
||||
.update({ state: "failed", rejection_reason: "Processing cancelled" })
|
||||
.eq("id", d.id)
|
||||
.in("state", ["uploading", "processing"]);
|
||||
return NextResponse.json({ ok: true });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,8 @@ export async function catalog() {
|
||||
return Promise.all(
|
||||
maps.map(async (m) => ({
|
||||
...m,
|
||||
image: (await mediaUrl(m.cover_path)) ?? undefined,
|
||||
image: (await mediaUrl(m.map_path || m.cover_path)) ?? undefined,
|
||||
mapImage: (await mediaUrl(m.map_path)) ?? undefined,
|
||||
server: servers.find((s) => s.id === m.server_id),
|
||||
})),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user