From 156d9a47bfc443930956a30976ccf1793dca3754 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Thu, 5 Feb 2026 14:57:11 -0600 Subject: [PATCH] UI improvements --- lib/towerops_web/channels/agent_channel.ex | 6 +--- lib/towerops_web/components/layouts.ex | 4 +-- .../live/device_live/form.html.heex | 18 +++++----- .../live/device_live/show.html.heex | 34 ++++++++++++++++++- .../live/org/settings_live.html.heex | 18 +++++----- lib/towerops_web/live/org_live/index.ex | 11 ++++++ .../live/org_live/index.html.heex | 10 +++--- lib/towerops_web/live/org_live/new.ex | 4 +-- lib/towerops_web/router.ex | 4 ++- lib/towerops_web/user_auth.ex | 8 ++--- priv/static/changelog.txt | 2 ++ 11 files changed, 82 insertions(+), 37 deletions(-) diff --git a/lib/towerops_web/channels/agent_channel.ex b/lib/towerops_web/channels/agent_channel.ex index aaeddf50..114db8e3 100644 --- a/lib/towerops_web/channels/agent_channel.ex +++ b/lib/towerops_web/channels/agent_channel.ex @@ -820,16 +820,12 @@ defmodule ToweropsWeb.AgentChannel do defp process_sensor_reading(sensor, oid_values, timestamp) do case Map.get(oid_values, sensor.sensor_oid) do nil -> - Logger.info("Sensor #{sensor.sensor_descr} (#{sensor.sensor_oid}): OID not in result") + :ok value -> with parsed_value when not is_nil(parsed_value) <- parse_float(value) do final_value = parsed_value / sensor.sensor_divisor - Logger.info( - "Sensor #{sensor.sensor_descr}: raw=#{inspect(value)}, parsed=#{inspect(parsed_value)}, divisor=#{sensor.sensor_divisor}, final=#{inspect(final_value)}" - ) - Snmp.create_sensor_reading(%{ sensor_id: sensor.id, value: final_value, diff --git a/lib/towerops_web/components/layouts.ex b/lib/towerops_web/components/layouts.ex index df86a13d..b7c40a66 100644 --- a/lib/towerops_web/components/layouts.ex +++ b/lib/towerops_web/components/layouts.ex @@ -205,7 +205,7 @@ defmodule ToweropsWeb.Layouts do class="hidden md:ml-8 md:flex md:space-x-6" > <.nav_link - navigate={~p"/"} + navigate={~p"/dashboard"} active={@active_page == "dashboard"} > Dashboard @@ -369,7 +369,7 @@ defmodule ToweropsWeb.Layouts do >
<.mobile_nav_link - navigate={~p"/"} + navigate={~p"/dashboard"} active={@active_page == "dashboard"} > <.icon name="hero-home" class="size-5" /> Dashboard diff --git a/lib/towerops_web/live/device_live/form.html.heex b/lib/towerops_web/live/device_live/form.html.heex index d39dd45a..26bd3cbb 100644 --- a/lib/towerops_web/live/device_live/form.html.heex +++ b/lib/towerops_web/live/device_live/form.html.heex @@ -97,7 +97,7 @@ <.form for={@form} id="device-form" phx-change="validate" phx-submit="save">
-
+

Basic Information @@ -108,7 +108,7 @@

-
+
<.input field={@form[:name]} @@ -186,7 +186,7 @@
-
+

Monitoring Configuration @@ -197,7 +197,7 @@

-
+
<.input field={@form[:check_interval_seconds]} @@ -276,7 +276,7 @@
-
+

SNMP Configuration @@ -337,7 +337,7 @@
<.input @@ -590,7 +590,7 @@ <%= if @live_action == :edit and @is_mikrotik_device do %>
@@ -621,7 +621,7 @@
<% end %> -
+
<.input field={@form[:mikrotik_enabled]} @@ -700,7 +700,7 @@ <%= if @live_action == :edit do %> -
+

Danger Zone

diff --git a/lib/towerops_web/live/device_live/show.html.heex b/lib/towerops_web/live/device_live/show.html.heex index 313e5617..779ceeec 100644 --- a/lib/towerops_web/live/device_live/show.html.heex +++ b/lib/towerops_web/live/device_live/show.html.heex @@ -26,7 +26,39 @@

-

{@device.name}

+
+

{@device.name}

+
+ "bg-green-100 text-green-800 dark:bg-green-950/50 dark:text-green-400 ring-1 ring-green-600/20 dark:ring-green-500/30" + + :down -> + "bg-red-100 text-red-800 dark:bg-red-950/50 dark:text-red-400 ring-1 ring-red-600/20 dark:ring-red-500/30" + + :unknown -> + "bg-gray-100 text-gray-800 dark:bg-gray-800/50 dark:text-gray-400 ring-1 ring-gray-600/20 dark:ring-gray-500/30" + end + ]}> + "bg-green-600 dark:bg-green-500" + :down -> "bg-red-600 dark:bg-red-500" + :unknown -> "bg-gray-500 dark:bg-gray-400" + end + ]}> + + + {case @device.status do + :up -> "Online" + :down -> "Offline" + :unknown -> "Unknown" + end} + +
+
{@device.ip_address} diff --git a/lib/towerops_web/live/org/settings_live.html.heex b/lib/towerops_web/live/org/settings_live.html.heex index a72f65f0..83c96647 100644 --- a/lib/towerops_web/live/org/settings_live.html.heex +++ b/lib/towerops_web/live/org/settings_live.html.heex @@ -5,7 +5,7 @@
<.link - navigate={~p"/orgs/#{@organization.slug}"} + navigate={~p"/dashboard"} 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 @@ -29,7 +29,7 @@ >
-
+

Organization Name @@ -51,7 +51,7 @@ <%= if @user_orgs_count > 1 do %> -
+

Default Organization @@ -91,7 +91,7 @@ <% end %> -
+

Site Organization @@ -135,7 +135,7 @@

-
+

SNMP Configuration @@ -272,7 +272,7 @@ <%= if @current_scope.user.is_superuser do %> -
+

MikroTik API Configuration @@ -363,7 +363,7 @@ <%= if @available_agents != [] do %> -
+

Default Agent @@ -441,7 +441,7 @@

<% else %> -
+

Default Agent @@ -468,7 +468,7 @@
<.link - navigate={~p"/orgs/#{@organization.slug}"} + navigate={~p"/dashboard"} class="text-sm font-semibold text-gray-900 dark:text-white" > Cancel diff --git a/lib/towerops_web/live/org_live/index.ex b/lib/towerops_web/live/org_live/index.ex index d4cb1abf..4b1f55a5 100644 --- a/lib/towerops_web/live/org_live/index.ex +++ b/lib/towerops_web/live/org_live/index.ex @@ -2,6 +2,7 @@ defmodule ToweropsWeb.OrgLive.Index do @moduledoc false use ToweropsWeb, :live_view + alias Towerops.Accounts alias Towerops.Organizations @impl true @@ -19,4 +20,14 @@ defmodule ToweropsWeb.OrgLive.Index do def handle_params(_params, _url, socket) do {:noreply, socket} end + + @impl true + def handle_event("select_org", %{"org-id" => org_id}, socket) do + user = socket.assigns.current_scope.user + + # Update user's default organization + {:ok, _user} = Accounts.update_user_profile(user, %{default_organization_id: org_id}) + + {:noreply, push_navigate(socket, to: ~p"/dashboard")} + end end diff --git a/lib/towerops_web/live/org_live/index.html.heex b/lib/towerops_web/live/org_live/index.html.heex index e4060364..ddec3dca 100644 --- a/lib/towerops_web/live/org_live/index.html.heex +++ b/lib/towerops_web/live/org_live/index.html.heex @@ -12,10 +12,12 @@
- <.link +
diff --git a/lib/towerops_web/live/org_live/new.ex b/lib/towerops_web/live/org_live/new.ex index 041b11f1..de552e66 100644 --- a/lib/towerops_web/live/org_live/new.ex +++ b/lib/towerops_web/live/org_live/new.ex @@ -39,11 +39,11 @@ defmodule ToweropsWeb.OrgLive.New do opts = if is_superuser, do: [bypass_limits: true], else: [] case Organizations.create_organization(org_params, user.id, opts) do - {:ok, organization} -> + {:ok, _organization} -> {:noreply, socket |> put_flash(:info, "Organization created successfully") - |> push_navigate(to: ~p"/orgs/#{organization.slug}")} + |> push_navigate(to: ~p"/dashboard")} {:error, %Ecto.Changeset{} = changeset} -> {:noreply, assign(socket, :form, to_form(changeset))} diff --git a/lib/towerops_web/router.ex b/lib/towerops_web/router.ex index 7cc74c6c..893b6c35 100644 --- a/lib/towerops_web/router.ex +++ b/lib/towerops_web/router.ex @@ -293,7 +293,6 @@ defmodule ToweropsWeb.Router do scope "/orgs/:org_slug", ToweropsWeb do pipe_through [:browser, :require_authenticated_user, :load_current_organization] - live "/", DashboardLive, :index live "/settings", Org.SettingsLive, :index end end @@ -309,6 +308,9 @@ defmodule ToweropsWeb.Router do scope "/", ToweropsWeb do pipe_through [:browser, :require_authenticated_user] + # Dashboard route + live "/dashboard", DashboardLive, :index + # Alert routes live "/alerts", AlertLive.Index, :index diff --git a/lib/towerops_web/user_auth.ex b/lib/towerops_web/user_auth.ex index adc36ff8..3aae5368 100644 --- a/lib/towerops_web/user_auth.ex +++ b/lib/towerops_web/user_auth.ex @@ -323,8 +323,8 @@ defmodule ToweropsWeb.UserAuth do # Get user's organizations (ordered by most recently joined first) case Towerops.Organizations.list_user_organizations(user.id) do [_first_org | _] -> - # Devices page - ~p"/devices" + # Dashboard page + ~p"/dashboard" [] -> # No organizations yet, go to org list @@ -883,10 +883,10 @@ defmodule ToweropsWeb.UserAuth do ip_address: ip }) - # Devices page + # Dashboard page redirect_path = case Towerops.Organizations.list_user_organizations(superuser.id) do - [_first_org | _] -> ~p"/devices" + [_first_org | _] -> ~p"/dashboard" [] -> ~p"/orgs" end diff --git a/priv/static/changelog.txt b/priv/static/changelog.txt index 0bbbf4a3..793b98c2 100644 --- a/priv/static/changelog.txt +++ b/priv/static/changelog.txt @@ -5,6 +5,8 @@ Devices Tested & Working 2026-02-05 * Fix SNMP v3 polling +* UI Simplification +* Add device status to device page 2026-02-04 * Feature: SNMP v3 support