Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put audit log feed in component #1677

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions lib/nerves_hub_web/components/audit_log_feed.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
defmodule NervesHubWeb.Components.AuditLogFeed do
use NervesHubWeb, :component

import NervesHubWeb.LayoutView, only: [pagination_links: 1]

alias NervesHubWeb.LayoutView.DateTimeFormat

attr(:audit_logs, :list)
attr(:audit_pager, :map)

def render(assigns) do
~H"""
<div id="audit-log-feed">
<%= if Enum.empty?(@audit_logs) do %>
<div class="audit-log-item">
<p class="text-muted">No activity</p>
</div>
<% else %>
<div :for={audit_log <- @audit_logs} class="audit-log-item" id={audit_log.id}>
<div class="audit-action-icon icon-update"></div>
<div>
<p class="audit-description"><%= audit_log.description %></p>
<div class="help-text">
<%= DateTimeFormat.from_now(audit_log.inserted_at) %><small> at <%= audit_log.inserted_at %></small>
<%= if audit_log.reference_id, do: "(Ref: #{audit_log.reference_id})" %>
</div>
</div>
</div>
<%= pagination_links(@audit_pager) %>
<% end %>
</div>
"""
end
end
2 changes: 2 additions & 0 deletions lib/nerves_hub_web/live/deployments/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ defmodule NervesHubWeb.Live.Deployments.Show do
alias NervesHub.Firmwares.Firmware
alias NervesHub.Repo

alias NervesHubWeb.Components.AuditLogFeed

@impl Phoenix.LiveView
def mount(params, _session, socket) do
%{"name" => name} = params
Expand Down
2 changes: 1 addition & 1 deletion lib/nerves_hub_web/live/deployments/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,5 @@
<div>
<h3 id="latest-activity" class="mb-2">Latest Activity</h3>

<%= render(NervesHubWeb.AuditLogView, "_audit_log_feed.html", assigns) %>
<AuditLogFeed.render audit_logs={@audit_logs} audit_pager={@audit_pager} />
</div>
1 change: 1 addition & 0 deletions lib/nerves_hub_web/live/devices/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ defmodule NervesHubWeb.Live.Devices.Show do
alias NervesHub.Firmwares
alias NervesHub.Tracker

alias NervesHubWeb.Components.AuditLogFeed
alias NervesHubWeb.Components.DeviceHeader
alias NervesHubWeb.Components.FwupProgress
alias NervesHubWeb.Components.DeviceLocation
Expand Down
2 changes: 1 addition & 1 deletion lib/nerves_hub_web/live/devices/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
</a>
</div>

<%= render(NervesHubWeb.AuditLogView, "_audit_log_feed.html", assigns) %>
<AuditLogFeed.render audit_logs={@audit_logs} audit_pager={@audit_pager} />
</div>
</div>
</div>
23 changes: 0 additions & 23 deletions lib/nerves_hub_web/templates/audit_log/_audit_log_feed.html.heex

This file was deleted.

56 changes: 0 additions & 56 deletions lib/nerves_hub_web/views/audit_log_view.ex

This file was deleted.

Loading