Dashboards

Build dashboards for your team in the panel, with charts, tables, statistics and forms fed by your own HTTP functions.

A dashboard is a page in the panel made of components. Each component loads JSON from a URL, usually an HTTP function, and renders it as a chart, a table, a statistic or a form. Dashboards are the quickest way to give business users KPIs and reports without building a separate admin app.

A dashboard with a line chart of daily views and a statistic tile for published posts

Create a dashboard

JSON
{
  "name": "Blog overview",
  "icon": "insights",
  "components": [
    {"name": "Daily views", "url": "https://api.example.com/api/fn-execute/stats/views", "type": "line", "ratio": "2/2"},
    {"name": "Published posts", "url": "https://api.example.com/api/fn-execute/stats/posts", "type": "statistic", "ratio": "1/1"}
  ]
}
FieldDescription
nameRequired. Shown in the panel's dashboard list.
iconA Material icon name.
components[].nameTitle of the component.
components[].urlURL that returns the component's data with a GET request.
components[].typeHow the data is rendered.
components[].ratioSize on the grid, such as 1/1 or 2/2 (default).

Create dashboards in the panel or with POST /dashboard (dashboard:create). Manage them with GET, PUT and DELETE on /dashboard/:id.

Component types and data

Charts

Types: line, bar, radar, pie, doughnut, polarArea, bubble, scatter. The data follows Chart.js:

JavaScript
export function views() {
  return {
    title: "Daily views",
    options: {legend: {display: true}, responsive: true},
    labels: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
    datasets: [{data: [120, 190, 170, 240, 310, 280, 350], label: "Views"}],
    legend: true
  };
}

pie, doughnut and polarArea take labels and a data array instead of datasets. bubble and scatter take points such as {"x": 10, "y": 5, "r": 8} in their datasets.

Statistic

A single number with an optional change indicator:

JavaScript
export function posts() {
  return {title: "Published posts", value: 42, difference: 12, icon: "article", iconBg: "#36369c", iconColor: "white"};
}

difference is shown as a percentage, green when positive and red when negative.

Table

JavaScript
export function topAuthors() {
  return {
    title: "Top authors",
    data: [
      {name: "Ada Lovelace", posts: 12},
      {name: "Alan Turing", posts: 9}
    ],
    displayedColumns: ["name", "posts"]
  };
}

When displayedColumns is left out, the keys of the first row are used.

Card

A small form that sends its values to a URL, useful for operational actions such as "resend invoice":

JSON
{
  "title": "Resend invoice",
  "description": "Send the invoice email of an order again.",
  "inputs": [{"key": "orderId", "type": "string", "value": "", "title": "Order id"}],
  "button": {"color": "primary", "target": "https://api.example.com/api/fn-execute/invoices/resend", "method": "post", "title": "Send"}
}

Securing dashboard endpoints

The panel calls component URLs with the logged-in identity's token. Protect the functions behind them with authenticate: ["IDENTITY"] so that only your team can load the data:

YAML
triggers:
  views:
    type: http
    active: true
    options:
      method: Get
      path: /stats/views
      authenticate: [IDENTITY]

Tips

  • Pre-aggregate expensive numbers on a schedule and store them in a bucket. Dashboard functions then only read the result.
  • Keep one function per dashboard and one handler per component.
  • Give business users DashboardReadOnlyAccess and access only to what the dashboards need.