Skip to main content

Module ui

Module ui 

Source
Available on crate feature ui only.
Expand description

A Navree UI part for an operation (the ui feature): OperationProgress, a region that follows a queued operation and ends as a link to its result.

An export or an import page starts an operation, then has nothing to show but “working”. The region polls the operation’s page fragment (and, with the live hub, hears it change), draws a progress bar and the operation’s note, and when the operation finishes stops polling and shows the result: a link when the result holds a url, the error when it failed.

ⓘ
let op = operations.start(&uow, Operation::new("deals.export").owner(user)).await?;
operations.dispatch(&uow, &op, ExportDeals { operation: op.id }).await?;
// On the page:
OperationProgress::new(op.id).live()
// In the job, when it is done:
operations.complete(op.id, json!({ "url": "/exports/deals.csv" })).await?;

QueueModule mounts the fragment at GET /operations/{id}/progress (the same sign-in and visibility rules as the JSON route: the owner and holders of operations.view, a 404 for everyone else) when the app has DatabaseModule and an authenticator. It draws the English words; to draw other words, mount a route of your own that answers with OperationProgress::new(id).labels(words).record(record).

Structs§

OperationLabels
The words of an OperationProgress. English by default. {done} and {total} are filled in.
OperationProgress
A region that follows an operation. See the module for how a page uses it.
OperationProgressController
The fragment of an operation: GET /operations/{id}/progress, mounted by QueueModule.

Constants§

PROGRESS_PATH
Where QueueModule serves the fragment of an operation, with the id in place of {id}.