Expand description
Dashboard widget system for umbral-admin.
Plugins register widgets via AdminPlugin::register_widget. Each widget
has a key, title, kind, default_span, optional permission, and
an async data function. The admin dashboard renders a 12-column grid of
the user’s saved layout (defaulting to all permitted widgets).
§Registration shape
ⓘ
admin.register_widget(Widget {
key: "umbral_total_models",
title: "Total Models".to_string(),
kind: WidgetKind::Kpi,
default_span: Span { cols: 3, rows: 1 },
permission: None,
data: WidgetDataFn::new(|_user| async move {
WidgetPayload::Kpi(KpiPayload {
value: "42".to_string(),
unit: None,
delta: None,
sparkline: None,
})
}),
});§Endpoint contract
GET /admin/api/dashboard/catalog—[{key, title, kind, default_span}]GET /admin/api/dashboard/layout— user’s saved layout or defaultPUT /admin/api/dashboard/layout— save user’s layoutGET /admin/api/dashboard/widgets/{key}/data— typed payload JSON
Structs§
- BarPayload
- Bar chart payload (same shape as Line).
- Card
Payload - Summary card payload. Renders as:
- Catalog
Entry - Serialized catalog entry returned by
GET /admin/api/dashboard/catalog. - Chart
Point - X/Y data point. X is a string for flexible labeling.
- Donut
Payload - Donut chart payload — categorical breakdown summing to 100%.
- Donut
Slice - One slice of a donut chart.
- Feed
Item - One item in an activity feed.
- Feed
Payload - Activity feed payload.
- Heatmap
Cell - One cell in a
HeatmapRow— an x-axis bucket and its magnitude. - Heatmap
Payload - Heatmap payload — a 2-D grid of cells colored by magnitude
(ApexCharts
heatmap). Every row shares the same ordered x-axis. Use for “activity by time” patterns (day-of-week × hour), cohort retention, or per-region load. - Heatmap
Row - One row (series) of a
HeatmapPayload— a label plus its cells across the shared x-axis. - KpiPayload
- KPI card payload.
- Line
Payload - Line chart payload.
- Progress
Item - One row of a
ProgressPayload— a labeled horizontal bar. - Progress
Payload - Progress-bar list payload — a ranked set of labeled horizontal bars, each filled relative to the largest value (or an explicit target). The “top N by metric” tile: revenue by product, traffic by source, completion per category. Rendered as pure HTML — no chart library.
- Radial
Payload - Radial gauge payload — one or more 0–100% tracks rendered as
concentric arcs (ApexCharts
radialBar). Use for “progress toward a goal” metrics: quota attainment, capacity used, completion rate. - Radial
Track - One arc of a
RadialPayloadgauge — a labeled 0–100% value. - Series
- One data series for Line or Bar charts.
- Span
- Grid span in the 12-column dashboard grid.
- Table
Column - Table widget column descriptor.
- Table
Payload - Table widget payload.
- Widget
- A registered dashboard widget.
- Widget
Data Fn - Wrapper around the async data closure. Build via
WidgetDataFn::new(closure ignores per-request params) orWidgetDataFn::with_params(closure readsWidgetParamsto honour period / date-range filters from the request URL). - Widget
Instance - One entry in a user’s saved layout JSON.
- Widget
Params - Per-request parameters a widget’s data closure can read.
Sourced from the query string on
GET /admin/api/dashboard/widgets/<key>/data?<params>. - Widget
Section - A named group of widgets on the dashboard. Each section renders as its own heading + (optional) subtitle + widget grid, so a dashboard with 20 widgets reads as themed clusters rather than one mega-grid.
Enums§
- Widget
Kind - The visual kind of a dashboard widget. Drives how the payload is rendered.
- Widget
Payload - Union of all widget payloads. The JSON discriminant is the variant name.
Functions§
- format_
thousands - Format a number with thousands separators and (when fractional)
two decimal places. Use for values where the full digits matter
(currency totals, audit counts) — for compact display use
humanize_number. - humanize_
number - Humanize a number into a compact display string: