Deployment and lifecycle management for Nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

server: add online component to agent show

+35 -22
+27
apps/sower/lib/sower_web/components/sower_components.ex
··· 1 1 defmodule SowerWeb.SowerComponents do 2 2 use Phoenix.Component 3 3 4 + attr :state, :boolean, required: true 5 + 6 + def online(assigns) do 7 + ~H""" 8 + <svg class="w-4 h-4" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> 9 + <circle 10 + cx="12" 11 + cy="12" 12 + r="10" 13 + class={ 14 + if @state, 15 + do: "fill-green-500", 16 + else: "fill-none stroke-gray-300 stroke-2" 17 + } 18 + /> 19 + <line 20 + :if={not @state} 21 + x1="4" 22 + y1="20" 23 + x2="20" 24 + y2="4" 25 + class="stroke-gray-300 stroke-2" 26 + /> 27 + </svg> 28 + """ 29 + end 30 + 4 31 attr :result, :string, required: true 5 32 6 33 def result(assigns) do
+2
apps/sower/lib/sower_web/live/agent_live/index.ex
··· 6 6 alias Sower.Orchestration.Agent 7 7 alias SowerWeb.Presence 8 8 9 + import SowerWeb.SowerComponents 10 + 9 11 @impl true 10 12 def mount(_params, _session, socket) do 11 13 if connected?(socket) do
+1 -20
apps/sower/lib/sower_web/live/agent_live/index.html.heex
··· 14 14 row_click={fn {_id, agent} -> JS.navigate(~p"/agents/#{agent}") end} 15 15 > 16 16 <:col :let={{_id, agent}} label="Online"> 17 - <svg class="w-4 h-4" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> 18 - <circle 19 - cx="12" 20 - cy="12" 21 - r="10" 22 - class={ 23 - if agent.sid in Map.keys(@agent_presence), 24 - do: "fill-green-500", 25 - else: "fill-none stroke-gray-300 stroke-2" 26 - } 27 - /> 28 - <line 29 - :if={agent.sid not in Map.keys(@agent_presence)} 30 - x1="4" 31 - y1="20" 32 - x2="20" 33 - y2="4" 34 - class="stroke-gray-300 stroke-2" 35 - /> 36 - </svg> 17 + <.online state={agent.sid in Map.keys(@agent_presence)} /> 37 18 </:col> 38 19 <:col :let={{_id, agent}} label="Name">{agent.name}</:col> 39 20 <:col :let={{_id, agent}} label="sid">{agent.sid}</:col>
+5 -2
apps/sower/lib/sower_web/live/agent_live/show.html.heex
··· 1 1 <Layouts.app flash={@flash} current_user={@current_user}> 2 2 <.header> 3 - Agent: {@agent.name} 3 + <div class="flex items-center space-x-2"> 4 + <.online state={@online} /> 5 + <span>Agent: {@agent.name}</span> 6 + </div> 7 + 4 8 <:actions> 5 9 <.link patch={~p"/agents/#{@agent}/show/edit"} phx-click={JS.push_focus()}> 6 10 <.button>Edit agent</.button> ··· 9 13 </.header> 10 14 11 15 <.list> 12 - <:item title="Online">{@online}</:item> 13 16 <:item title="sid">{@agent.sid}</:item> 14 17 <:item title="Local sid">{@agent.local_sid}</:item> 15 18 <:item title="Current Generation">