Class: RailsPulse::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Includes:
PaginationConcern, SessionFiltersConcern
Defined in:
app/controllers/rails_pulse/application_controller.rb

Instance Method Summary collapse

Methods included from PaginationConcern

#set_pagination_limit

Instance Method Details

#set_global_filtersObject



9
10
11
12
13
14
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
# File 'app/controllers/rails_pulse/application_controller.rb', line 9

def set_global_filters
  if params[:clear] == "true"
    session.delete(:global_filters)
    session[:show_non_tagged] = true  # Reset show_non_tagged to default
  else
    filters = session[:global_filters] || {}

    # Update time filters if provided
    if params[:start_time].present? && params[:end_time].present?
      filters["start_time"] = params[:start_time]
      filters["end_time"] = params[:end_time]
    end

    # Update performance threshold if provided (or remove if empty)
    if params[:performance_threshold].present?
      filters["performance_threshold"] = params[:performance_threshold]
    else
      filters.delete("performance_threshold")
    end

    # Update tag visibility - convert enabled tags to disabled tags
    all_tags = RailsPulse.configuration.tags
    enabled_tags = params[:enabled_tags] || []

    # Handle "non_tagged" separately
    session[:show_non_tagged] = enabled_tags.include?("non_tagged")
    enabled_tags = enabled_tags - [ "non_tagged" ]

    disabled_tags = all_tags - enabled_tags

    if disabled_tags.any?
      filters["disabled_tags"] = disabled_tags
    else
      filters.delete("disabled_tags")
    end

    session[:global_filters] = filters
  end

  # Redirect back to the referring page or root
  redirect_back(fallback_location: root_path)
end

#set_time_rangeObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/controllers/rails_pulse/application_controller.rb', line 52

def set_time_range
  if params[:preset].present?
    # Store preset selection
    session[:time_range_preference] = params[:preset]
  elsif params[:start_time].present? && params[:end_time].present?
    # Store custom range
    session[:time_range_preference] = {
      type: "custom",
      start_time: params[:start_time],
      end_time: params[:end_time]
    }
  end

  # Redirect back to the referring page or root
  redirect_back(fallback_location: root_path)
end