JobMonitor

The jobs of a resource in one tab per status, with a count on each tab. The monitor reads its resource itself, from its resource prop or the context, and polls it every pollInterval ms, 5000 by default and 0 for no polling. It groups one page of up to perPage jobs, 200 by default, and a job whose status has no tab is not shown. Retry and Cancel write the status through a pessimistic update, need edit access on the resource, and are hidden with actions set to false. The rules are in the UI only, so the server has to refuse a retry of a job that is not failed.

Installation

pnpm dlx shadcn@latest add @chelone/job-monitor
Loading preview…

The jobs of a resource in one tab per status, with a count on each tab. The monitor reads its resource itself, from its resource prop or the context, and polls it every pollInterval ms, 5000 by default and 0 for no polling. It groups one page of up to perPage jobs, 200 by default, and a job whose status has no tab is not shown. Retry and Cancel write the status through a pessimistic update, need edit access on the resource, and are hidden with actions set to false. The rules are in the UI only, so the server has to refuse a retry of a job that is not failed.

Props

PropTypeDefaultDescription
actionsboolean—Show Retry and Cancel where the job allows them and the user has `edit` access. Default true.
attemptsSourceSourceProp<TRecord>—The field holding the attempt count. Default `"attempts"`.
cancelFromreadonly string[]—Statuses a job can be cancelled from. Default `["running", "queued"]`.
cancelValuestring—Status Cancel writes. Default `"cancelled"`.
classNamestring—
createdAtSourceSourceProp<TRecord>—The field holding the creation time. Default `"createdAt"`.
errorSourceSourceProp<TRecord>—The field holding the last error. Default `"lastError"`.
payloadSourceSourceProp<TRecord>—The field holding the payload. Default `"payload"`.
perPagenumber—Jobs read per poll. Default 200.
pollIntervalnumber—Milliseconds between reads. Default 5000, `0` turns polling off.
resourcestring—The jobs resource. Defaults to the resource context; with neither, nothing renders.
retryFromreadonly string[]—Statuses a job can be retried from. Default `["failed"]`.
retryValuestring—Status Retry writes. Default `"queued"`.
sortSortPayload—Default `createdAtSource` descending.
statusSourceSourceKey<TRecord>—Record field holding the job status, a top-level key. Default `"status"`.
tabsreadonly string[]—The statuses to show, one tab each and in this order. A job whose status has no tab is not shown.
titlestring—Default `translate("chelone.job_monitor.title")`, "Jobs".
typeSourceSourceProp<TRecord>—The field shown as the job's type. Default `"type"`.