diff --git a/lib/towerops_web/live/device_live/show.ex b/lib/towerops_web/live/device_live/show.ex index 9a93f179..905c69c3 100644 --- a/lib/towerops_web/live/device_live/show.ex +++ b/lib/towerops_web/live/device_live/show.ex @@ -436,16 +436,20 @@ defmodule ToweropsWeb.DeviceLive.Show do device = socket.assigns.device preseem_ap = Towerops.Preseem.get_access_point_for_device(device.id) - metrics = + {metrics, insights} = if preseem_ap do - Towerops.Preseem.list_subscriber_metrics(preseem_ap.id, limit: 50) + { + Towerops.Preseem.list_subscriber_metrics(preseem_ap.id, limit: 50), + Towerops.Preseem.list_device_insights(device.id) + } else - [] + {[], []} end socket |> assign(:preseem_access_point, preseem_ap) |> assign(:preseem_metrics, metrics) + |> assign(:preseem_insights, insights) end defp get_available_firmware(nil), do: nil @@ -1222,6 +1226,17 @@ defmodule ToweropsWeb.DeviceLive.Show do {:noreply, assign(socket, :selected_backup_ids, MapSet.new())} end + @impl true + def handle_event("dismiss_insight", %{"id" => insight_id}, socket) do + case Towerops.Preseem.dismiss_insight(insight_id) do + {:ok, _} -> + {:noreply, assign_preseem_data(socket)} + + {:error, _} -> + {:noreply, put_flash(socket, :error, "Failed to dismiss insight")} + end + end + @impl true def handle_event("delete_backup", %{"id" => backup_id}, socket) do import ToweropsWeb.Permissions diff --git a/lib/towerops_web/live/device_live/show.html.heex b/lib/towerops_web/live/device_live/show.html.heex index a0c643d8..7ce92a16 100644 --- a/lib/towerops_web/live/device_live/show.html.heex +++ b/lib/towerops_web/live/device_live/show.html.heex @@ -2206,6 +2206,63 @@ <% "preseem" -> %> <%= if @preseem_access_point do %>
+ {insight.title} +
++ {insight.description} +
+