Phoenix.LiveDashboard.PageBuilder behaviour (LiveDashboard v0.2.9) View Source
Link to this section Summary
Callbacks
Callback invoked when a page is declared in the router.
Callback invoked when a page is declared in the router.
Link to this section Types
Link to this section Functions
Specs
Renders a table component.
This component is used in different pages like applications or sockets.
It can be used in a Phoenix.LiveView
in the render/1
function:
def render_page(assigns) do
table(
columns: columns(),
id: @table_id,
row_attrs: &row_attrs/1,
row_fetcher: &fetch_applications/2,
title: "Applications"
)
end
Options
These are the options supported by the component:
:id
- Required. Because is a statefulPhoenix.LiveComponent
an unique id is needed.:columns
- Required. AKeyword
list with the following keys::field
- Required. An identifier for the column.:header
- Label to show in the current column. Default value is calculated from:field
.:header_attrs
- A list with HTML attributes for the column header. More info:Phoenix.HTML.Tag.tag/1
. Default[]
.:format
- Function which receives the row data and returns the cell information. Default is calculated from:field
:row[:field]
.:cell_attrs
- A list with HTML attributes for the table cell. It also can be a function which receives the row data and returns an attribute list. More info:Phoenix.HTML.Tag.tag/1
. Default:[]
.:sortable
- Either:asc
or:desc
with the default sorting. When set, the column header is clickable and it fetches again rows with the new order. At least one column should be sortable. Default:nil
:limit_options
- A list of integers to limit the number of rows to show. Default:[50, 100, 500, 1000, 5000]
:params
- Required. All the params received by the parentPhoenix.LiveView
, so the table can handle its own parameters.:row_fetcher
- Required. A function which receives the params and the node and returns a tuple with the rows and the total number:(params(), node()) -> {list(), integer() | binary()}
:rows_name
- A string to name the representation of the rows. Default is calculated from the current page.:title
- The title of the table. Default is calculated with the current page.
Link to this section Callbacks
Specs
handle_event(event :: binary(), unsigned_params(), socket :: Socket.t()) :: {:noreply, Socket.t()} | {:reply, map(), Socket.t()}
Specs
handle_info(msg :: term(), socket :: Socket.t()) :: {:noreply, Socket.t()}
Specs
handle_params(unsigned_params(), uri :: String.t(), socket :: Socket.t()) :: {:noreply, Socket.t()}
Specs
handle_refresh(socket :: Socket.t()) :: {:noreply, Socket.t()}
Specs
init(term()) :: {:ok, session()} | {:ok, session(), requirements()}
Callback invoked when a page is declared in the router.
It receives the router options and it must return the
tuple {:ok, session, requirements}
.
The page session will be serialized to the client and
received on mount
.
The requirements is an optional keyword to detect the state of the node.
The result of this detection will be passed as second
argument in the menu_link/2
callback.
The possible values are:
:applications
list of applications that are running or not.:modules
list of modules that are loaded or not.:pids
list of processes that alive or not.
Specs
mount(unsigned_params(), session(), socket :: Socket.t()) :: {:ok, Socket.t()} | {:ok, Socket.t(), keyword()}
Specs
render_page(assigns :: Socket.assigns()) :: component()