Class: Admin::AuditLogEntriesController

Inherits:
ApplicationController
  • Object
show all
Includes:
AdminPagination, AdminTurboTable
Defined in:
lib/generators/ruby_cms/templates/controllers/admin/audit_log_entries_controller.rb

Constant Summary collapse

SORTABLE =
{
  "time" => "created_at",
  "actor" => "actor_email",
  "action" => "action"
}.freeze
FILTERS =
AuditLogEntry::BUCKETS + [ "all" ].freeze

Constants included from AdminPagination

AdminPagination::DEFAULT_MAX_PER_PAGE, AdminPagination::DEFAULT_MIN_PER_PAGE

Instance Method Summary collapse

Methods included from AdminTurboTable

#turbo_frame_id, #turbo_frame_request?, #turbo_redirect_to, #turbo_render_form, #turbo_render_index, #turbo_stream_replace_table, #turbo_stream_request?, #turbo_stream_update_table

Methods included from AdminPagination

#paginate_collection, #set_pagination_vars

Instance Method Details

#indexObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/generators/ruby_cms/templates/controllers/admin/audit_log_entries_controller.rb', line 21

def index
  base = AuditLogEntry.all
  base = base.by_actor(params[:actor]) if params[:actor].present?

  @filter_counts = filter_counts(base)
  @current_filter = FILTERS.include?(params[:filter]) ? params[:filter] : "all"

  scope = base
  scope = scope.by_bucket(@current_filter) unless @current_filter == "all"
  scope = scope.search_fulltext(params[:search].to_s.strip) if params[:search].present?

  @sort_column = SORTABLE.key?(params[:sort]) ? params[:sort] : "time"
  @sort_direction = params[:direction] == "asc" ? "asc" : "desc"
  scope = scope.reorder(Arel.sql("#{SORTABLE[@sort_column]} #{@sort_direction}"))

  @actor_options = AuditLogEntry.where.not(actor_email: nil).distinct.pluck(:actor_email).sort
  @current_actor = params[:actor]

  @audit_log_entries = set_pagination_vars(scope)
  turbo_render_index
end

#showObject



43
# File 'lib/generators/ruby_cms/templates/controllers/admin/audit_log_entries_controller.rb', line 43

def show; end