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-monitorThe 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
| Prop | Type | Default | Description |
|---|---|---|---|
| actions | boolean | — | Show Retry and Cancel where the job allows them and the user has `edit` access. Default true. |
| attemptsSource | SourceProp<TRecord> | — | The field holding the attempt count. Default `"attempts"`. |
| cancelFrom | readonly string[] | — | Statuses a job can be cancelled from. Default `["running", "queued"]`. |
| cancelValue | string | — | Status Cancel writes. Default `"cancelled"`. |
| className | string | — | |
| createdAtSource | SourceProp<TRecord> | — | The field holding the creation time. Default `"createdAt"`. |
| errorSource | SourceProp<TRecord> | — | The field holding the last error. Default `"lastError"`. |
| payloadSource | SourceProp<TRecord> | — | The field holding the payload. Default `"payload"`. |
| perPage | number | — | Jobs read per poll. Default 200. |
| pollInterval | number | — | Milliseconds between reads. Default 5000, `0` turns polling off. |
| resource | string | — | The jobs resource. Defaults to the resource context; with neither, nothing renders. |
| retryFrom | readonly string[] | — | Statuses a job can be retried from. Default `["failed"]`. |
| retryValue | string | — | Status Retry writes. Default `"queued"`. |
| sort | SortPayload | — | Default `createdAtSource` descending. |
| statusSource | SourceKey<TRecord> | — | Record field holding the job status, a top-level key. Default `"status"`. |
| tabs | readonly string[] | — | The statuses to show, one tab each and in this order. A job whose status has no tab is not shown. |
| title | string | — | Default `translate("chelone.job_monitor.title")`, "Jobs". |
| typeSource | SourceProp<TRecord> | — | The field shown as the job's type. Default `"type"`. |