diff --git a/src/client/JobLogs.jsx b/src/client/JobLogs.jsx new file mode 100644 index 0000000..f88dbe2 --- /dev/null +++ b/src/client/JobLogs.jsx @@ -0,0 +1,26 @@ +import { useEffect, useState } from "preact/hooks" + +export const JobLogs = ({}) => { + const [logLines, setLogLines] = useState([]) + + useEffect(async () => { + const res = await fetch(location.href + '/logs?format=raw') + const rawLogs = (await res.text()).trim() + + if (rawLogs.length > 0) setLogLines(rawLogs.split('\n')) + + // Setup SSE + const es = new EventSource(location.href + '/logs?format=sse') + es.addEventListener('message', ({ data }) => { + const event = JSON.parse(data) + setLogLines(lines => [ + ...lines, + event.content, + ]) + }) + }, []) + + return ( +
{logLines.join('\n')}
+ )
+}
diff --git a/src/client/JobsPage.jsx b/src/client/JobsPage.jsx
index 059b36a..ec1b0a8 100644
--- a/src/client/JobsPage.jsx
+++ b/src/client/JobsPage.jsx
@@ -6,8 +6,8 @@ import { durationToString } from './lib/utils'
/**
* @param {import('@/jobs.ts').QueuedJob} props
*/
-export const QueuedJob = ({ uuid, name, submitter, submittedAt }) => (
- {message ?? 'Unknown error'}
+ {previous && Back} +{JSON.stringify(job, null, 2)}
+ {logsContent}
+ :