defmodule VigilWeb.OrgSettingsLive.Audit do
@moduledoc "The latest changes to who is in the organization, and as what."
use VigilWeb, :live_view
import VigilWeb.OrgSettingsLive.Components
alias Vigil.Organizations
@impl true
def mount(_params, _session, socket) do
org = socket.assigns.current_scope.organization
{:ok,
socket
|> assign(:page_title, "#{org.name} · Audit log")
|> stream(:events, Organizations.list_audit_events(org))}
end
@impl true
def render(assigns) do
~H"""
<Layouts.app flash={@flash} current_scope={@current_scope} active={:org_settings}>
<.settings scope={@current_scope} tab={:audit}>
<ol
id="audit"
phx-update="stream"
class="divide-y divide-base-300 rounded-box border border-base-300"
>
<li id="audit-empty" class="hidden p-4 text-center text-sm text-base-content/60 only:block">
Nothing yet.
</li>
<li
:for={{dom_id, e} <- @streams.events}
id={dom_id}
class="flex flex-wrap items-baseline gap-x-3 px-4 py-2 text-sm"
>
<time class="w-36 shrink-0 font-mono text-xs text-base-content/60">
{Calendar.strftime(e.inserted_at, "%Y-%m-%d %H:%M")}
</time>
<span class="font-medium">{e.action}</span>
<span :if={e.target_user} class="font-mono text-xs">{e.target_user.email}</span>
<span class="text-xs text-base-content/60">
{if e.actor, do: "by #{e.actor.email}", else: "by the system"}
</span>
<span :if={e.data != %{}} class="font-mono text-xs text-base-content/50">
{e.data |> Enum.map_join(" ", fn {k, v} -> "#{k}=#{v}" end)}
</span>
</li>
</ol>
</.settings>
</Layouts.app>
"""
end
end
neiam
/vigil
public · Issues · Pulls · Labels · Forks · Compare · Actions queued · Badges · Packages
⭐
Log in to mark this repository.
1.8 KiB · text
History
573fef1