<.link navigate={~p"/orgs/#{@organization.slug}"} class="inline-flex items-center gap-1 text-sm text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white" > <.icon name="hero-arrow-left" class="h-4 w-4" /> Back to Dashboard
<.header> Organization Settings <:subtitle> Manage your organization settings and defaults
<.form for={@form} id="organization-form" phx-change="validate" phx-submit="save"> <.input field={@form[:name]} type="text" label="Organization Name" required />

SNMP Configuration

Set default SNMP settings for all devices in this organization. These can be overridden at the site or device level.

<.input field={@form[:snmp_version]} type="select" label="SNMP Version" prompt="Select SNMP version" options={[{"SNMP v1", "1"}, {"SNMP v2c", "2c"}, {"SNMP v3", "3"}]} /> <.input field={@form[:snmp_community]} type="text" label="SNMP Community String" placeholder="e.g., public" />

<.icon name="hero-information-circle" class="h-4 w-4 inline" /> SNMP configuration hierarchy: Device > Site > Organization

<%= if @organization.snmp_community do %>

Force Apply to All Device

This will override SNMP settings for ALL devices across all sites in this organization.

<.button type="button" phx-click="apply_snmp_to_all" data-confirm="This will replace SNMP settings for ALL devices in this organization. Are you sure?" variant="danger" > <.icon name="hero-arrow-path" class="h-4 w-4" /> Apply SNMP Config to All Device
<% end %>
<%= if @available_agents != [] do %>

Default Agent

Select a default agent for SNMP polling. This will be used for all devices in this organization unless overridden at the site or device level.

<.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})} />

Current Device Assignment:

<.icon name="hero-server" class="h-4 w-4" /> {@assignment_breakdown.direct} device-level override
<.icon name="hero-building-office" class="h-4 w-4" /> {@assignment_breakdown.site} inherited from site
<.icon name="hero-building-office-2" class="h-4 w-4" /> {@assignment_breakdown.organization} inheriting organization default
<.icon name="hero-cloud" class="h-4 w-4" /> {@assignment_breakdown.cloud} cloud polling (no agent)

<.icon name="hero-information-circle" class="h-4 w-4 inline" /> Agent assignment hierarchy: Device > Site > Organization

<%= if @organization.default_agent_token_id do %>

Force Apply to All Device

This will assign the default agent to ALL devices across all sites in this organization.

<.button type="button" phx-click="apply_agent_to_all" data-confirm="This will replace agent assignments for ALL devices in this organization. Are you sure?" variant="danger" > <.icon name="hero-arrow-path" class="h-4 w-4" /> Apply Default Agent to All Device
<% end %>
<% else %>

Default Agent

No agents configured yet. <.link navigate={~p"/agents"} class="text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300" > Create an agent to enable remote polling.

<% end %>
<.button phx-disable-with="Saving..." variant="primary">Save Settings <.button navigate={~p"/orgs/#{@organization.slug}"}>Cancel