-
-
Notifications
You must be signed in to change notification settings - Fork 385
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
single job page view #598
single job page view #598
Changes from 7 commits
73a4fce
5ac7e9b
9f1fac7
ce7c919
f0012c7
77405c7
8ff4a32
e3c53fe
1c765a0
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { BullBoardRequest, ControllerHandlerReturnType, QueueJob } from '../../typings/app'; | ||
import { queueProvider } from '../providers/queue'; | ||
import { jobProvider } from '../providers/job'; | ||
|
||
async function getJobState( | ||
_req: BullBoardRequest, | ||
job: QueueJob | ||
): Promise<ControllerHandlerReturnType> { | ||
const state = await job.getState(); | ||
|
||
return { | ||
status: 200, | ||
body: { | ||
job, | ||
state, | ||
}, | ||
}; | ||
} | ||
|
||
export const jobHandler = queueProvider(jobProvider(getJobState), { | ||
skipReadOnlyModeCheck: true, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { useParams, useHistory, useLocation } from 'react-router-dom'; | ||
import { AppJob, AppQueue, JobRetryStatus, Status } from '@bull-board/api/typings/app'; | ||
import React, { useState } from 'react'; | ||
import { Store } from '../../hooks/useStore'; | ||
import s from '../QueuePage/QueuePage.module.css'; | ||
import { JobCard } from '../../components/JobCard/JobCard'; | ||
import { ArrowLeftIcon } from '../../components/Icons/ArrowLeft'; | ||
import { Button } from '../../components/JobCard/Button/Button'; | ||
import { useInterval } from '../../hooks/useInterval'; | ||
|
||
export const JobPage = ({ | ||
actions, | ||
queue, | ||
selectedStatus, | ||
}: { | ||
queue: AppQueue | null; | ||
actions: Store['actions']; | ||
selectedStatus: Store['selectedStatuses']; | ||
}) => { | ||
const { search } = useLocation(); | ||
const history = useHistory(); | ||
const { name, jobId } = useParams<any>(); | ||
const [job, setJob] = useState<AppJob>(); | ||
const [status, setStatus] = useState<Status>(selectedStatus[queue?.name || '']); | ||
|
||
useInterval(() => { | ||
fetchJob(); | ||
}, 5000); | ||
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. should use users config of interval time 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.
idk what this means - if you can point me to an example I'm happy to make the change
no - I just let the polling continue because it keeps everything in sync and it's simple. traffic is not a real concern for an app like this imo. You probably wouldn't have 1000s of concurrent users. |
||
|
||
const fetchJob = async () => { | ||
const { job, state } = await actions.getJob(name)(jobId)(); | ||
setJob(job); | ||
setStatus(state); | ||
}; | ||
|
||
if (!queue) { | ||
return <section>Queue Not found</section>; | ||
} | ||
|
||
if (!job) { | ||
return <section>Job Not found</section>; | ||
} | ||
|
||
const cleanJob = async () => { | ||
await actions.cleanJob(queue?.name)(job)(); | ||
history.push(`/queue/${queue.name}`); | ||
}; | ||
|
||
return ( | ||
<section> | ||
<div className={s.stickyHeader}> | ||
<div className={s.actionContainer}> | ||
<Button onClick={() => history.push(`/queue/${queue.name}${search}`)}> | ||
felixmosh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<ArrowLeftIcon /> | ||
</Button> | ||
<div>Status: {status.toLocaleUpperCase()}</div> | ||
</div> | ||
</div> | ||
<JobCard | ||
key={job.id} | ||
job={job} | ||
status={status} | ||
actions={{ | ||
cleanJob, | ||
promoteJob: actions.promoteJob(queue?.name)(job), | ||
retryJob: actions.retryJob(queue?.name, status as JobRetryStatus)(job), | ||
getJobLogs: actions.getJobLogs(queue?.name)(job), | ||
}} | ||
readOnlyMode={queue?.readOnlyMode} | ||
allowRetries={(job.isFailed || queue.allowCompletedRetries) && queue?.allowRetries} | ||
/> | ||
</section> | ||
); | ||
}; |
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.
Apparently this is the full union of states 🤷♂️ - idk if this is going to cause problems, any advice here would be greatly appreciated.
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.
Why do you need to specify all of the statuses (which the board not supports yet, as far as i know, bull doesn't support waiting-children as well)
This interface must be a unify version between bullmq & bull
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.
I'm getting a build error unless I include them all.
https://gist.github.com/jamesgweber/cbf1e8bbf29f169964d37b6adb8c405a
bull board might not support it but
{ Job } from 'bull';
does and it expects that continuityAnother possible option is
getState(): Promise<Status | any>;
🙅