backoffice nextJs replaces admin in rust
This commit is contained in:
41
apps/backoffice/app/jobs/page.tsx
Normal file
41
apps/backoffice/app/jobs/page.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
import { listJobs } from "../../lib/api";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function JobsPage() {
|
||||
const jobs = await listJobs().catch(() => []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>Index Jobs</h1>
|
||||
<div className="card">
|
||||
<form action="/jobs/rebuild" method="post">
|
||||
<input name="library_id" placeholder="optional library UUID" />
|
||||
<button type="submit">Queue Rebuild</button>
|
||||
</form>
|
||||
</div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Type</th>
|
||||
<th>Status</th>
|
||||
<th>Created</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{jobs.map((job) => (
|
||||
<tr key={job.id}>
|
||||
<td>
|
||||
<code>{job.id}</code>
|
||||
</td>
|
||||
<td>{job.type}</td>
|
||||
<td>{job.status}</td>
|
||||
<td>{job.created_at}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</>
|
||||
);
|
||||
}
|
||||
17
apps/backoffice/app/jobs/rebuild/route.ts
Normal file
17
apps/backoffice/app/jobs/rebuild/route.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { NextResponse } from "next/server";
|
||||
import { apiFetch } from "../../../lib/api";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
const form = await req.formData();
|
||||
const libraryId = String(form.get("library_id") || "").trim();
|
||||
const body = libraryId ? { library_id: libraryId } : {};
|
||||
|
||||
await apiFetch("/index/rebuild", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(body)
|
||||
}).catch(() => null);
|
||||
|
||||
revalidatePath("/jobs");
|
||||
return NextResponse.redirect(new URL("/jobs", req.url));
|
||||
}
|
||||
Reference in New Issue
Block a user