fix: remove experimental badges from Alerts and Network Map nav items

This commit is contained in:
Graham McIntire 2026-02-13 19:11:34 -06:00
parent dec6f0f271
commit b7204b604d
2 changed files with 45 additions and 8 deletions

View file

@ -45,6 +45,7 @@ defmodule Towerops.ActivityFeed do
types = Keyword.get(opts, :types, nil)
after_dt = Keyword.get(opts, :after, nil)
before_dt = Keyword.get(opts, :before, nil)
search = Keyword.get(opts, :search, nil)
sources = active_sources(types)
@ -54,10 +55,52 @@ defmodule Towerops.ActivityFeed do
end)
items
|> maybe_filter_search(search)
|> Enum.sort_by(& &1.timestamp, {:desc, DateTime})
|> Enum.take(limit)
end
@doc """
Returns counts of items per type for an organization (for filter chip badges).
"""
def count_by_type(organization_id) do
# Count recent items (last 24h) per type for badge display
since = DateTime.add(DateTime.utc_now(), -86400, :second)
active_sources(nil)
|> Enum.map(fn source ->
items = fetch_source(source, organization_id, since, nil, 1000)
{source, length(items)}
end)
|> Map.new()
end
defp maybe_filter_search(items, nil), do: items
defp maybe_filter_search(items, ""), do: items
defp maybe_filter_search(items, search) do
search_lower = String.downcase(search)
Enum.filter(items, fn item ->
matches_search?(item, search_lower)
end)
end
defp matches_search?(item, search) do
searchable =
[
item.device_name,
item.site_name,
item.summary,
item.detail
]
|> Enum.reject(&is_nil/1)
|> Enum.join(" ")
|> String.downcase()
String.contains?(searchable, search)
end
defp active_sources(nil),
do: [:config_change, :alert_fired, :alert_resolved, :device_event, :sync, :device_added]

View file

@ -228,19 +228,13 @@ defmodule ToweropsWeb.Layouts do
navigate={~p"/network-map"}
active={@active_page == "network-map"}
>
<span class="flex items-center gap-1.5">
<.icon name="hero-beaker" class="h-3.5 w-3.5 text-blue-500 dark:text-blue-400" />
Network Map
</span>
Network Map
</.nav_link>
<.nav_link
navigate={~p"/alerts"}
active={@active_page == "alerts"}
>
<span class="flex items-center gap-1.5">
<.icon name="hero-beaker" class="h-3.5 w-3.5 text-blue-500 dark:text-blue-400" />
Alerts
</span>
Alerts
</.nav_link>
<.nav_link
navigate={~p"/insights"}