-
-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logs in details panel #210
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,10 @@ export class BullMQAdapter implements QueueAdapter { | |
return this.queue.getJob(id) | ||
} | ||
|
||
public getLogs(id: string): Promise<string[]> { | ||
return this.queue.getJobLogs(id).then(({logs}) => logs); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have a lint issue here. pls fix |
||
} | ||
|
||
public getJobs( | ||
jobStatuses: JobStatus[], | ||
start?: number, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Request, RequestHandler, Response } from 'express-serve-static-core' | ||
|
||
import { BullBoardQueues } from '../@types/app' | ||
|
||
export const getLogs: RequestHandler = async (req: Request, res: Response) => { | ||
try { | ||
const { queueName, id } = req.params | ||
const { bullBoardQueues } = req.app.locals as { | ||
bullBoardQueues: BullBoardQueues | ||
} | ||
const { queue } = bullBoardQueues[queueName] | ||
if (!queue) { | ||
return res.status(404).send({ error: 'queue not found' }) | ||
} | ||
|
||
const logs = await queue.getLogs(id) | ||
|
||
return res.send(logs) | ||
} catch (e) { | ||
const body = { | ||
error: 'queue error', | ||
details: e.stack, | ||
} | ||
|
||
return res.status(500).send(body) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React, { useEffect, useState } from 'react' | ||
|
||
const basePath = document.head.querySelector('base')?.getAttribute('href') || '' | ||
|
||
export const Logs = ({ | ||
queueName, | ||
jobId, | ||
}: { | ||
queueName: string | ||
jobId: string | number | undefined | ||
}) => { | ||
const [state, setState] = useState([]) | ||
|
||
useEffect(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Components should not know how to make AJAX requests, it breaks the entire encapsulation. This way you don't need to pass the queue name every where. Pls refactor this 🙏🏼 |
||
fetch( | ||
`${basePath}/api/queues/${encodeURIComponent(queueName)}/${jobId}/logs` | ||
) | ||
.then((res) => res.json()) | ||
.then((logs) => setState(logs)) | ||
}, [jobId]) | ||
|
||
return ( | ||
<ul> | ||
{state.map((line, i) => ( | ||
<li key={i}> | ||
<pre>{line}</pre> | ||
</li> | ||
))} | ||
</ul> | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a lint issue here. pls fix