Deployment and lifecycle management for Nix
0
fork

Configure Feed

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

server: icon for agent online status

server: fix agent+deployments view, add result component

+92 -10
+44
apps/sower/lib/sower_web/components/sower_components.ex
··· 1 1 defmodule SowerWeb.SowerComponents do 2 2 use Phoenix.Component 3 3 4 + attr :result, :string, required: true 5 + 6 + def result(assigns) do 7 + ~H""" 8 + <svg class="w-5 h-5" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> 9 + <%= cond do %> 10 + <% @result == :success -> %> 11 + <path 12 + d="M5 12l5 5L20 7" 13 + class="fill-none stroke-green-500 stroke-2" 14 + stroke-linecap="round" 15 + stroke-linejoin="round" 16 + /> 17 + <% is_nil(@result) -> %> 18 + <line 19 + x1="6" 20 + y1="12" 21 + x2="18" 22 + y2="12" 23 + class="stroke-gray-400 stroke-2" 24 + stroke-linecap="round" 25 + /> 26 + <% true -> %> 27 + <line 28 + x1="6" 29 + y1="6" 30 + x2="18" 31 + y2="18" 32 + class="stroke-red-500 stroke-2" 33 + stroke-linecap="round" 34 + /> 35 + <line 36 + x1="18" 37 + y1="6" 38 + x2="6" 39 + y2="18" 40 + class="stroke-red-500 stroke-2" 41 + stroke-linecap="round" 42 + /> 43 + <% end %> 44 + </svg> 45 + """ 46 + end 47 + 4 48 attr :id, :string, required: true 5 49 6 50 def uuid(assigns) do
+22 -1
apps/sower/lib/sower_web/live/agent_live/index.html.heex
··· 13 13 rows={@streams.agents} 14 14 row_click={fn {_id, agent} -> JS.navigate(~p"/agents/#{agent}") end} 15 15 > 16 - <:col :let={{_id, agent}} label="Online">{agent.sid in Map.keys(@agent_presence)}</:col> 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> 37 + </:col> 17 38 <:col :let={{_id, agent}} label="Name">{agent.name}</:col> 18 39 <:col :let={{_id, agent}} label="sid">{agent.sid}</:col> 19 40 <:col :let={{_id, agent}} label="Local sid">{agent.local_sid}</:col>
+7
apps/sower/lib/sower_web/live/agent_live/show.ex
··· 4 4 alias Phoenix.Socket.Broadcast 5 5 alias Sower.Orchestration 6 6 alias SowerWeb.Presence 7 + import SowerWeb.SowerComponents 7 8 8 9 @impl true 9 10 def mount(_params, _session, socket) do ··· 19 20 orchestration = 20 21 Orchestration.get_agent_sid!(sid) |> Sower.Repo.preload(subscriptions: [:deployments]) 21 22 23 + deployments = 24 + Enum.reduce(orchestration.subscriptions, [], fn sub, acc -> 25 + acc ++ sub.deployments 26 + end) 27 + 22 28 socket = 23 29 socket 24 30 |> assign(:page_title, page_title(socket.assigns.live_action)) 25 31 |> assign(:agent, orchestration) 32 + |> assign(:deployments, deployments) 26 33 |> add_online_status() 27 34 |> assign(:current_generation, %{}) 28 35
+8 -6
apps/sower/lib/sower_web/live/agent_live/show.html.heex
··· 30 30 </:item> 31 31 <:item title="deployments"> 32 32 <.table 33 - id="subscriptions" 34 - rows={@agent.subscriptions} 35 - row_click={fn subscription -> JS.navigate(~p"/subscriptions/#{subscription.sid}") end} 33 + id="deployments" 34 + rows={@deployments} 35 + row_click={fn deployment -> JS.navigate(~p"/deployments/#{deployment.sid}") end} 36 36 > 37 - <:col :let={subscription}>{subscription.seed_name}</:col> 38 - <:col :let={subscription}>{subscription.seed_type}</:col> 39 - <:col :let={subscription}>{subscription.updated_at}</:col> 37 + <:col :let={deployment} label="Result"> 38 + <.result result={deployment.result} /> 39 + </:col> 40 + <:col :let={deployment}>{deployment.sid}</:col> 41 + <:col :let={deployment}>{deployment.inserted_at}</:col> 40 42 </.table> 41 43 </:item> 42 44 </.list>
+5 -1
apps/sower/lib/sower_web/live/deployment_live/index.ex
··· 4 4 alias Sower.Orchestration 5 5 alias SowerWeb.Layouts 6 6 7 + import SowerWeb.SowerComponents 8 + 7 9 @impl true 8 10 def render(assigns) do 9 11 ~H""" ··· 17 19 rows={@streams.deployments} 18 20 row_click={fn {_id, deployment} -> JS.navigate(~p"/deployments/#{deployment}") end} 19 21 > 22 + <:col :let={{_id, deployment}} label="Result"> 23 + <.result result={deployment.result} /> 24 + </:col> 20 25 <:col :let={{_id, deployment}} label="sid">{deployment.sid}</:col> 21 - <:col :let={{_id, deployment}} label="result">{deployment.result}</:col> 22 26 <:col :let={{_id, deployment}} label="completed">{deployment.deployed_at}</:col> 23 27 <:action :let={{_id, deployment}}> 24 28 <div class="sr-only">
+6 -2
apps/sower/lib/sower_web/live/deployment_live/show.ex
··· 3 3 4 4 alias Sower.Orchestration 5 5 6 + import SowerWeb.SowerComponents 7 + 6 8 @impl true 7 9 def render(assigns) do 8 10 ~H""" 9 11 <Layouts.app flash={@flash} current_user={@current_user}> 10 12 <.header> 11 - Deployment {@deployment.id} 12 - <:subtitle>This is a deployment record from your database.</:subtitle> 13 + <div class="flex items-center space-x-2"> 14 + <.result result={@deployment.result} /> 15 + <span>Deployment {@deployment.sid}</span> 16 + </div> 13 17 <:actions> 14 18 <.link patch={~p"/deployments"}> 15 19 <.button>