Lotus.Web.Router (Lotus Web v1.2.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.
  • :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