232 lines
9.8 KiB
Text
232 lines
9.8 KiB
Text
<Layouts.authenticated
|
|
flash={@flash}
|
|
current_scope={@current_scope}
|
|
active_page="activity"
|
|
>
|
|
<.header>
|
|
<div class="flex items-center gap-3">
|
|
<span class="relative flex h-3 w-3">
|
|
<span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"></span>
|
|
<span class="relative inline-flex rounded-full h-3 w-3 bg-green-500"></span>
|
|
</span>
|
|
Activity Feed
|
|
</div>
|
|
<:subtitle>Real-time NOC operations log — config changes, alerts, events, and syncs</:subtitle>
|
|
</.header>
|
|
|
|
<%!-- Search Bar --%>
|
|
<div class="mt-6">
|
|
<form phx-change="search" phx-submit="search" class="relative">
|
|
<div class="relative">
|
|
<.icon name="hero-magnifying-glass" class="absolute left-3 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400 dark:text-gray-500" />
|
|
<input
|
|
type="text"
|
|
name="search"
|
|
value={@search}
|
|
placeholder="Search by device name, IP, site, or keyword..."
|
|
phx-debounce="300"
|
|
class="input input-bordered w-full pl-10 pr-10 bg-white dark:bg-gray-800 dark:border-gray-700 dark:text-white dark:placeholder-gray-500"
|
|
/>
|
|
<button
|
|
:if={@search != ""}
|
|
type="button"
|
|
phx-click="clear_search"
|
|
class="absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"
|
|
>
|
|
<.icon name="hero-x-mark" class="h-5 w-5" />
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<%!-- Filter Chips with Counts --%>
|
|
<div class="mt-4 flex flex-wrap items-center gap-2">
|
|
<span class="text-sm font-medium text-gray-500 dark:text-gray-400 mr-1">Filter:</span>
|
|
<%= for {type, label, icon} <- filter_options() do %>
|
|
<button
|
|
type="button"
|
|
phx-click="toggle_type"
|
|
phx-value-type={type}
|
|
class={[
|
|
"inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-medium transition-all",
|
|
if(type in @active_types,
|
|
do: filter_active_class(type),
|
|
else: "bg-gray-100 text-gray-500 dark:bg-gray-800 dark:text-gray-500 hover:bg-gray-200 dark:hover:bg-gray-700"
|
|
)
|
|
]}
|
|
>
|
|
<.icon name={icon} class="h-3.5 w-3.5" />
|
|
{label}
|
|
<span
|
|
:if={Map.get(@type_counts, type, 0) > 0}
|
|
class={[
|
|
"inline-flex items-center justify-center min-w-[18px] h-[18px] rounded-full px-1 text-[10px] font-bold",
|
|
if(type in @active_types,
|
|
do: "bg-white/30 dark:bg-black/20",
|
|
else: "bg-gray-200 dark:bg-gray-700"
|
|
)
|
|
]}
|
|
>
|
|
{Map.get(@type_counts, type, 0)}
|
|
</span>
|
|
</button>
|
|
<% end %>
|
|
</div>
|
|
|
|
<%!-- Timeline --%>
|
|
<div class="mt-8">
|
|
<%= if @items == [] do %>
|
|
<div class="rounded-xl border-2 border-dashed border-gray-200 bg-white p-16 text-center dark:border-gray-700 dark:bg-gray-800/50">
|
|
<div class="mx-auto w-16 h-16 rounded-full bg-gray-100 dark:bg-gray-700 flex items-center justify-center mb-4">
|
|
<.icon name="hero-signal-slash" class="h-8 w-8 text-gray-400 dark:text-gray-500" />
|
|
</div>
|
|
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">
|
|
<%= if @search != "" do %>
|
|
No results for "<%= @search %>"
|
|
<% else %>
|
|
No activity yet
|
|
<% end %>
|
|
</h3>
|
|
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400 max-w-md mx-auto">
|
|
<%= if @search != "" do %>
|
|
Try adjusting your search terms or clearing the filters.
|
|
<% else %>
|
|
Your network operations log is empty. Events will appear here in real time as config changes, alerts, device events, and syncs happen across your organization.
|
|
<% end %>
|
|
</p>
|
|
<div :if={@search != ""} class="mt-4">
|
|
<button
|
|
type="button"
|
|
phx-click="clear_search"
|
|
class="btn btn-sm btn-outline gap-2"
|
|
>
|
|
<.icon name="hero-x-mark" class="h-4 w-4" />
|
|
Clear search
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<% else %>
|
|
<%!-- Item count summary --%>
|
|
<div class="mb-4 flex items-center justify-between">
|
|
<span class="text-xs text-gray-500 dark:text-gray-400">
|
|
Showing {length(@items)} events
|
|
<span :if={@search != ""}>matching "<strong class="text-gray-700 dark:text-gray-300">{@search}</strong>"</span>
|
|
</span>
|
|
<span class="text-xs text-gray-400 dark:text-gray-500 flex items-center gap-1">
|
|
<span class="relative flex h-2 w-2">
|
|
<span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"></span>
|
|
<span class="relative inline-flex rounded-full h-2 w-2 bg-green-500"></span>
|
|
</span>
|
|
Live
|
|
</span>
|
|
</div>
|
|
|
|
<%= for {period, period_items} <- @grouped_items do %>
|
|
<%!-- Time Period Header --%>
|
|
<div class="sticky top-0 z-10 flex items-center gap-3 py-2 mb-2 mt-6 first:mt-0">
|
|
<div class="h-px flex-1 bg-gray-200 dark:bg-gray-700"></div>
|
|
<span class="flex-shrink-0 text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 bg-gray-50 dark:bg-gray-900 px-3 py-1 rounded-full">
|
|
{period}
|
|
<span class="ml-1 text-gray-400 dark:text-gray-500 font-normal">({length(period_items)})</span>
|
|
</span>
|
|
<div class="h-px flex-1 bg-gray-200 dark:bg-gray-700"></div>
|
|
</div>
|
|
|
|
<div class="relative">
|
|
<%!-- Vertical timeline line --%>
|
|
<div class="absolute left-5 top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700"></div>
|
|
|
|
<div class="space-y-1">
|
|
<%= for item <- period_items do %>
|
|
<div
|
|
id={item.id}
|
|
class={[
|
|
"relative flex items-start gap-4 pl-12 py-3 group rounded-lg transition-colors",
|
|
"hover:bg-gray-50 dark:hover:bg-gray-800/50",
|
|
item.severity == :critical && "bg-red-50/50 dark:bg-red-900/10"
|
|
]}
|
|
>
|
|
<%!-- Timeline dot --%>
|
|
<div class={[
|
|
"absolute left-3.5 top-4 h-3 w-3 rounded-full border-2 border-white dark:border-gray-900 ring-2 ring-transparent group-hover:ring-gray-200 dark:group-hover:ring-gray-700 transition-all",
|
|
severity_dot_color(item.severity, item.type)
|
|
]}>
|
|
</div>
|
|
|
|
<%!-- Content --%>
|
|
<div class="flex-1 min-w-0">
|
|
<div class="flex items-center gap-2 flex-wrap">
|
|
<.icon name={item.icon} class={["h-4 w-4 flex-shrink-0", severity_icon_color(item.severity, item.type)]} />
|
|
<span class="text-xs text-gray-500 dark:text-gray-400 tabular-nums" title={Calendar.strftime(item.timestamp, "%Y-%m-%d %H:%M:%S UTC")}>
|
|
{relative_time(item.timestamp, @now)}
|
|
</span>
|
|
<span class={[
|
|
"inline-flex items-center rounded-full px-1.5 py-0.5 text-[10px] font-medium",
|
|
type_badge_class(item.type)
|
|
]}>
|
|
{type_label(item.type)}
|
|
</span>
|
|
<%!-- Device/site link --%>
|
|
<.link
|
|
:if={item.device_name && item.link}
|
|
navigate={item.link}
|
|
class="inline-flex items-center gap-1 text-xs font-medium text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300"
|
|
>
|
|
<.icon name="hero-server-stack" class="h-3 w-3" />
|
|
{item.device_name}
|
|
</.link>
|
|
<span
|
|
:if={item.device_name && !item.link}
|
|
class="inline-flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400"
|
|
>
|
|
<.icon name="hero-server-stack" class="h-3 w-3" />
|
|
{item.device_name}
|
|
</span>
|
|
</div>
|
|
|
|
<p class={["mt-0.5 text-sm font-medium", severity_text_color(item.severity, item.type)]}>
|
|
<%= if item.link do %>
|
|
<.link navigate={item.link} class="hover:underline">
|
|
{item.summary}
|
|
</.link>
|
|
<% else %>
|
|
{item.summary}
|
|
<% end %>
|
|
</p>
|
|
|
|
<p :if={item.detail && item.detail != ""} class="mt-0.5 text-xs text-gray-500 dark:text-gray-400">
|
|
{item.detail}
|
|
</p>
|
|
|
|
<div :if={item.site_name} class="mt-0.5 inline-flex items-center gap-1 text-xs text-gray-400 dark:text-gray-500">
|
|
<.icon name="hero-map-pin" class="h-3 w-3" />
|
|
{item.site_name}
|
|
</div>
|
|
</div>
|
|
|
|
<%!-- Link arrow --%>
|
|
<div :if={item.link} class="flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity">
|
|
<.link navigate={item.link} class="text-gray-400 hover:text-blue-500 dark:text-gray-600 dark:hover:text-blue-400">
|
|
<.icon name="hero-arrow-right" class="h-4 w-4" />
|
|
</.link>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
|
|
<%!-- Load More --%>
|
|
<div :if={@has_more} class="mt-6 text-center">
|
|
<button
|
|
type="button"
|
|
phx-click="load_more"
|
|
class="btn btn-outline btn-sm gap-2"
|
|
>
|
|
<.icon name="hero-arrow-down" class="h-4 w-4" />
|
|
Load more events
|
|
</button>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</Layouts.authenticated>
|