poller detail screen fix
This commit is contained in:
parent
fb42e93f7a
commit
902d21eeee
1 changed files with 18 additions and 9 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue