ahoy_captain 0.83 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -13
  3. data/Rakefile +23 -2
  4. data/app/assets/javascript/ahoy_captain/controllers/application_controller.js +20 -0
  5. data/app/assets/javascript/ahoy_captain/controllers/combobox_controller.js +371 -0
  6. data/app/assets/javascript/ahoy_captain/controllers/filter/item_controller.js +12 -0
  7. data/app/assets/javascript/ahoy_captain/controllers/filter_modal_controller.js +45 -0
  8. data/app/assets/javascript/ahoy_captain/controllers/frame_link_controller.js +20 -0
  9. data/app/assets/javascript/ahoy_captain/controllers/funnel_chart_controller.js +58 -16
  10. data/app/assets/javascript/ahoy_captain/controllers/interval_controller.js +5 -0
  11. data/app/assets/javascript/ahoy_captain/controllers/line_chart_controller.js +236 -22
  12. data/app/assets/javascript/ahoy_captain/controllers/map_controller.js +47 -0
  13. data/app/assets/javascript/ahoy_captain/controllers/predicate_select_controller.js +1 -1
  14. data/app/assets/javascript/ahoy_captain/controllers/properties_controller.js +8 -0
  15. data/app/assets/javascript/ahoy_captain/controllers/property_filter_controller.js +45 -0
  16. data/app/assets/javascript/ahoy_captain/controllers/realtime_controller.js +4 -2
  17. data/app/assets/javascript/ahoy_captain/controllers/tile_controller.js +33 -0
  18. data/app/assets/javascript/ahoy_captain/controllers/toggle_controller.js +17 -0
  19. data/app/assets/javascript/ahoy_captain/helpers/chart_utils.js +156 -0
  20. data/app/assets/javascript/ahoy_captain/helpers/countries.js +2261 -0
  21. data/app/assets/javascript/ahoy_captain/helpers/number_formatters.js +55 -0
  22. data/app/components/ahoy_captain/combobox_component.html.erb +33 -0
  23. data/app/components/ahoy_captain/combobox_component.rb +13 -0
  24. data/app/components/ahoy_captain/comparison_link_component.html.erb +17 -0
  25. data/app/components/ahoy_captain/comparison_link_component.rb +44 -0
  26. data/app/components/ahoy_captain/dropdown_button_component.html.erb +5 -5
  27. data/app/components/ahoy_captain/dropdown_link_component.html.erb +5 -7
  28. data/app/components/ahoy_captain/dropdown_link_component.rb +4 -0
  29. data/app/components/ahoy_captain/filter/dropdown_component.html.erb +50 -0
  30. data/app/components/ahoy_captain/filter/dropdown_component.rb +51 -0
  31. data/app/components/ahoy_captain/filter/modal_component.html.erb +7 -5
  32. data/app/components/ahoy_captain/filter/select_component.html.erb +23 -21
  33. data/app/components/ahoy_captain/filter/select_component.rb +24 -9
  34. data/app/components/ahoy_captain/filter/tag_component.html.erb +8 -4
  35. data/app/components/ahoy_captain/filter/tag_component.rb +6 -30
  36. data/app/components/ahoy_captain/filter/tag_container_component.html.erb +2 -3
  37. data/app/components/ahoy_captain/filter/tag_container_component.rb +1 -8
  38. data/app/components/ahoy_captain/previous_next_component.html.erb +8 -0
  39. data/app/components/ahoy_captain/previous_next_component.rb +11 -0
  40. data/app/components/ahoy_captain/stats/comparable_container_component.html.erb +25 -0
  41. data/app/components/ahoy_captain/stats/comparable_container_component.rb +86 -0
  42. data/app/components/ahoy_captain/stats/container_component.html.erb +15 -0
  43. data/app/components/ahoy_captain/stats/container_component.rb +26 -0
  44. data/app/components/ahoy_captain/sticky_nav_component.html.erb +28 -33
  45. data/app/components/ahoy_captain/sticky_nav_component.rb +19 -0
  46. data/app/components/ahoy_captain/table_component.html.erb +2 -2
  47. data/app/components/ahoy_captain/table_component.rb +15 -3
  48. data/app/components/ahoy_captain/tables/devices_table_component.rb +11 -0
  49. data/app/components/ahoy_captain/tables/dynamic_table.rb +13 -0
  50. data/app/components/ahoy_captain/tables/dynamic_table_component.rb +204 -0
  51. data/app/components/ahoy_captain/tables/goals_table_component.rb +17 -0
  52. data/app/components/ahoy_captain/tables/header_component.html.erb +5 -0
  53. data/app/components/ahoy_captain/tables/header_component.rb +18 -0
  54. data/app/components/ahoy_captain/tables/headers/header_component.html.erb +1 -1
  55. data/app/components/ahoy_captain/tables/headers/header_component.rb +4 -0
  56. data/app/components/ahoy_captain/tables/properties_table_component.rb +27 -0
  57. data/app/components/ahoy_captain/tables/row_component.html.erb +4 -0
  58. data/app/components/ahoy_captain/tables/rows/row_component.rb +2 -3
  59. data/app/components/ahoy_captain/tile_component.html.erb +21 -10
  60. data/app/components/ahoy_captain/tile_component.rb +10 -2
  61. data/app/components/ahoy_captain/tooltip_component.html.erb +2 -2
  62. data/app/controllers/ahoy_captain/application_controller.rb +7 -16
  63. data/app/controllers/ahoy_captain/exports_controller.rb +1 -2
  64. data/app/controllers/ahoy_captain/filters/base_controller.rb +1 -3
  65. data/app/controllers/ahoy_captain/filters/goals_controller.rb +9 -0
  66. data/app/controllers/ahoy_captain/filters/pages/actions_controller.rb +1 -1
  67. data/app/controllers/ahoy_captain/filters/pages/entry_pages_controller.rb +1 -1
  68. data/app/controllers/ahoy_captain/filters/pages/exit_pages_controller.rb +1 -1
  69. data/app/controllers/ahoy_captain/filters/properties/values_controller.rb +4 -4
  70. data/app/controllers/ahoy_captain/filters/sources_controller.rb +1 -1
  71. data/app/controllers/ahoy_captain/filters/utms_controller.rb +1 -1
  72. data/app/controllers/ahoy_captain/locations/cities_controller.rb +22 -0
  73. data/app/controllers/ahoy_captain/locations/countries_controller.rb +22 -0
  74. data/app/controllers/ahoy_captain/locations/maps_controller.rb +24 -0
  75. data/app/controllers/ahoy_captain/locations/regions_controller.rb +22 -0
  76. data/app/controllers/ahoy_captain/properties_controller.rb +41 -0
  77. data/app/controllers/ahoy_captain/stats/base_controller.rb +86 -5
  78. data/app/controllers/ahoy_captain/stats/bounce_rates_controller.rb +1 -1
  79. data/app/controllers/ahoy_captain/stats/total_pageviews_controller.rb +1 -1
  80. data/app/controllers/ahoy_captain/stats/total_visits_controller.rb +1 -1
  81. data/app/controllers/ahoy_captain/stats/unique_visitors_controller.rb +2 -1
  82. data/app/controllers/ahoy_captain/stats/views_per_visits_controller.rb +1 -10
  83. data/app/controllers/ahoy_captain/stats/visit_durations_controller.rb +1 -1
  84. data/app/helpers/ahoy_captain/application_helper.rb +60 -3
  85. data/app/models/ahoy_captain/comparison_mode.rb +72 -0
  86. data/app/models/ahoy_captain/filter_parser.rb +82 -0
  87. data/app/models/ahoy_captain/range_from_params.rb +78 -0
  88. data/app/models/ahoy_captain/rangeable.rb +0 -3
  89. data/app/models/concerns/ahoy_captain/compare_mode.rb +19 -0
  90. data/app/models/concerns/ahoy_captain/limitable.rb +17 -0
  91. data/app/models/concerns/ahoy_captain/range_options.rb +1 -14
  92. data/app/presenters/ahoy_captain/dashboard_presenter.rb +18 -54
  93. data/app/presenters/ahoy_captain/goals_presenter.rb +3 -2
  94. data/app/queries/ahoy_captain/application_query.rb +74 -10
  95. data/app/queries/ahoy_captain/event_query.rb +7 -2
  96. data/app/queries/ahoy_captain/stats/average_views_per_visit_query.rb +11 -4
  97. data/app/queries/ahoy_captain/stats/average_visit_duration_query.rb +14 -2
  98. data/app/queries/ahoy_captain/stats/base_query.rb +18 -0
  99. data/app/queries/ahoy_captain/stats/bounce_rates_query.rb +15 -1
  100. data/app/queries/ahoy_captain/stats/total_pageviews_query.rb +2 -2
  101. data/app/queries/ahoy_captain/stats/total_visitors_query.rb +1 -1
  102. data/app/queries/ahoy_captain/stats/unique_visitors_query.rb +1 -1
  103. data/app/queries/ahoy_captain/stats/views_per_visit_query.rb +1 -1
  104. data/app/queries/ahoy_captain/stats/visit_duration_query.rb +3 -3
  105. data/app/queries/ahoy_captain/visit_query.rb +1 -2
  106. data/app/queries/concerns/ahoy_captain/comparable_queries.rb +25 -0
  107. data/app/queries/concerns/ahoy_captain/comparable_query.rb +138 -0
  108. data/app/queries/concerns/ahoy_captain/lazy_comparable_query.rb +42 -0
  109. data/app/views/ahoy_captain/devices/_table.html.erb +1 -4
  110. data/app/views/ahoy_captain/funnels/show.html.erb +5 -2
  111. data/app/views/ahoy_captain/goals/index.html.erb +1 -4
  112. data/app/views/ahoy_captain/layouts/application.html.erb +3 -4
  113. data/app/views/ahoy_captain/layouts/shared/_tile_loader.html.erb +12 -0
  114. data/app/views/ahoy_captain/locations/maps/show.html.erb +3 -0
  115. data/app/views/ahoy_captain/properties/_form.html.erb +6 -0
  116. data/app/views/ahoy_captain/properties/index.html.erb +3 -0
  117. data/app/views/ahoy_captain/properties/show.html.erb +6 -0
  118. data/app/views/ahoy_captain/realtimes/show.html.erb +1 -1
  119. data/app/views/ahoy_captain/roots/_filters.html.erb +80 -0
  120. data/app/views/ahoy_captain/roots/show.html.erb +113 -122
  121. data/app/views/ahoy_captain/stats/base/index.html.erb +37 -8
  122. data/app/views/ahoy_captain/stats/show.html.erb +14 -56
  123. data/config/routes.rb +9 -3
  124. data/lib/ahoy_captain/ahoy/event_methods.rb +21 -14
  125. data/lib/ahoy_captain/ahoy/visit_methods.rb +1 -1
  126. data/lib/ahoy_captain/configuration.rb +18 -7
  127. data/lib/ahoy_captain/engine.rb +21 -0
  128. data/lib/ahoy_captain/filter_configuration/filter.rb +16 -0
  129. data/lib/ahoy_captain/filter_configuration/filter_collection.rb +48 -0
  130. data/lib/ahoy_captain/filters_configuration.rb +77 -0
  131. data/lib/ahoy_captain/goals.rb +1 -1
  132. data/lib/ahoy_captain/predicate_label.rb +7 -0
  133. data/lib/ahoy_captain/version.rb +1 -1
  134. data/lib/ahoy_captain.rb +8 -1
  135. data/lib/generators/ahoy_captain/templates/config.rb.tt +32 -0
  136. metadata +149 -22
  137. data/app/assets/javascript/ahoy_captain/controllers/active_links_controller.js +0 -15
  138. data/app/assets/javascript/ahoy_captain/controllers/filter_tag_controller.js +0 -20
  139. data/app/assets/javascript/ahoy_captain/controllers/search_select_controller.js +0 -65
  140. data/app/components/ahoy_captain/tables/headers/devices_header_component.html.erb +0 -3
  141. data/app/components/ahoy_captain/tables/headers/devices_header_component.rb +0 -9
  142. data/app/components/ahoy_captain/tables/headers/goals_header_component.html.erb +0 -6
  143. data/app/components/ahoy_captain/tables/headers/goals_header_component.rb +0 -9
  144. data/app/components/ahoy_captain/tables/rows/devices_row_component.html.erb +0 -5
  145. data/app/components/ahoy_captain/tables/rows/devices_row_component.rb +0 -12
  146. data/app/components/ahoy_captain/tables/rows/goals_row_component.html.erb +0 -11
  147. data/app/components/ahoy_captain/tables/rows/goals_row_component.rb +0 -12
  148. data/app/controllers/ahoy_captain/cities_controller.rb +0 -20
  149. data/app/controllers/ahoy_captain/countries_controller.rb +0 -20
  150. data/app/controllers/ahoy_captain/regions_controller.rb +0 -20
  151. /data/app/views/ahoy_captain/{cities → locations/cities}/index.html+details.erb +0 -0
  152. /data/app/views/ahoy_captain/{cities → locations/cities}/index.html.erb +0 -0
  153. /data/app/views/ahoy_captain/{countries → locations/countries}/index.html+details.erb +0 -0
  154. /data/app/views/ahoy_captain/{countries → locations/countries}/index.html.erb +0 -0
  155. /data/app/views/ahoy_captain/{regions → locations/regions}/index.html+details.erb +0 -0
  156. /data/app/views/ahoy_captain/{regions → locations/regions}/index.html.erb +0 -0
@@ -1,6 +1,5 @@
1
1
  module AhoyCaptain
2
2
  class VisitQuery < ApplicationQuery
3
- include Rangeable
4
3
 
5
4
  def build
6
5
  shared_context = Ransack::Context.for(AhoyCaptain.visit)
@@ -9,7 +8,7 @@ module AhoyCaptain
9
8
  ransack_params_for(:visit).reject { |k,v| k.start_with?("events_") }, context: shared_context
10
9
  )
11
10
  search_children = AhoyCaptain.event.ransack(
12
- ransack_params_for(:event).reject { |k,v| k.start_with?("visit_") }.transform_keys { |key| "events_#{key}" }, context: shared_context
11
+ ransack_params_for(:event).reject { |k,v| k.start_with?("visit_") || k == :c }.transform_keys { |key| "events_#{key}" }, context: shared_context
13
12
  )
14
13
 
15
14
  shared_conditions = [search_parents, search_children].map { |search|
@@ -0,0 +1,25 @@
1
+ module AhoyCaptain
2
+ module ComparableQueries
3
+ def compare_range
4
+ @compare_range ||= begin
5
+ ComparisonMode.new(@params).compared_to_range
6
+ end
7
+ end
8
+
9
+ def range
10
+ @range ||= @query.send(:range)
11
+ end
12
+
13
+ def comparison_params
14
+ params = @params.deep_dup
15
+ params.delete("period")
16
+
17
+ params[:start_date] = compare_range[0]
18
+ params[:end_date] = compare_range[1]
19
+ params
20
+ end
21
+ end
22
+ end
23
+
24
+ require_relative './lazy_comparable_query'
25
+ require_relative './comparable_query'
@@ -0,0 +1,138 @@
1
+ module AhoyCaptain
2
+ module ComparableQuery
3
+ class Comparison
4
+ class ComparisonResult
5
+ attr_reader :current, :compared_to
6
+ def initialize(current, compared_to)
7
+ @current = current
8
+ @compared_to = compared_to
9
+ end
10
+ end
11
+
12
+ def initialize(query)
13
+ @query = query
14
+ @params = @query.params.deep_dup
15
+ @compare = @query.class.call(comparison_params)
16
+ @model = @query.all.klass
17
+ @query_class = @query.class
18
+ end
19
+
20
+ def count(column_name = :id)
21
+ @operation = :count
22
+ @column = column_name
23
+ perform_calculations(:count, column_name)
24
+
25
+ self
26
+ end
27
+
28
+ def average(column_name)
29
+ @operation = :average
30
+ @column = column_name
31
+
32
+ perform_calculations(:average, column_name)
33
+
34
+ self
35
+ end
36
+
37
+ def perform_calculations(operation, column_name)
38
+ @query = perform_calculation(@query, operation, column_name)
39
+ @compare = perform_calculation(@compare, operation, column_name)
40
+ end
41
+
42
+ def perform_calculation(q, operation, column_name)
43
+ operation = operation.to_s.downcase
44
+ # If #count is used with #distinct (i.e. `relation.distinct.count`) it is
45
+ # considered distinct.
46
+ distinct = q.send(:distinct_value)
47
+
48
+ if operation == "count"
49
+ column_name ||= q.send(:select_for_count)
50
+ if column_name == :all
51
+ if !distinct
52
+ distinct = q.send(:distinct_select?, :select_for_count) if q.group_values.empty?
53
+ elsif q.send(:group_values).any? || q.send(:select_values).empty? && q.order_values.empty?
54
+ column_name = q.primary_key
55
+ end
56
+ elsif q.all.send(:distinct_select?, column_name)
57
+ distinct = nil
58
+ end
59
+ end
60
+
61
+ if q.group_values.any?
62
+ raise "use a subquery"
63
+ else
64
+ execute_simple_calculation(q, operation, column_name, distinct)
65
+ end
66
+ end
67
+
68
+ def result
69
+ result = @model.with(
70
+ current: @query.to_sql,
71
+ compare: @compare.to_sql
72
+ ).select("current, compare").from("current, compare")[0]
73
+ type = @query_class.cast_type(@column)
74
+
75
+ if result
76
+ current = @query_class.cast_value(type, result.current[1...-1])
77
+ compare = @query_class.cast_value(type, result.compare[1...-1])
78
+ else
79
+ current = @query_class.cast_value(type, '0')
80
+ compare = @query_class.cast_value(type, '0')
81
+ end
82
+
83
+ @result = ComparisonResult.new((current), (compare))
84
+ end
85
+
86
+ def compare_range
87
+ @compare_range ||= begin
88
+ og_range = range
89
+ [og_range[0] - (og_range[1] - og_range[0]), og_range[0]]
90
+ end
91
+
92
+ end
93
+
94
+ def range
95
+ @range ||= @query.send(:range)
96
+ end
97
+
98
+ private
99
+
100
+ def execute_simple_calculation(q, operation, column_name, distinct) # :nodoc:
101
+ if operation == "count" && (column_name == :all && distinct || q.has_limit_or_offset?)
102
+ # Shortcut when limit is zero.
103
+ return 0 if q.limit_value == 0
104
+
105
+ q.send(:build_count_subquery, q.spawn, column_name, distinct)
106
+ else
107
+ # PostgreSQL doesn't like ORDER BY when there are no GROUP BY
108
+ relation = q.all.unscope(:order).distinct!(false)
109
+
110
+ column = q.all.send(:aggregate_column, column_name)
111
+ select_value = q.all.send(:operation_over_aggregate_column, column, operation, distinct)
112
+ select_value.distinct = true if operation == "sum" && distinct
113
+
114
+ relation.select_values = [select_value]
115
+
116
+ relation.arel
117
+ end
118
+ end
119
+
120
+ def comparison_params
121
+ params = @params.deep_dup
122
+ params.delete("period")
123
+
124
+ params[:start_date] = compare_range[0]
125
+ params[:end_date] = compare_range[1]
126
+ params
127
+ end
128
+ end
129
+
130
+ def with_comparison(enabled = false)
131
+ if enabled
132
+ Comparison.new(self)
133
+ else
134
+ self
135
+ end
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,42 @@
1
+ module AhoyCaptain
2
+ module LazyComparableQuery
3
+ class LazyComparison
4
+ class LazyComparisonResult
5
+ attr_accessor :current, :compared_to
6
+ end
7
+
8
+ include ::AhoyCaptain::ComparableQueries
9
+
10
+ def initialize(query)
11
+ @query = query
12
+ @params = @query.params.deep_dup
13
+ @compare = @query.class.call(comparison_params)
14
+ end
15
+
16
+ def method_missing(name, *args)
17
+ perform_operations(name, *args)
18
+ end
19
+
20
+ def perform_operations(name, *args)
21
+ @query = @query.public_send(name, *args)
22
+ @compare = @compare.public_send(name, *args)
23
+
24
+ self
25
+ end
26
+
27
+ def result
28
+ return @result if @result
29
+
30
+ @result = LazyComparisonResult.new.tap { |comparison| comparison.current = @query; comparison.compared_to = @compare }
31
+ end
32
+ end
33
+
34
+ def with_lazy_comparison(enabled = false)
35
+ if enabled
36
+ LazyComparison.new(self)
37
+ else
38
+ self
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,5 +1,2 @@
1
1
  <%= render AhoyCaptain::TableComponent.new(items: @devices,
2
- category_name: 'Devices',
3
- unit_name: 'Visitors',
4
- header: ::AhoyCaptain::Tables::Headers::DevicesHeaderComponent,
5
- row: ::AhoyCaptain::Tables::Rows::DevicesRowComponent) %>
2
+ table: ::AhoyCaptain::Tables::DevicesTableComponent) %>
@@ -1,6 +1,9 @@
1
1
  <%= turbo_frame_tag :goals do %>
2
2
  <div >
3
- <canvas data-controller="funnel-chart" data-data="<%= @funnel.to_json %>" ></canvas>
4
-
3
+ <% if params.dig(:q, :goal_id) %>
4
+ <p>Funnels are unavailable if filtering by a goal.</p>
5
+ <% else %>
6
+ <canvas data-controller="funnel-chart" data-data="<%= @funnel.to_json %>" ></canvas>
7
+ <% end %>
5
8
  </div>
6
9
  <% end %>
@@ -1,7 +1,4 @@
1
1
  <%= turbo_frame_tag :goals do %>
2
2
  <%= render AhoyCaptain::TableComponent.new(items: @presenter.goals,
3
- header: ::AhoyCaptain::Tables::Headers::GoalsHeaderComponent,
4
- row: ::AhoyCaptain::Tables::Rows::GoalsRowComponent) %>
5
-
6
-
3
+ table: ::AhoyCaptain::Tables::GoalsTableComponent) %>
7
4
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE html>
2
- <html>
2
+ <html data-theme='<%= AhoyCaptain.config.theme %>'>
3
3
  <head>
4
4
  <title>Ahoy Captain</title>
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
@@ -21,7 +21,6 @@
21
21
  <meta name="theme-color" content="#ffffff">
22
22
  <link href="https://cdn.jsdelivr.net/npm/daisyui@3.5.0/dist/full.css" rel="stylesheet" type="text/css"/>
23
23
  <script src="https://cdn.tailwindcss.com"></script>
24
- <link href="https://unpkg.com/slim-select@latest/dist/slimselect.css" rel="stylesheet" />
25
24
  <%= ahoy_captain_importmap_tags %>
26
25
  <style>
27
26
  /* Application styles */
@@ -116,9 +115,9 @@
116
115
  </style>
117
116
  </head>
118
117
 
119
- <body data-theme='<%= AhoyCaptain.config.theme %>' class='bg-base-300' data-controller='application'>
118
+ <body data-controller='application'>
120
119
  <%= yield %>
121
- <div class="flex justify-center bg-base-300 border-t-4 border-base-100 py-4">
120
+ <div class="flex justify-center border-t-4 border-base-100 py-4">
122
121
  <div class="flex justify-around space-x-4 my-4">
123
122
  <h5>Powered by <a href='https://github.com/joshmn/ahoy_captain' target=”_blank”>Ahoy Captain v<%= AhoyCaptain::VERSION %></a></h5>
124
123
  </div>
@@ -0,0 +1,12 @@
1
+ <div class="mt-5" >
2
+ <div role="status" class="animate-pulse">
3
+ <div class="flex justify-between w-full mb-2">
4
+ <div class="h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 w-32"></div>
5
+ <div class="h-2.5 bg-gray-300 rounded-full dark:bg-gray-600 w-24"></div>
6
+ </div>
7
+ <% 10.times do |i| %>
8
+ <div class="h-6 bg-gray-200 dark:bg-gray-700 max-w-[<%= 100 - (i * 10) %>%] mb-2.5"></div>
9
+ <% end %>
10
+ <span class="sr-only">Loading...</span>
11
+ </div>
12
+ </div>
@@ -0,0 +1,3 @@
1
+ <%= turbo_frame_tag :geography do %>
2
+ <canvas style="position: relative; width: 500px; height: 300px;" data-controller="map" data-map-data-value="<%= @countries.to_json %>"></canvas>
3
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <select class="select text-accent select-sm w-full max-w-sm" data-controller="properties" data-action="change->properties#handleChange">
2
+ <option></option>
3
+ <% @options.each do |key, value| %>
4
+ <option value="<%= property_path(id: key) %>" <%= 'selected' if local_assigns[:selected] == value %>><%= value %></option>
5
+ <% end %>
6
+ </select>
@@ -0,0 +1,3 @@
1
+ <%= turbo_frame_tag :goals do %>
2
+ <%= render 'ahoy_captain/properties/form' %>
3
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <%= turbo_frame_tag :goals do %>
2
+ <%= render 'ahoy_captain/properties/form', selected: Base64.strict_decode64(params[:id]) %>
3
+
4
+ <%= render AhoyCaptain::TableComponent.new(items: @properties,
5
+ table: ::AhoyCaptain::Tables::PropertiesTableComponent) %>
6
+ <% end %>
@@ -1,6 +1,6 @@
1
1
  <%= turbo_frame_tag :realtime do %>
2
2
  <div>
3
- <a class="block ml-1 md:ml-2 mr-auto text-xs md:text-sm font-bold text-base-content dark:text-base-content" title="" data-realtime-target="label">
3
+ <a class="block ml-1 md:ml-2 mr-auto text-xs md:text-sm font-bold " title="" data-realtime-target="label">
4
4
  <svg class="inline w-2 mr-1 md:mr-2 text-green-500 fill-current animate-pulse" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
5
5
  <circle cx="8" cy="8" r="8"></circle>
6
6
  </svg><%= @total %> <span class="hidden sm:inline-block">current visitors</span>
@@ -0,0 +1,80 @@
1
+ <%= form_with url: url_for(params.permit!.except(:q)), method: :get, data: { turbo_frame: "_top", controller: "filter-form", action: "reset->filter-form#handleReset" } do |form| %>
2
+ <% non_filter_ransack_params.each do |k,v| %>
3
+ <%= form.hidden_field k, value: v %>
4
+ <% end %>
5
+ <% AhoyCaptain.config.filters.each do |name, filters| %>
6
+ <%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by #{name}", id: "#{filters.modal_name}") do |modal| %>
7
+ <% modal.with_modal_display do %>
8
+ <% filters.each do |filter| %>
9
+ <%= render AhoyCaptain::Filter::SelectComponent.new(label: filter.label, column: filter.column, url: public_send(filter.url), predicates: filter.predicates, multiple: filter.multiple, form: form) %>
10
+ <% end %>
11
+ <% end %>
12
+ <% end %>
13
+ <% end %>
14
+
15
+ <%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Custom Property", id: "customPropertyFilterModal") do |modal| %>
16
+ <% modal.with_modal_display do %>
17
+ <div data-controller="property-filter">
18
+ <fieldset class="flex space-x-4 items-end">
19
+ <% if current_property_filter %>
20
+ <%= render ::AhoyCaptain::ComboboxComponent.new(name: "", multiple: false, column: "", url: filters_properties_names_path, value: [current_property_filter[:key].delete_prefix("properties.")], select_html: { "data-property-filter-target" => 'name', id: "property-name" }) %>
21
+ <% else %>
22
+ <%= render ::AhoyCaptain::ComboboxComponent.new(name: "", multiple: false, column: "", url: filters_properties_names_path, select_html: { "data-property-filter-target" => 'name', id: "property-name" } ) %>
23
+ <% end %>
24
+
25
+ <div class="flex flex-col w-[20%]">
26
+ <select class='select select-primary bg-gray-900 ring-0 focus-within:ring-0 focus-within:ring-0 focus:ring-0 focus:outline-none inline-flex justify-between items-center w-full rounded-md border px-4 py-2 text-sm'>
27
+ <option value="in">in</option>
28
+ </select>
29
+ </div>
30
+
31
+ <% if current_property_filter %>
32
+ <%= render ::AhoyCaptain::ComboboxComponent.new(name: "q[#{current_property_filter[:key]}_in]", multiple: false, column: "", url: filters_properties_values_path, value: [current_property_filter[:value]], select_html: { "data-property-filter-target" => 'value', id: "property-value" } ) %>
33
+ <% else %>
34
+ <%= render ::AhoyCaptain::ComboboxComponent.new(name: "", multiple: false, column: "", url: filters_properties_values_path, select_html: { "data-property-filter-target" => 'value', id: "property-value" }, disabled: true) %>
35
+ <% end %>
36
+
37
+ </fieldset>
38
+
39
+ </div>
40
+ <% end %>
41
+ <% end %>
42
+
43
+ <%= render AhoyCaptain::Filter::ModalComponent.new(title: "Custom Range", id: "customRangeModal") do |modal| %>
44
+ <% modal.with_modal_display do %>
45
+ <div class="flex gap-2 w-full">
46
+ <div class="form-control w-full max-w-xs">
47
+ <label class="label" for="start_date">
48
+ <span class="label-text">Start Date</span>
49
+ </label>
50
+ <input type="datetime-local" id="start_date" name="start_date" class="input input-bordered w-full" value="<%= params[:start_date] %>" />
51
+ </div>
52
+ <div class="form-control w-full max-w-xs">
53
+ <label class="label" for="end_date">
54
+ <span class="label-text">End Date</span>
55
+ </label>
56
+ <input type="datetime-local" id="end_date" name="end_date" class="input input-bordered w-full" value="<%= params[:end_date] %>" />
57
+ </div>
58
+ </div>
59
+ <% end %>
60
+ <% end %>
61
+
62
+ <%= render AhoyCaptain::Filter::ModalComponent.new(title: "Custom Comparison", id: "customComparisonModal") do |modal| %>
63
+ <% modal.with_modal_display do %>
64
+ <div class="flex gap-2 w-full">
65
+ <div class="form-control w-full max-w-xs">
66
+ <label class="label" for="start_date">
67
+ <span class="label-text">Start Date</span>
68
+ </label>
69
+ <input type="datetime-local" id="start_date" name="compare_to_start_date" class="input input-bordered w-full" value="<%= params[:compare_to_start_date] %>" />
70
+ </div>
71
+ <div class="form-control w-full max-w-xs">
72
+ <label class="label" for="end_date">
73
+ <span class="label-text">End Date</span>
74
+ </label>
75
+ <input type="datetime-local" id="end_date" name="compare_to_end_date" class="input input-bordered w-full" value="<%= params[:compare_to_end_date] %>" />
76
+ </div>
77
+ </div>
78
+ <% end %>
79
+ <% end %>
80
+ <% end %>