Skip to content

Build a dashboard with tables and totals

Use a dedicated module with an index layout and resource_table aggregates for business dashboards. This minimal pair defines order data and a dashboard module. Aggregates/summary match SPA types and runtime data flow; the complete example and result shape have not been executed here. Verify the aggregate result and summary recipe in your target version before publishing.

Copy the Bakery definitions into the system directory, inspect php bakery plan <system>, then apply them in a disposable preview with php bakery apply <system>. A client must already exist.

dashboard.bake.json:

[
{
"resource_module": "dashboard_orders",
"resource": {
"identifier": "dashboard_orders",
"title": "name",
"fields": [
{
"identifier": "name",
"type": "text"
},
{
"identifier": "total",
"type": "currency"
}
]
}
},
{
"resource_module": "sales_dashboard",
"resource": {
"identifier": "sales_dashboard",
"title": "name",
"fields": [
{
"identifier": "name",
"type": "text"
}
],
"layouts": {
"index": "/modules/sales_dashboard/sales_dashboard.index"
}
}
}
]

modules/sales_dashboard/sales_dashboard.index.json:

{
"tabs": [
{
"identifier": "general",
"rows": [
{
"cols": [
{
"span": 24,
"components": [
{
"type": "resource_table",
"options": {
"module": "dashboard_orders",
"columns": [
"name",
"total"
],
"aggregates": [
{
"functions": {
"total_sum": {
"function": "sum",
"fields": [
"total"
]
}
}
}
],
"summary": [
{
"total": {
"type": "statistic",
"recipe": "$.aggregates.total_sum"
}
}
]
}
}
]
}
]
}
]
}
]
}

Open /sales_dashboard. The table queries orders under the current actor’s permissions and filters. Its aggregate definition sums total; the summary reads the result through $.aggregates. The aggregate result alias/shape must be checked in the target system. Give users read access to both modules. Add navigation to the existing menu if desired; a record-free dashboard menu entry has not been verified here.

Create orders of 10 and 20, verify records/permissions with workflow assertions, then check the summary displays 30 in the browser. Filter to one order and confirm the aggregate uses the intended scope. Test a restricted non-root actor and an empty result. Workflow assertions do not test dashboard rendering.

  • Not recommended until rendering and data wiring are verified: chart widgets bar, column, line, progress, radar, donut through widget:. The audit found missing dispatch/rendering paths; aggregate-to-chart recipes remain unverified.
  • Recommended for custom server-computed tables after verification: resource_table.workflow with a resource-table response. The full response pattern remains unverified.
  • Recommended for expensive periodic metrics after verification: cron populates a metric module. Decide freshness requirements; the complete pattern remains unverified.
  • Recommended for the platform home page only: the Dashboard capability. Use a business module for business metrics.

Table options · Layouts · Capabilities · Workflow tests · Assertions