Files
QuestionProject/hy_qa_asset_backend/frontend/app/logs/page.tsx

90 lines
3.7 KiB
TypeScript

"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>
);
}