diff --git a/lib/towerops_web/live/device_live/show.ex b/lib/towerops_web/live/device_live/show.ex index 6ad31381..a1ad4332 100644 --- a/lib/towerops_web/live/device_live/show.ex +++ b/lib/towerops_web/live/device_live/show.ex @@ -217,7 +217,8 @@ defmodule ToweropsWeb.DeviceLive.Show do storage_sensors = Enum.filter(non_transceiver_sensors, &(&1.sensor_type in ["disk_usage"])) - count_sensors = Enum.filter(non_transceiver_sensors, &(&1.sensor_type == "count")) + # Include various counter/gauge sensor types in the Counters section + count_sensors = Enum.filter(non_transceiver_sensors, &counter_sensor?/1) # Wireless sensors (frequency, power, rssi, ccq, etc.) wireless_sensors = Enum.filter(non_transceiver_sensors, &wireless_sensor?/1) @@ -829,4 +830,17 @@ defmodule ToweropsWeb.DeviceLive.Show do "utilization" ] end + + # Counter sensors include various count and gauge types + # (connections, sessions, clients, DHCP leases, etc.) + defp counter_sensor?(sensor) do + sensor.sensor_type in [ + "count", + "pppoe_sessions", + "connections", + "clients", + "leases", + "sessions" + ] + end end diff --git a/lib/towerops_web/live/device_live/show.html.heex b/lib/towerops_web/live/device_live/show.html.heex index 7640504f..a59e8a34 100644 --- a/lib/towerops_web/live/device_live/show.html.heex +++ b/lib/towerops_web/live/device_live/show.html.heex @@ -713,7 +713,7 @@
<.link navigate={ - ~p"/devices/#{@device.id}/graph/count?sensor_id=#{sensor.id}" + ~p"/devices/#{@device.id}/graph/#{sensor.sensor_type}?sensor_id=#{sensor.id}" } class="hover:text-blue-600 dark:hover:text-blue-400 hover:underline" > diff --git a/lib/towerops_web/live/graph_live/show.ex b/lib/towerops_web/live/graph_live/show.ex index 71fa3960..18d0c796 100644 --- a/lib/towerops_web/live/graph_live/show.ex +++ b/lib/towerops_web/live/graph_live/show.ex @@ -204,7 +204,13 @@ defmodule ToweropsWeb.GraphLive.Show do since = get_datetime_from_range(range) limit = get_limit_for_range(range) dataset = sensor_to_dataset(sensor, since, limit) - Jason.encode!(%{datasets: [dataset]}) + + # Return nil if no data points (empty readings) + if Enum.empty?(dataset.data) do + nil + else + Jason.encode!(%{datasets: [dataset]}) + end end end