Class: Admin::VisitorErrorsController
Constant Summary
AdminPagination::DEFAULT_MAX_PER_PAGE, AdminPagination::DEFAULT_MIN_PER_PAGE
Instance Method Summary
collapse
#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
#paginate_collection, #set_pagination_vars
Instance Method Details
#bulk_delete ⇒ Object
73
74
75
76
77
|
# File 'lib/generators/ruby_cms/templates/controllers/admin/visitor_errors_controller.rb', line 73
def bulk_delete
count = bulk_destroy(VisitorError, audit: :visitor_error_deleted, target_label: "VisitorError", soft: true)
redirect_to admin_visitor_errors_path,
notice: t("ruby_cms.admin.visitor_errors.bulk_deleted", count:)
end
|
#bulk_mark_as_resolved ⇒ Object
79
80
81
82
83
|
# File 'lib/generators/ruby_cms/templates/controllers/admin/visitor_errors_controller.rb', line 79
def bulk_mark_as_resolved
count = bulk_update(VisitorError, { resolved: true }, audit: :visitor_error_resolved, target_label: "VisitorError")
redirect_to admin_visitor_errors_path,
notice: t("ruby_cms.admin.visitor_errors.bulk_resolved", count:)
end
|
#bulk_mark_as_unresolved ⇒ Object
85
86
87
88
89
|
# File 'lib/generators/ruby_cms/templates/controllers/admin/visitor_errors_controller.rb', line 85
def bulk_mark_as_unresolved
count = bulk_update(VisitorError, { resolved: false }, audit: :visitor_error_unresolved, target_label: "VisitorError")
redirect_to admin_visitor_errors_path,
notice: t("ruby_cms.admin.visitor_errors.bulk_unresolved", default: "#{count} fout(en) heropend", count: count)
end
|
#index ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/generators/ruby_cms/templates/controllers/admin/visitor_errors_controller.rb', line 15
def index
by_resolved = VisitorError.group(:resolved).count
open_count = by_resolved[false].to_i
resolved_count = by_resolved[true].to_i
@filter_counts = {
all: open_count + resolved_count,
open: open_count,
resolved: resolved_count
}
@current_filter = %w[all open resolved].include?(params[:filter]) ? params[:filter] : "all"
scope = VisitorError.recent
case @current_filter
when "open" then scope = scope.where(resolved: false)
when "resolved" then scope = scope.where(resolved: true)
end
if params[:resolved].present? && params[:filter].blank?
scope = scope.where(resolved: params[:resolved] == "true")
@current_filter = params[:resolved] == "true" ? "resolved" : "open"
end
scope = apply_search_filter(scope)
scope = apply_error_type_filter(scope)
@sort_column = %w[time page error status].include?(params[:sort]) ? params[:sort] : "time"
@sort_direction = params[:direction] == "asc" ? "asc" : "desc"
sort_db_column = {
"time" => "created_at",
"page" => "request_path",
"error" => "error_class",
"status" => "resolved"
}[@sort_column]
scope = scope.reorder(Arel.sql("#{sort_db_column} #{@sort_direction}"))
@visitor_errors = (scope)
turbo_render_index
end
|
#resolve ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/generators/ruby_cms/templates/controllers/admin/visitor_errors_controller.rb', line 57
def resolve
@visitor_error.resolve!
@visitor_error.save!
audit!(:visitor_error_resolved, target: @visitor_error, summary: "Resolved #{@visitor_error.error_class} on #{@visitor_error.request_path}")
redirect_to admin_visitor_errors_path,
notice: t("ruby_cms.admin.visitor_errors.resolved")
end
|
#show ⇒ Object
55
|
# File 'lib/generators/ruby_cms/templates/controllers/admin/visitor_errors_controller.rb', line 55
def show; end
|
#unresolve ⇒ Object
65
66
67
68
69
70
71
|
# File 'lib/generators/ruby_cms/templates/controllers/admin/visitor_errors_controller.rb', line 65
def unresolve
@visitor_error.reopen!
@visitor_error.save!
audit!(:visitor_error_unresolved, target: @visitor_error, summary: "Reopened #{@visitor_error.error_class} on #{@visitor_error.request_path}")
redirect_to admin_visitor_errors_path,
notice: t("ruby_cms.admin.visitor_errors.unresolved", default: "Markeer als open")
end
|