Initial MVP for QA asset backend

This commit is contained in:
2026-07-05 17:44:15 +08:00
commit 95b5e09fd4
71 changed files with 6546 additions and 0 deletions

View File

@@ -0,0 +1,89 @@
"use client";
import { useEffect, useState } from "react";
import { api, formatDateTime } from "@/lib/api";
import type { AuditLog, TaskRun } from "@/lib/types";
import StatusBadge from "@/components/StatusBadge";
export default function LogsPage() {
const [tasks, setTasks] = useState<TaskRun[]>([]);
const [audit, setAudit] = useState<AuditLog[]>([]);
useEffect(() => {
Promise.all([api.get<TaskRun[]>("/logs/tasks"), api.get<AuditLog[]>("/logs/audit")]).then(([taskRows, auditRows]) => {
setTasks(taskRows);
setAudit(auditRows);
});
}, []);
return (
<div className="space-y-6">
<h1 className="text-2xl font-semibold text-ink"></h1>
<div className="table-wrap rounded-md border border-line bg-white">
<table className="min-w-[980px] w-full border-collapse text-left text-sm">
<thead className="bg-panel text-xs uppercase text-slate-500">
<tr>
<th className="px-4 py-3"> ID</th>
<th className="px-4 py-3"></th>
<th className="px-4 py-3"></th>
<th className="px-4 py-3"></th>
<th className="px-4 py-3"></th>
<th className="px-4 py-3"></th>
<th className="px-4 py-3"></th>
<th className="px-4 py-3"></th>
<th className="px-4 py-3"></th>
</tr>
</thead>
<tbody>
{tasks.map((task) => (
<tr key={task.id} className="border-t border-line">
<td className="px-4 py-3">{task.id}</td>
<td className="px-4 py-3">{formatDateTime(task.started_at)}</td>
<td className="px-4 py-3">{formatDateTime(task.ended_at)}</td>
<td className="px-4 py-3">
<StatusBadge status={task.task_status} />
</td>
<td className="px-4 py-3">{task.sessions_processed}/{task.sessions_scanned}</td>
<td className="px-4 py-3">{task.qa_created}</td>
<td className="px-4 py-3">{task.qa_failed}</td>
<td className="px-4 py-3 text-rose-700">{task.error_message ?? "-"}</td>
<td className="px-4 py-3">{task.retry_count}</td>
</tr>
))}
</tbody>
</table>
</div>
<div className="table-wrap rounded-md border border-line bg-white">
<table className="min-w-[900px] w-full border-collapse text-left text-sm">
<thead className="bg-panel text-xs uppercase text-slate-500">
<tr>
<th className="px-4 py-3"> ID</th>
<th className="px-4 py-3"></th>
<th className="px-4 py-3"></th>
<th className="px-4 py-3"></th>
<th className="px-4 py-3"></th>
<th className="px-4 py-3"></th>
<th className="px-4 py-3"></th>
</tr>
</thead>
<tbody>
{audit.map((log) => (
<tr key={log.id} className="border-t border-line">
<td className="px-4 py-3">{log.id}</td>
<td className="px-4 py-3">{log.target_type} #{log.target_id}</td>
<td className="px-4 py-3">{log.action}</td>
<td className="px-4 py-3">{log.before_status ?? "-"}</td>
<td className="px-4 py-3">{log.after_status ?? "-"}</td>
<td className="px-4 py-3">{log.comment ?? "-"}</td>
<td className="px-4 py-3">{formatDateTime(log.created_at)}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
);
}