diff --git a/lib/towerops_web/live/agent_live/index.ex b/lib/towerops_web/live/agent_live/index.ex index e4067f52..e30d9ed0 100644 --- a/lib/towerops_web/live/agent_live/index.ex +++ b/lib/towerops_web/live/agent_live/index.ex @@ -10,10 +10,12 @@ defmodule ToweropsWeb.AgentLive.Index do organization = socket.assigns.current_organization agent_tokens = Agents.list_organization_agent_tokens(organization.id) - # Get equipment counts for each agent (directly assigned) + # Get equipment counts for each agent (both direct and total with inheritance) equipment_counts = Map.new(agent_tokens, fn token -> - {token.id, Agents.count_assigned_equipment(token.id)} + direct = Agents.count_assigned_equipment(token.id) + total = length(Agents.list_agent_polling_targets(token.id)) + {token.id, %{direct: direct, total: total}} end) # Get organization-wide agent health statistics @@ -60,7 +62,9 @@ defmodule ToweropsWeb.AgentLive.Index do # Refresh equipment counts equipment_counts = Map.new(agent_tokens, fn t -> - {t.id, Agents.count_assigned_equipment(t.id)} + direct = Agents.count_assigned_equipment(t.id) + total = length(Agents.list_agent_polling_targets(t.id)) + {t.id, %{direct: direct, total: total}} end) # Refresh health statistics @@ -183,6 +187,15 @@ defmodule ToweropsWeb.AgentLive.Index do end end + defp status_dot_class(status) do + case status do + :online -> "bg-green-600 dark:bg-green-400 animate-pulse" + :warning -> "bg-yellow-600 dark:bg-yellow-400" + :offline -> "bg-red-600 dark:bg-red-400" + :never -> "bg-zinc-400 dark:bg-zinc-600" + end + end + defp format_last_seen(nil), do: "Never" defp format_last_seen(datetime) do diff --git a/lib/towerops_web/live/agent_live/index.html.heex b/lib/towerops_web/live/agent_live/index.html.heex index 10425514..1199dee9 100644 --- a/lib/towerops_web/live/agent_live/index.html.heex +++ b/lib/towerops_web/live/agent_live/index.html.heex @@ -63,7 +63,12 @@
Status
+ <% {status, label} = agent_status(@agent_token) %> +Equipment
++ {length(@polling_targets)} +
++ {@direct_assignments} direct +
+Last Seen
++ {format_last_seen(@agent_token.last_seen_at)} +
+ <%= if @agent_token.last_ip do %> ++ {@agent_token.last_ip} +
+ <% end %> +Agent Info
+ <%= if @agent_token.metadata["version"] do %> ++ v{@agent_token.metadata["version"]} +
+ <% else %> ++ Unknown +
+ <% end %> + <%= if @agent_token.metadata["uptime_seconds"] do %> ++ Uptime: {format_uptime(@agent_token.metadata["uptime_seconds"])} +
+ <% end %> ++ Equipment that this agent is responsible for polling +
++ This agent is not currently polling any equipment. +
++ {equipment.name} +
+ <% {source, source_label} = assignment_source(equipment, @agent_token.id) %> + + {source_label} + +