Enhance job logging and UI updates

- Implement job logging functionality to track progress and events for each job.
- Add a new section in the job card to display session logs with detailed entries.
- Update job statistics to include pages fetched, pages found, and assets processed.
- Modify the UI theme and text for better clarity and aesthetics.
- Adjust tests to validate new logging features and ensure proper event handling.
This commit is contained in:
kstyagi23
2026-09-05 07:36:34 +05:30
parent 8f9210d6be
commit 2059c275c2
10 changed files with 762 additions and 593 deletions
+7 -2
View File
@@ -59,7 +59,8 @@ async def secure_headers(_: Request, call_next: Any) -> Response:
response.headers.setdefault(
"Content-Security-Policy",
"default-src 'self'; base-uri 'none'; object-src 'none'; frame-ancestors 'none'; "
"form-action 'self'; connect-src 'self'; img-src 'self' data:; style-src 'self'; "
"form-action 'self'; connect-src 'self'; img-src 'self' data:; "
"style-src 'self' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; "
"script-src 'self'",
)
return response
@@ -224,8 +225,12 @@ async def _event_stream(request: Request, job_id: str, after_id: int) -> AsyncIt
events = await asyncio.to_thread(database.get_events, job_id, last_id)
for event in events:
last_id = int(event["id"])
payload = json.dumps(event["payload"], separators=(",", ":"))
payload = json.dumps(
{**event["payload"], "logged_at": event["created_at"]}, separators=(",", ":")
)
yield f"id: {last_id}\nevent: {event['kind']}\ndata: {payload}\n\n"
if events:
continue
job = await asyncio.to_thread(database.get_job, job_id)
if not job or job["state"] in terminal_states: