From 902d21eeee96dc69748116f949fa2968bb2e1c2d Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Mon, 26 Jan 2026 12:46:14 -0600 Subject: [PATCH] poller detail screen fix --- lib/towerops_web/live/agent_live/show.ex | 27 ++++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/towerops_web/live/agent_live/show.ex b/lib/towerops_web/live/agent_live/show.ex index 9fc987f7..f5f4b649 100644 --- a/lib/towerops_web/live/agent_live/show.ex +++ b/lib/towerops_web/live/agent_live/show.ex @@ -42,26 +42,35 @@ defmodule ToweropsWeb.AgentLive.Show do defp assignment_source(device, agent_token_id) do cond do - # Direct assignment - Enum.any?(device.agent_assignments || [], fn a -> - a.agent_token_id == agent_token_id and a.enabled - end) -> + directly_assigned?(device, agent_token_id) -> {:direct, "Directly assigned"} - # Site assignment - device.site && device.site.agent_token_id == agent_token_id -> + site_assigned?(device, agent_token_id) -> {:site, "From site: #{device.site.name}"} - # Organization assignment - device.organization && device.organization.default_agent_token_id == agent_token_id -> + organization_assigned?(device, agent_token_id) -> {:organization, "From organization"} - # Shouldn't happen but handle gracefully true -> {:unknown, "Unknown"} end end + defp directly_assigned?(device, agent_token_id) do + Enum.any?(device.agent_assignments || [], fn a -> + a.agent_token_id == agent_token_id and a.enabled + end) + end + + defp site_assigned?(device, agent_token_id) do + device.site && device.site.agent_token_id == agent_token_id + end + + defp organization_assigned?(device, agent_token_id) do + device.site && device.site.organization && + device.site.organization.default_agent_token_id == agent_token_id + end + defp source_badge_class(source) do case source do :direct -> "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300"