Add three-level agent assignment hierarchy (Equipment > Site > Organization) allowing flexible agent deployment strategies. Agents now receive only equipment assigned to them through direct assignment or inheritance from site/organization defaults. Key changes: - Add agent_token_id to Sites table with migration - Implement get_effective_agent_token/1 for hierarchical resolution - Add list_agent_polling_targets/1 to return polling targets per agent - Update API config endpoint to use hierarchical polling targets - Add agent assignment UI to equipment, site, and organization forms - Show agent source (direct/site/org/none) in equipment form - Add equipment count column to agent list - Update terminology from "poll from server" to "cloud polling" Tests: - Add 8 comprehensive tests for list_agent_polling_targets/1 - Add end-to-end test for hierarchical config endpoint - All 775 tests passing
68 lines
2.5 KiB
Text
68 lines
2.5 KiB
Text
<Layouts.authenticated
|
|
flash={@flash}
|
|
current_scope={@current_scope}
|
|
current_organization={@organization}
|
|
>
|
|
<div class="mb-4">
|
|
<.link
|
|
navigate={~p"/orgs/#{@organization.slug}"}
|
|
class="inline-flex items-center gap-1 text-sm text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-100"
|
|
>
|
|
<.icon name="hero-arrow-left" class="h-4 w-4" /> Back to Dashboard
|
|
</.link>
|
|
</div>
|
|
|
|
<.header>
|
|
Organization Settings
|
|
<:subtitle>
|
|
Manage your organization settings and defaults
|
|
</:subtitle>
|
|
</.header>
|
|
|
|
<div class="max-w-2xl">
|
|
<.form for={@form} id="organization-form" phx-change="validate" phx-submit="save">
|
|
<.input field={@form[:name]} type="text" label="Organization Name" required />
|
|
|
|
<%= if @available_agents != [] do %>
|
|
<div class="mt-6 border-t pt-6">
|
|
<h3 class="text-lg font-medium mb-4">Default Agent</h3>
|
|
<p class="text-sm text-zinc-600 dark:text-zinc-400 mb-4">
|
|
Select a default agent for SNMP polling. This will be used for all equipment in this organization unless overridden at the site or equipment level.
|
|
</p>
|
|
|
|
<.input
|
|
field={@form[:default_agent_token_id]}
|
|
type="select"
|
|
label="Default Remote Agent"
|
|
prompt="No default agent - cloud polling"
|
|
options={Enum.map(@available_agents, &{&1.name, &1.id})}
|
|
/>
|
|
|
|
<p class="mt-2 text-sm text-zinc-500 dark:text-zinc-400 italic">
|
|
<.icon name="hero-information-circle" class="h-4 w-4 inline" />
|
|
Agent assignment hierarchy: Equipment > Site > Organization
|
|
</p>
|
|
</div>
|
|
<% else %>
|
|
<div class="mt-6 border-t pt-6">
|
|
<h3 class="text-lg font-medium mb-2">Default Agent</h3>
|
|
<p class="text-sm text-zinc-600 dark:text-zinc-400 mb-4">
|
|
No agents configured yet.
|
|
<.link
|
|
navigate={~p"/orgs/#{@organization.slug}/agents"}
|
|
class="text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300"
|
|
>
|
|
Create an agent
|
|
</.link>
|
|
to enable remote polling.
|
|
</p>
|
|
</div>
|
|
<% end %>
|
|
|
|
<div class="flex gap-3 mt-6">
|
|
<.button phx-disable-with="Saving..." variant="primary">Save Settings</.button>
|
|
<.button navigate={~p"/orgs/#{@organization.slug}"}>Cancel</.button>
|
|
</div>
|
|
</.form>
|
|
</div>
|
|
</Layouts.authenticated>
|