diff --git a/lib/towerops_web/live/org/settings_live.ex b/lib/towerops_web/live/org/settings_live.ex
index 93bf4653..67e04b44 100644
--- a/lib/towerops_web/live/org/settings_live.ex
+++ b/lib/towerops_web/live/org/settings_live.ex
@@ -38,25 +38,17 @@ defmodule ToweropsWeb.Org.SettingsLive do
{:noreply, assign(socket, :form, to_form(changeset))}
end
- @impl true
- def handle_event("toggle_mikrotik", _params, socket) do
- # credo:disable-for-next-line Credo.Check.Design.AliasUsage
- current_value = Phoenix.HTML.Form.input_value(socket.assigns.form, :mikrotik_enabled)
- new_value = !current_value
-
- changeset = Organizations.change_organization(socket.assigns.organization, %{"mikrotik_enabled" => new_value})
-
- {:noreply, assign(socket, :form, to_form(changeset))}
- end
-
@impl true
def handle_event("save", %{"organization" => org_params}, socket) do
case Organizations.update_organization(socket.assigns.organization, org_params) do
{:ok, organization} ->
+ changeset = Organizations.change_organization(organization)
+
{:noreply,
socket
- |> put_flash(:info, "Organization settings updated successfully")
- |> push_navigate(to: ~p"/orgs/#{organization.slug}")}
+ |> put_flash(:info, "Settings saved successfully")
+ |> assign(:organization, organization)
+ |> assign(:form, to_form(changeset))}
{:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, :form, to_form(changeset))}
diff --git a/lib/towerops_web/live/org/settings_live.html.heex b/lib/towerops_web/live/org/settings_live.html.heex
index 43b1ce56..f110f863 100644
--- a/lib/towerops_web/live/org/settings_live.html.heex
+++ b/lib/towerops_web/live/org/settings_live.html.heex
@@ -22,6 +22,7 @@
<.form
for={@form}
id="organization-form"
+ phx-change="validate"
phx-submit="save"
data-1p-ignore
data-form-type="other"
@@ -39,26 +40,12 @@
-
-
-
- Organization Name
-
-
-
-
-
-
+ <.input
+ field={@form[:name]}
+ type="text"
+ label="Organization Name"
+ required
+ />
@@ -78,62 +65,20 @@
-
-
-
- SNMP Version
-
-
-
- Select SNMP version
- SNMP v1
-
- SNMP v2c
-
- SNMP v3
-
-
-
-
-
-
+ <.input
+ field={@form[:snmp_version]}
+ type="select"
+ label="SNMP Version"
+ prompt="Select SNMP version"
+ options={[{"SNMP v1", "1"}, {"SNMP v2c", "2c"}, {"SNMP v3", "3"}]}
+ />
-
-
- SNMP Community String
-
-
-
-
-
-
+ <.input
+ field={@form[:snmp_community]}
+ type="text"
+ label="SNMP Community String"
+ placeholder="e.g., public"
+ />
<%= if @organization.snmp_community do %>
@@ -174,126 +119,67 @@
-
-
-
-
-
- Enable MikroTik API
-
-
-
+ <.input
+ field={@form[:mikrotik_enabled]}
+ type="checkbox"
+ label="Enable MikroTik API"
+ />
-
+
+ <.input
+ field={@form[:mikrotik_username]}
+ type="text"
+ label="Username"
+ placeholder="e.g., admin"
+ autocomplete="off"
+ />
+
-
+
+ <.input
+ field={@form[:mikrotik_password]}
+ type="password"
+ label="Password"
+ placeholder="RouterOS API password"
+ autocomplete="off"
+ />
+
-
+
+ <.input
+ field={@form[:mikrotik_port]}
+ type="number"
+ label="API Port"
+ placeholder="8729"
+ autocomplete="off"
+ />
+
-
-
-
-
- Use SSL (API-SSL)
-
-
-
+
+ <.input
+ field={@form[:mikrotik_use_ssl]}
+ type="checkbox"
+ label="Use SSL (API-SSL)"
+ />
+
-
-
-
- Critical Security Warning:
- Plain API (port 8728) sends credentials unencrypted over the network. This setting is
- blocked for devices using cloud pollers
- and should only be used with local agents on trusted networks.
-
-
+
+
+
+ Critical Security Warning:
+ Plain API (port 8728) sends credentials unencrypted over the network. This setting is
+ blocked for devices using cloud pollers
+ and should only be used with local agents on trusted networks.
+
+
-
-
-
- Security Warning:
- Plain API (port 8728) sends credentials unencrypted. Use SSL (port 8729) whenever possible.
-
-
+
+
+
+ Security Warning:
+ Plain API (port 8728) sends credentials unencrypted. Use SSL (port 8729) whenever possible.
+
@@ -317,78 +203,43 @@
-
-
-
- Default Remote Agent
-
-
-
- No default agent - cloud polling
- <%= for agent <- @available_agents do %>
-
- {agent.name}
-
- <% end %>
-
-
-
-
-
-
+ <.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)
-
-
-
+
+
+ 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)
+