defmodule Bloccs.Web.Panels.Networks do @moduledoc """ Panel 1 — the overview list of every running network (`Bloccs.Introspect.list_networks/0`), each row linking into its topology and carrying live stats: a throughput sparkline + rate, error count, and uptime. Pure presentation; data (the list plus live `stats`) is loaded by `Bloccs.Web.DashboardLive` and passed in. """ use Bloccs.Web, :html import Bloccs.Web.Components.Chart alias Bloccs.Web.{Format, Paths} attr :networks, :list, required: true attr :base_path, :string, required: true attr :now, :integer, required: true attr :stats, :map, default: %{} def render(assigns) do ~H"""

Networks

{count_label(@networks)}
Network Version Throughput Nodes Edges In-flight Errors Uptime
<.link navigate={Paths.topology(@base_path, n.id)} class="bloccs-link bloccs-net-name"> 0 && "bloccs-dot--live"]} /> {n.id} {n.version} <.sparkline values={series(@stats, n.id)} /> {Format.rate(rate(@stats, n.id))} {n.node_count} {n.edge_count} 0 && "bloccs-num--live"]}> {inflight(@stats, n.id)} 0 && "bloccs-num--error"]}> {errors(@stats, n.id)} {Format.uptime(n.started_at, @now)}

No running networks.

Start a compiled network (e.g. mix bloccs.run) and it appears here. Networks built with bloccs < 0.2 must be recompiled to be discoverable.

""" end defp rate(stats, id), do: get_in(stats, [id, :rate]) || 0 defp errors(stats, id), do: get_in(stats, [id, :errors]) || 0 defp inflight(stats, id), do: get_in(stats, [id, :in_flight]) || 0 defp series(stats, id), do: get_in(stats, [id, :series]) || [] defp count_label([_]), do: "1 running" defp count_label(list), do: "#{length(list)} running" end