Lotus.Web.Router (Lotus Web v1.4.0)

Copy Markdown View Source

Mounts the dashboard in a host router.

Import the module and call lotus_dashboard/2 inside a scope:

import Lotus.Web.Router

scope "/" do
  pipe_through [:browser, :require_authenticated_user]

  lotus_dashboard "/lotus"
end

The macro defines the live sessions, the routes of the dashboard pages, the public dashboard route, the CSV export route, and the asset routes. See lotus_dashboard/2 for the options.

Summary

Functions

Defines an lotus dashboard route.

Functions

lotus_dashboard(path, opts \\ [])

(macro)

Defines an lotus dashboard route.

It requires a path where to mount the dashboard at and allows options to customize routing.

Options

  • :as — override the route name; otherwise defaults to :lotus_dashboard

  • :on_mount — declares additional module callbacks to be invoked when the dashboard mounts

  • :socket_path — a phoenix socket path for live communication, defaults to "/live".

  • :transport — a phoenix socket transport, either "websocket" or "longpoll", defaults to "websocket".

  • :resolver — a module implementing the Lotus.Web.Resolver behaviour for custom authentication and access control. The module must exist: a resolver that cannot be loaded fails the compile, because Lotus would otherwise fall back to its permissive defaults and give every visitor full access.

  • :features — a list of optional feature flags to enable. Defaults to []. Supported features:

    • :timeout_options — shows a per-query timeout selector in the query editor toolbar.
  • :theme — the look of the dashboard: :lotus (the default) or :sumi, the design system of Hattori AI. A person can pick the other theme in the appearance menu; their choice is kept in their browser. See the Theming guide.

  • :themes — the themes people can pick in the appearance menu. Defaults to [:lotus, :sumi]. With one theme, the menu offers no theme choice. When :theme is not given, the dashboard uses the first of these.

  • :theme_colors — a map of colours that override the theme, from a token name to a hex colour, for example %{"pink-600" => "#0ea5e9"}. See the Theming guide for the tokens.

  • :card_concurrency — the maximum number of query cards a dashboard runs at the same time, per page load, in the dashboard view and the public view. The other cards wait in a queue and start as results arrive. A positive integer, defaults to 4.

Examples

Mount a lotus dashboard at the path "/lotus":

defmodule MyAppWeb.Router do
  use Phoenix.Router

  import Lotus.Web.Router

  scope "/", MyAppWeb do
    pipe_through [:browser]

    lotus_dashboard "/lotus"
  end
end