feat: make network insights actionable with affected device links and metadata
This commit is contained in:
parent
3284f0bce6
commit
74f112642d
2 changed files with 38 additions and 1 deletions
|
|
@ -49,6 +49,7 @@ defmodule Towerops.Workers.GaiiaInsightWorker do
|
|||
"dedup_key" => "untracked",
|
||||
"finding_type" => "untracked",
|
||||
"count" => count,
|
||||
"device_ids" => untracked_devices |> Enum.map(& &1.device.id),
|
||||
"device_names" => untracked_devices |> Enum.take(10) |> Enum.map(& &1.device.name)
|
||||
}
|
||||
})
|
||||
|
|
@ -97,7 +98,13 @@ defmodule Towerops.Workers.GaiiaInsightWorker do
|
|||
metadata: %{
|
||||
"dedup_key" => "mismatch",
|
||||
"finding_type" => "mismatch",
|
||||
"count" => count
|
||||
"count" => count,
|
||||
"device_ids" => data_mismatches |> Enum.map(& &1.device.id) |> Enum.uniq(),
|
||||
"device_names" =>
|
||||
data_mismatches
|
||||
|> Enum.map(& &1.device.name)
|
||||
|> Enum.uniq()
|
||||
|> Enum.take(10)
|
||||
}
|
||||
})
|
||||
end
|
||||
|
|
|
|||
|
|
@ -274,6 +274,36 @@
|
|||
</p>
|
||||
<% end %>
|
||||
|
||||
<%!-- Affected devices list (from metadata) --%>
|
||||
<%= if insight.metadata["device_names"] && length(insight.metadata["device_names"]) > 0 do %>
|
||||
<div class="mt-2 rounded-md bg-gray-50 p-3 dark:bg-white/5">
|
||||
<p class="text-xs font-medium text-gray-700 dark:text-gray-300">
|
||||
Affected devices:
|
||||
</p>
|
||||
<div class="mt-1.5 flex flex-wrap gap-1.5">
|
||||
<%= for {name, idx} <- Enum.with_index(insight.metadata["device_names"]) do %>
|
||||
<%= if insight.metadata["device_ids"] && Enum.at(insight.metadata["device_ids"], idx) do %>
|
||||
<.link
|
||||
navigate={~p"/devices/#{Enum.at(insight.metadata["device_ids"], idx)}"}
|
||||
class="inline-flex items-center rounded-md bg-white px-2 py-0.5 text-xs font-medium text-indigo-700 ring-1 ring-inset ring-indigo-700/10 hover:bg-indigo-50 dark:bg-indigo-900/20 dark:text-indigo-400 dark:ring-indigo-400/20 dark:hover:bg-indigo-900/40"
|
||||
>
|
||||
{name || "Unnamed"}
|
||||
</.link>
|
||||
<% else %>
|
||||
<span class="inline-flex items-center rounded-md bg-white px-2 py-0.5 text-xs font-medium text-gray-600 ring-1 ring-inset ring-gray-500/10 dark:bg-white/10 dark:text-gray-300 dark:ring-white/10">
|
||||
{name || "Unnamed"}
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= if insight.metadata["count"] && insight.metadata["count"] > length(insight.metadata["device_names"]) do %>
|
||||
<span class="inline-flex items-center rounded-md bg-gray-100 px-2 py-0.5 text-xs text-gray-500 dark:bg-white/10 dark:text-gray-400">
|
||||
+{insight.metadata["count"] - length(insight.metadata["device_names"])} more
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="mt-2 flex flex-wrap items-center gap-3 text-xs text-gray-500 dark:text-gray-400">
|
||||
<%!-- Access point --%>
|
||||
<%= if insight.preseem_access_point do %>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue