Class: ActionTrace::ActivityLogsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/action_trace/activity_logs_controller.rb

Instance Method Summary collapse

Instance Method Details

#filterObject



35
36
37
38
39
40
41
42
# File 'app/controllers/action_trace/activity_logs_controller.rb', line 35

def filter
  session[:activity_logs_filters] = if params[:reset].present?
                                      {}
                                    else
                                      params[:filters]
                                    end
  redirect_to activity_logs_path
end

#indexObject

Uncomment and adapt to your authentication/authorization setup. Run ‘rails generate action_trace:views –controller` to copy this file into your app.

before_action :authenticate_user! # Devise load_and_authorize_resource # CanCanCan



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/action_trace/activity_logs_controller.rb', line 11

def index
  @filters = session[:activity_logs_filters] || {}

  result = ActionTrace::FetchActivityLogs.call(
    filters: @filters,
    current_user: current_user,
    range: params[:range] || 0
  )

  if result.success?
    @activity_logs = result.activity_logs
    @activity_logs_count = result.total_count
  else
    flash.now[:error] = result.message
    @activity_logs = []
    @activity_logs_count = 0
  end

  return unless request.xhr?

  response.headers['Cache-Control'] = 'no-store'
  render partial: 'index'
end