karafka-web 0.10.1 → 0.10.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +2 -1
  3. data/CHANGELOG.md +15 -1
  4. data/Gemfile.lock +13 -11
  5. data/config/locales/pro_errors.yml +7 -1
  6. data/docker-compose.yml +1 -1
  7. data/karafka-web.gemspec +10 -2
  8. data/lib/karafka/web/pro/commanding/commands/{probe.rb → trace.rb} +3 -3
  9. data/lib/karafka/web/pro/commanding/listener.rb +1 -1
  10. data/lib/karafka/web/pro/commanding/manager.rb +2 -2
  11. data/lib/karafka/web/pro/commanding.rb +1 -1
  12. data/lib/karafka/web/pro/loader.rb +4 -2
  13. data/lib/karafka/web/pro/ui/app.rb +47 -2
  14. data/lib/karafka/web/pro/ui/controllers/commanding_controller.rb +4 -4
  15. data/lib/karafka/web/pro/ui/controllers/routing_controller.rb +18 -1
  16. data/lib/karafka/web/pro/ui/controllers/scheduled_messages/base_controller.rb +29 -0
  17. data/lib/karafka/web/pro/ui/controllers/scheduled_messages/explorer_controller.rb +65 -0
  18. data/lib/karafka/web/pro/ui/controllers/scheduled_messages/messages_controller.rb +60 -0
  19. data/lib/karafka/web/pro/ui/controllers/scheduled_messages/schedules_controller.rb +84 -0
  20. data/lib/karafka/web/pro/ui/lib/branding/config.rb +40 -0
  21. data/lib/karafka/web/pro/ui/lib/branding/contracts/config.rb +56 -0
  22. data/lib/karafka/web/pro/ui/lib/branding.rb +36 -0
  23. data/lib/karafka/web/pro/ui/views/commands/_command.erb +1 -1
  24. data/lib/karafka/web/pro/ui/views/consumers/_consumer_controls.erb +3 -3
  25. data/lib/karafka/web/pro/ui/views/consumers/consumer/_commands.erb +4 -4
  26. data/lib/karafka/web/pro/ui/views/explorer/_partition_option.erb +10 -2
  27. data/lib/karafka/web/pro/ui/views/recurring_tasks/_actions.erb +2 -2
  28. data/lib/karafka/web/pro/ui/views/recurring_tasks/_not_active.erb +1 -1
  29. data/lib/karafka/web/pro/ui/views/routing/_consumer_group.erb +2 -0
  30. data/lib/karafka/web/pro/ui/views/routing/_topic.erb +10 -0
  31. data/lib/karafka/web/pro/ui/views/scheduled_messages/explorer/_breadcrumbs.erb +30 -0
  32. data/lib/karafka/web/pro/ui/views/scheduled_messages/explorer/_key.erb +9 -0
  33. data/lib/karafka/web/pro/ui/views/scheduled_messages/explorer/_message.erb +122 -0
  34. data/lib/karafka/web/pro/ui/views/scheduled_messages/explorer/_messages.erb +28 -0
  35. data/lib/karafka/web/pro/ui/views/scheduled_messages/explorer/partition.erb +72 -0
  36. data/lib/karafka/web/pro/ui/views/scheduled_messages/explorer/topic.erb +33 -0
  37. data/lib/karafka/web/pro/ui/views/scheduled_messages/schedules/_breadcrumbs.erb +21 -0
  38. data/lib/karafka/web/pro/ui/views/scheduled_messages/schedules/_no_groups.erb +11 -0
  39. data/lib/karafka/web/pro/ui/views/scheduled_messages/schedules/index.erb +38 -0
  40. data/lib/karafka/web/pro/ui/views/scheduled_messages/schedules/show.erb +48 -0
  41. data/lib/karafka/web/pro/ui/views/search/_breadcrumbs.erb +1 -0
  42. data/lib/karafka/web/pro/ui/views/shared/_navigation.erb +29 -14
  43. data/lib/karafka/web/pro/ui/views/shared/branding/_label.erb +20 -0
  44. data/lib/karafka/web/pro/ui/views/shared/branding/_notice.erb +13 -0
  45. data/lib/karafka/web/tracking/consumers/listeners/errors.rb +3 -1
  46. data/lib/karafka/web/ui/base.rb +1 -1
  47. data/lib/karafka/web/ui/controllers/base_controller.rb +18 -3
  48. data/lib/karafka/web/ui/helpers/application_helper.rb +21 -7
  49. data/lib/karafka/web/ui/helpers/paths_helper.rb +18 -0
  50. data/lib/karafka/web/ui/helpers/tailwind_helper.rb +5 -4
  51. data/lib/karafka/web/ui/models/recurring_tasks/log.rb +0 -11
  52. data/lib/karafka/web/ui/models/recurring_tasks/schedule.rb +0 -11
  53. data/lib/karafka/web/ui/models/recurring_tasks/task.rb +0 -11
  54. data/lib/karafka/web/ui/public/javascripts/application.js +1 -0
  55. data/lib/karafka/web/ui/public/javascripts/application.min.js +3 -3
  56. data/lib/karafka/web/ui/public/javascripts/application.min.js.br +0 -0
  57. data/lib/karafka/web/ui/public/javascripts/application.min.js.gz +0 -0
  58. data/lib/karafka/web/ui/public/javascripts/components/btn_toggle_manager.js +16 -6
  59. data/lib/karafka/web/ui/public/javascripts/components/live_poll.js +15 -0
  60. data/lib/karafka/web/ui/public/stylesheets/application.css +21 -0
  61. data/lib/karafka/web/ui/public/stylesheets/application.min.css +1 -1
  62. data/lib/karafka/web/ui/public/stylesheets/application.min.css.br +0 -0
  63. data/lib/karafka/web/ui/public/stylesheets/application.min.css.gz +0 -0
  64. data/lib/karafka/web/ui/public/stylesheets/libs/tailwind.css +70 -3
  65. data/lib/karafka/web/ui/views/layout.erb +5 -2
  66. data/lib/karafka/web/ui/views/shared/_brand.erb +3 -2
  67. data/lib/karafka/web/ui/views/shared/_breadcrumbs.erb +1 -1
  68. data/lib/karafka/web/ui/views/shared/_navigation.erb +28 -14
  69. data/lib/karafka/web/ui/views/shared/alerts/_error.erb +3 -1
  70. data/lib/karafka/web/ui/views/shared/alerts/_info.erb +1 -1
  71. data/lib/karafka/web/ui/views/shared/alerts/_primary.erb +3 -1
  72. data/lib/karafka/web/ui/views/shared/alerts/_secondary.erb +3 -1
  73. data/lib/karafka/web/ui/views/shared/alerts/_success.erb +3 -1
  74. data/lib/karafka/web/ui/views/shared/alerts/_warning.erb +3 -1
  75. data/lib/karafka/web/ui/views/shared/icons/_calendar.erb +3 -0
  76. data/lib/karafka/web/ui/views/shared/icons/_chevron.erb +4 -0
  77. data/lib/karafka/web/version.rb +1 -1
  78. data/package-lock.json +3 -3
  79. data.tar.gz.sig +0 -0
  80. metadata +28 -16
  81. metadata.gz.sig +0 -0
  82. data/.coditsu/ci.yml +0 -3
  83. data/.diffend.yml +0 -3
  84. data/.github/FUNDING.yml +0 -1
  85. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -50
  86. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  87. data/.github/workflows/ci.yml +0 -133
  88. data/.gitignore +0 -71
  89. data/.rspec +0 -1
  90. data/.ruby-gemset +0 -1
  91. data/.ruby-version +0 -1
@@ -1,14 +1,15 @@
1
1
  <nav class="sidebar-nav">
2
2
  <%== partial 'shared/brand' %>
3
+ <%== partial 'shared/branding/label' %>
3
4
 
4
- <ul class="menu">
5
+ <ul class="menu grow">
5
6
  <li>
6
7
  <a
7
8
  class="sidebar-nav-item <%= nav_class(start_with: '/dashboard') %>"
8
9
  href="<%= root_path('dashboard') %>"
9
10
  >
10
11
  <%== icon(:home) %>
11
- Dashboard
12
+ <span class="sidebar-nav-item-label">Dashboard</span>
12
13
  </a>
13
14
  </li>
14
15
 
@@ -18,7 +19,7 @@
18
19
  href="<%= root_path('consumers') %>"
19
20
  >
20
21
  <%== icon(:cpu) %>
21
- Consumers
22
+ <span class="sidebar-nav-item-label">Consumers</span>
22
23
  </a>
23
24
  </li>
24
25
 
@@ -28,7 +29,7 @@
28
29
  href="<%= root_path('jobs/running') %>"
29
30
  >
30
31
  <%== icon(:arrow_on_squares) %>
31
- Jobs
32
+ <span class="sidebar-nav-item-label">Jobs</span>
32
33
  </a>
33
34
  </li>
34
35
 
@@ -38,7 +39,7 @@
38
39
  href="<%= root_path('health/overview') %>"
39
40
  >
40
41
  <%== icon(:heart) %>
41
- Health
42
+ <span class="sidebar-nav-item-label">Health</span>
42
43
  </a>
43
44
  </li>
44
45
 
@@ -48,7 +49,7 @@
48
49
  href="<%= root_path('routing') %>"
49
50
  >
50
51
  <%== icon(:queue_list) %>
51
- Routing
52
+ <span class="sidebar-nav-item-label">Routing</span>
52
53
  </a>
53
54
  </li>
54
55
 
@@ -58,7 +59,7 @@
58
59
  href="<%= root_path('explorer') %>"
59
60
  >
60
61
  <%== icon(:document_glass) %>
61
- Explorer
62
+ <span class="sidebar-nav-item-label">Explorer</span>
62
63
  </a>
63
64
  </li>
64
65
 
@@ -68,7 +69,17 @@
68
69
  href="<%= root_path('recurring_tasks') %>"
69
70
  >
70
71
  <%== icon(:arrow_path_rounded) %>
71
- Cron
72
+ <span class="sidebar-nav-item-label">Cron</span>
73
+ </a>
74
+ </li>
75
+
76
+ <li>
77
+ <a
78
+ class="sidebar-nav-item <%= nav_class(start_with: '/scheduled_messages') %>"
79
+ href="<%= root_path('scheduled_messages') %>"
80
+ >
81
+ <%== icon(:calendar) %>
82
+ <span class="sidebar-nav-item-label">Schedules</span>
72
83
  </a>
73
84
  </li>
74
85
 
@@ -78,7 +89,7 @@
78
89
  href="<%= root_path('errors') %>"
79
90
  >
80
91
  <%== icon(:bug) %>
81
- Errors
92
+ <span class="sidebar-nav-item-label">Errors</span>
82
93
  </a>
83
94
  </li>
84
95
 
@@ -88,7 +99,7 @@
88
99
  href="<%= root_path('dlq') %>"
89
100
  >
90
101
  <%== icon(:x_circle) %>
91
- Dead
102
+ <span class="sidebar-nav-item-label">Dead</span>
92
103
  </a>
93
104
  </li>
94
105
 
@@ -98,7 +109,7 @@
98
109
  href="<%= root_path('cluster') %>"
99
110
  >
100
111
  <%== icon(:blocks) %>
101
- Cluster
112
+ <span class="sidebar-nav-item-label">Cluster</span>
102
113
  </a>
103
114
  </li>
104
115
 
@@ -108,7 +119,7 @@
108
119
  href="<%= root_path('topics') %>"
109
120
  >
110
121
  <%== icon(:list_bullets) %>
111
- Topics
122
+ <span class="sidebar-nav-item-label">Topics</span>
112
123
  </a>
113
124
  </li>
114
125
 
@@ -118,7 +129,7 @@
118
129
  href="<%= root_path('status') %>"
119
130
  >
120
131
  <%== icon(:check_badge) %>
121
- Status
132
+ <span class="sidebar-nav-item-label">Status</span>
122
133
  </a>
123
134
  </li>
124
135
 
@@ -128,8 +139,12 @@
128
139
  href="<%= root_path('support') %>"
129
140
  >
130
141
  <%== icon(:lifebuoy) %>
131
- Support
142
+ <span class="sidebar-nav-item-label">Support</span>
132
143
  </a>
133
144
  </li>
134
145
  </ul>
146
+
147
+ <button type="button" class="btn-toggle-nav-collapsed grid gap-2 grid-flow-col items-center justify-start ml-6 text-sm invisible lg:visible" data-toggle-target="drawer-side">
148
+ <%== icon(:chevron) %>
149
+ </button>
135
150
  </nav>
@@ -0,0 +1,20 @@
1
+ <% branding_cfg = Karafka::Web.config.ui.branding %>
2
+ <% if branding_cfg.label %>
3
+ <div class="branding-label text-left mt-4 ml-6">
4
+ <%==
5
+ public_send(
6
+ :"badge_#{branding_cfg.type}",
7
+ branding_cfg.label
8
+ )
9
+ %>
10
+ </div>
11
+
12
+ <div class="branding-mark text-left mt-4 ml-6">
13
+ <%==
14
+ public_send(
15
+ :"badge_#{branding_cfg.type}",
16
+ branding_cfg.label[0]
17
+ )
18
+ %>
19
+ </div>
20
+ <% end %>
@@ -0,0 +1,13 @@
1
+ <% branding_cfg = Karafka::Web.config.ui.branding %>
2
+ <% if branding_cfg.notice %>
3
+ <div id="branding" class="col-span-12">
4
+ <div class="mb-3">
5
+ <%==
6
+ public_send(
7
+ :"alert_#{branding_cfg.type}",
8
+ branding_cfg.notice
9
+ )
10
+ %>
11
+ </div>
12
+ </div>
13
+ <% end %>
@@ -73,7 +73,9 @@ module Karafka
73
73
  partition: consumer.partition,
74
74
  first_offset: consumer.messages.metadata.first_offset,
75
75
  last_offset: consumer.messages.metadata.last_offset,
76
- committed_offset: consumer.coordinator.seek_offset - 1,
76
+ # We set it to -1000 if non-existent because after subtracting one, we will end up
77
+ # with -1001, which is "N/A" offset position for all the offsets here
78
+ committed_offset: (consumer.coordinator.seek_offset || -1_000) - 1,
77
79
  consumer: consumer.class.to_s,
78
80
  tags: consumer.tags
79
81
  }
@@ -133,7 +133,7 @@ module Karafka
133
133
  # @param query_data [Hash] query params we want to add to the current path
134
134
  path :current do |query_data = {}|
135
135
  # Merge existing request parameters with new query data
136
- merged_params = request.params.deep_merge(query_data)
136
+ merged_params = deep_merge(request.params, query_data)
137
137
 
138
138
  # Flatten the merged parameters
139
139
  flattened_params = flatten_params('', merged_params)
@@ -28,13 +28,28 @@ module Karafka
28
28
 
29
29
  # Builds the render data object with assigned attributes based on instance variables.
30
30
  #
31
+ # @param attributes [Hash] attributes coming from the outside (in case of rebind)
31
32
  # @return [Responses::Render] data that should be used to render appropriate view
32
- def render
33
- attributes = {}
33
+ def render(attributes: {})
34
+ attributes = attributes.dup
35
+
36
+ full_parts = self.class.to_s.split('::')
37
+ separator = full_parts.index('Controllers')
38
+ base = full_parts[(separator + 1)..]
39
+
40
+ base.map!.with_index do |path_part, index|
41
+ if index == (base.size - 1)
42
+ path_part.gsub(/(.)([A-Z])/, '\1_\2').downcase.gsub('_controller', '')
43
+ else
44
+ path_part.gsub(/(.)([A-Z])/, '\1_\2').downcase
45
+ end
46
+ end
34
47
 
35
- scope = self.class.to_s.split('::').last.gsub(/(.)([A-Z])/, '\1_\2').downcase.gsub('_controller', '')
48
+ scope = base.join('/')
36
49
  action = caller_locations(1, 1)[0].label.split('#').last
37
50
 
51
+ attributes[:breadcrums_scope] = scope
52
+
38
53
  instance_variables.each do |iv|
39
54
  next if iv.to_s.start_with?('@_')
40
55
  next if iv.to_s.start_with?('@params')
@@ -50,13 +50,6 @@ module Karafka
50
50
  object.to_s.include?('#<') ? object.class.to_s : object.to_s
51
51
  end
52
52
 
53
- # Renders per scope breadcrumbs
54
- def render_breadcrumbs
55
- scope = request.path.delete_prefix(root_path).split('/')[0]
56
-
57
- render "#{scope}/_breadcrumbs"
58
- end
59
-
60
53
  # Takes a status and recommends background style color
61
54
  #
62
55
  # @param status [String] status
@@ -376,6 +369,27 @@ module Karafka
376
369
  def icon(name)
377
370
  render "shared/icons/_#{name}"
378
371
  end
372
+
373
+ # Merges two hashes deeply, combining nested hashes recursively.
374
+ #
375
+ # @param hash1 [Hash] The first hash to merge.
376
+ # @param hash2 [Hash] The second hash to merge.
377
+ # @return [Hash] A new hash that is the result of a deep merge of the two provided hashes.
378
+ def deep_merge(hash1, hash2)
379
+ merged_hash = hash1.dup
380
+
381
+ hash2.each_pair do |k, v|
382
+ tv = merged_hash[k]
383
+
384
+ merged_hash[k] = if tv.is_a?(Hash) && v.is_a?(Hash)
385
+ deep_merge(tv, v)
386
+ else
387
+ v
388
+ end
389
+ end
390
+
391
+ merged_hash
392
+ end
379
393
  end
380
394
  end
381
395
  end
@@ -65,6 +65,24 @@ module Karafka
65
65
  def explorer_path(topic_name = nil, partition_id = nil, offset = nil, action = nil)
66
66
  root_path(*['explorer', topic_name, partition_id, offset, action].compact)
67
67
  end
68
+
69
+ # Helps build scheduled messages paths.
70
+ # Similar to the explorer helper one
71
+ # @param topic_name [String]
72
+ # @param partition_id [Integer, nil]
73
+ # @param offset [Integer, nil]
74
+ # @param action [String, nil]
75
+ # @return [String] path to the expected location
76
+ def scheduled_messages_explorer_path(
77
+ topic_name = nil,
78
+ partition_id = nil,
79
+ offset = nil,
80
+ action = nil
81
+ )
82
+ root_path(
83
+ *['scheduled_messages', 'explorer', topic_name, partition_id, offset, action].compact
84
+ )
85
+ end
68
86
  end
69
87
  end
70
88
  end
@@ -34,9 +34,10 @@ module Karafka
34
34
  # @param name [String] button name
35
35
  # @param path [String] path to where to go
36
36
  # @param classes [String] extra css classes
37
+ # @param title [String, nil] title (if any)
37
38
  # @return [String] button link html
38
- def link_button(name, path, classes: '')
39
- %(<a href="#{path}" class="btn #{classes}">#{name}</a>)
39
+ def link_button(name, path, classes: '', title: nil)
40
+ %(<a href="#{path}" class="btn #{classes}" title="#{title}">#{name}</a>)
40
41
  end
41
42
 
42
43
  # Defines various methods for badges and links that simplify defining them without
@@ -54,8 +55,8 @@ module Karafka
54
55
  link_button(name, path, classes: "#{classes} btn-#{type}")
55
56
  end
56
57
 
57
- define_method :"link_button_#{type}_sm" do |name, path, classes: ''|
58
- link_button(name, path, classes: "#{classes} btn-#{type} btn-sm")
58
+ define_method :"link_button_#{type}_sm" do |name, path, classes: '', title: nil|
59
+ link_button(name, path, classes: "#{classes} btn-#{type} btn-sm", title: title)
59
60
  end
60
61
 
61
62
  # @param message [String] alert message
@@ -1,16 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # This Karafka component is a Pro component under a commercial license.
4
- # This Karafka component is NOT licensed under LGPL.
5
- #
6
- # All of the commercial components are present in the lib/karafka/pro directory of this
7
- # repository and their usage requires commercial license agreement.
8
- #
9
- # Karafka has also commercial-friendly license, commercial support and commercial components.
10
- #
11
- # By sending a pull request to the pro components, you are agreeing to transfer the copyright of
12
- # your code to Maciej Mensfeld.
13
-
14
3
  module Karafka
15
4
  module Web
16
5
  module Ui
@@ -1,16 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # This Karafka component is a Pro component under a commercial license.
4
- # This Karafka component is NOT licensed under LGPL.
5
- #
6
- # All of the commercial components are present in the lib/karafka/pro directory of this
7
- # repository and their usage requires commercial license agreement.
8
- #
9
- # Karafka has also commercial-friendly license, commercial support and commercial components.
10
- #
11
- # By sending a pull request to the pro components, you are agreeing to transfer the copyright of
12
- # your code to Maciej Mensfeld.
13
-
14
3
  module Karafka
15
4
  module Web
16
5
  module Ui
@@ -1,16 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # This Karafka component is a Pro component under a commercial license.
4
- # This Karafka component is NOT licensed under LGPL.
5
- #
6
- # All of the commercial components are present in the lib/karafka/pro directory of this
7
- # repository and their usage requires commercial license agreement.
8
- #
9
- # Karafka has also commercial-friendly license, commercial support and commercial components.
10
- #
11
- # By sending a pull request to the pro components, you are agreeing to transfer the copyright of
12
- # your code to Maciej Mensfeld.
13
-
14
3
  module Karafka
15
4
  module Web
16
5
  module Ui
@@ -110,6 +110,7 @@ function addListeners() {
110
110
  loadOffsetLookupDatePicker();
111
111
 
112
112
  new BtnToggleManager();
113
+ new BtnToggleManager('.btn-toggle-nav-collapsed', 'collapsed');
113
114
  new ThemeManager();
114
115
 
115
116
  refreshTitle()
@@ -51,14 +51,14 @@ function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"f
51
51
  /*! Source: lib/karafka/web/ui/public/javascripts/charts/data_formatting_utility.js */
52
52
  let DataFormattingUtils={niceBytes(e,t=2){let i=0,s=parseInt(e,10)||0;for(;1024<=s&&++i;)s/=1024;return s.toFixed(s<10&&0<i?1:t)+" "+["bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][i]},formatLabelX(e,t){return"date"!==t?e:("00"+((t=new Date(1e3*e)).getMonth()+1)).slice(-2)+"/"+("00"+t.getDate()).slice(-2)+"/"+t.getFullYear()+" "+("00"+t.getHours()).slice(-2)+":"+("00"+t.getMinutes()).slice(-2)+":"+("00"+t.getSeconds()).slice(-2)},formatTooltip(e,t){var i=t.parsed.y,s=t.dataset.label;switch(e){case"percentage":return Math.floor(i)===i?s+": "+i+" %":s+": "+Math.round(100*i)/100+" %";case"memory":return s+": "+DataFormattingUtils.niceBytes(1024*i,2);default:return t.yLabel}},formatLabelY(e,t){switch(e){case"percentage":return Math.floor(t)===t?t+"%":Math.round(100*t)/100+"%";case"memory":return DataFormattingUtils.niceBytes(1024*t,1);default:return Math.floor(t)===t?t:Math.round(100*t)/100}},isFractionalPrecision(e){return e!==Math.floor(e)}};
53
53
  /*! Source: lib/karafka/web/ui/public/javascripts/charts/dataset_state_manager.js */class DatasetStateManager{constructor(){this.storageKey="karafkaDisabledDatasets"}readAll(){var e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):{}}saveAll(e){localStorage.setItem(this.storageKey,JSON.stringify(e))}saveCurrent(){var e=document.querySelectorAll(".chartjs"),t=window.location.href.split("?")[0];let i={};var s=this.readAll();e.forEach(e=>{var e=e.id,t=Chart.getChart(e);t&&t.legend&&t.legend.legendItems&&0<(t=t.legend.legendItems.map((e,t)=>e.hidden?t:null).filter(e=>null!==e)).length&&(i[e]=t)}),s[t]=i,this.saveAll(s)}getCurrentChart(e){var t=window.location.href.split("?")[0];return(this.readAll()[t]||{})[e]||[]}}
54
- /*! Source: lib/karafka/web/ui/public/javascripts/components/btn_toggle_manager.js */class BtnToggleManager{constructor(){this.init()}init(){document.querySelectorAll(".btn-toggle").forEach(t=>{let i=t.getAttribute("data-toggle-target"),s=document.getElementById(i);s&&(this.restoreVisibility(t,s),t.addEventListener("click",()=>{var e=!s.classList.contains("hidden");s.classList.toggle("hidden"),t.classList.toggle("active",!e),this.saveVisibility(i,!e)}))})}saveVisibility(e,t){localStorage.setItem(e+"_visibility",t)}restoreVisibility(e,t){var i=localStorage.getItem(t.id+"_visibility"),i=i?"true"===i:!t.classList.contains("hidden");t.classList.toggle("hidden",!i),e.classList.toggle("active",i)}}
54
+ /*! Source: lib/karafka/web/ui/public/javascripts/components/btn_toggle_manager.js */class BtnToggleManager{constructor(e=".btn-toggle",t="hidden"){this.btnClass=e,this.visibilityClass=t,this.init()}init(){document.querySelectorAll(this.btnClass).forEach(t=>{let i=t.getAttribute("data-toggle-target"),s=document.getElementById(i);s&&(this.restoreVisibility(t,s),t.addEventListener("click",()=>{var e=!s.classList.contains(this.visibilityClass);s.classList.toggle(this.visibilityClass),t.classList.toggle("active",!e),this.saveVisibility(i,!e)}))})}saveVisibility(e,t){localStorage.setItem(e+"_visibility",t)}restoreVisibility(e,t){var i=localStorage.getItem(t.id+"_visibility"),i=i?"true"===i:!t.classList.contains(this.visibilityClass);t.classList.toggle(this.visibilityClass,!i),e.classList.toggle("active",i)}}
55
55
  /*! Source: lib/karafka/web/ui/public/javascripts/components/charts.js */function refreshCharts(e){(new LineChartsManager).refreshAndRender(e,!0),(new BarChartManager).refreshAndRenderBarCharts(e,!0)}function manageCharts(){(new LineChartsManager).refreshAndRender(document,!1),(new BarChartManager).refreshAndRenderBarCharts(document,!1)}
56
- /*! Source: lib/karafka/web/ui/public/javascripts/components/live_poll.js */var livePollTimer=null,oldDOM=null,datePicker=null,startURL=window.location.href;let isHoveringOverClickable=!1;function initLivePolling(){document.addEventListener("mouseover",function(e){isElementClickable(e.target)&&(isHoveringOverClickable=!0)}),document.addEventListener("mouseout",function(e){isElementClickable(e.target)&&(isHoveringOverClickable=!1)}),null==localStorage.karafkaLivePoll&&(localStorage.karafkaLivePoll="enabled")}function isElementClickable(e){return!!("A"===e.tagName||"BUTTON"===e.tagName||"INPUT"===e.tagName&&("button"===e.type||"submit"===e.type)||e.hasAttribute("onclick")||"function"==typeof e.onclick||"SPAN"===e.tagName&&e.closest(".tab-container"))}function isUserHoveringOverClickable(){return isHoveringOverClickable}function isAnyTextSelected(){var e="";return void 0!==window.getSelection?e=window.getSelection().toString():void 0!==document.selection&&"Text"==document.selection.type&&(e=document.selection.createRange().text),""!=e}function isCollapsingHappening(){return 0<document.querySelectorAll(".collapsing").length}function isPollingPossible(e=!1){return!isUserHoveringOverClickable()&&!isAnyTextSelected()&&!(isOffsetLookupCalendarVisible()||isAnyModalOpen()||isCollapsingHappening()||isTurboOperating()||e&&startURL!=window.location.href)}function isAnyModalOpen(){var e;for(e of document.querySelectorAll("dialog"))if(e.open)return!0;return!1}function bindPollingButtonClick(){var e=document.getElementById("live-poll");null!=e&&e.addEventListener("click",handleLivePollingButtonClick)}function handleLivePollingButtonClick(){toggleLivePollState(),setLivePollButton(),setPollingListener()}function toggleLivePollState(){"enabled"==localStorage.karafkaLivePoll?localStorage.karafkaLivePoll="disabled":localStorage.karafkaLivePoll="enabled"}function setLivePollButton(){null!=(selector=document.getElementById("live-poll"))&&("enabled"==localStorage.karafkaLivePoll?(selector.classList.add("text-base-content"),selector.classList.remove("text-gray-500")):(selector.classList.add("text-gray-500"),selector.classList.remove("text-base-content")))}function checkResponse(e){if(e.ok)return e;throw e}function refreshPage(e){if(!isPollingPossible())return!1;var t,e=(new DOMParser).parseFromString(e,"text/html"),i=e.getElementById("content");oldDOM!=i.innerHTML&&(t=document.querySelectorAll(".chartjs").length,0==i.querySelectorAll(".chartjs").length||0==t?(document.getElementById("content").replaceWith(i),addListeners()):(t=e.getElementById("refreshable"),document.getElementById("refreshable").replaceWith(t),refreshCharts(e)),oldDOM=i.innerHTML)}function showError(e){console.error(e)}function scheduleLivePoll(){null==oldDOM&&(oldDOM=document.getElementById("content").innerHTML);let e=parseInt(localStorage.karafkaTimeInterval)||5e3;e<1e3&&(localStorage.karafkaTimeInterval=5e3,e=5e3),livePollTimer=setTimeout(livePollCallback,e)}function livePollCallback(){clearTimeout(livePollTimer),livePollTimer=null,isPollingPossible(!1)?(startURL=window.location.href,fetch(window.location.href).then(checkResponse).then(e=>e.text()).then(refreshPage).catch(showError).finally(setPollingListener)):setPollingListener()}function setPollingListener(){var e=document.getElementById("live-poll"),t=localStorage.karafkaLivePoll;"disabled"==t||null==t||null==e?(clearTimeout(livePollTimer),livePollTimer=null):(clearTimeout(livePollTimer),scheduleLivePoll())}
56
+ /*! Source: lib/karafka/web/ui/public/javascripts/components/live_poll.js */var livePollTimer=null,oldDOM=null,datePicker=null,startURL=window.location.href;let isHoveringOverClickable=!1;function initLivePolling(){document.addEventListener("mouseover",function(e){isElementClickable(e.target)&&(isHoveringOverClickable=!0)}),document.addEventListener("mouseout",function(e){isElementClickable(e.target)&&(isHoveringOverClickable=!1)}),null==localStorage.karafkaLivePoll&&(localStorage.karafkaLivePoll="enabled")}function isFormActive(){var e=document.activeElement;return["INPUT","TEXTAREA","SELECT","BUTTON","FIELDSET"].includes(e.tagName)}function isElementClickable(e){return!!("A"===e.tagName||"BUTTON"===e.tagName||"INPUT"===e.tagName&&("button"===e.type||"submit"===e.type)||e.hasAttribute("onclick")||"function"==typeof e.onclick||"SPAN"===e.tagName&&e.closest(".tab-container")||e.closest("button")||e.closest("a"))}function isUserHoveringOverClickable(){return isHoveringOverClickable}function isAnyTextSelected(){var e="";return void 0!==window.getSelection?e=window.getSelection().toString():void 0!==document.selection&&"Text"==document.selection.type&&(e=document.selection.createRange().text),""!=e}function isCollapsingHappening(){return 0<document.querySelectorAll(".collapsing").length}function isPollingPossible(e=!1){return!(isFormActive()||isUserHoveringOverClickable()||isAnyTextSelected()||isOffsetLookupCalendarVisible()||isAnyModalOpen()||isCollapsingHappening()||isTurboOperating()||e&&startURL!=window.location.href)}function isAnyModalOpen(){var e;for(e of document.querySelectorAll("dialog"))if(e.open)return!0;return!1}function bindPollingButtonClick(){var e=document.getElementById("live-poll");null!=e&&e.addEventListener("click",handleLivePollingButtonClick)}function handleLivePollingButtonClick(){toggleLivePollState(),setLivePollButton(),setPollingListener()}function toggleLivePollState(){"enabled"==localStorage.karafkaLivePoll?localStorage.karafkaLivePoll="disabled":localStorage.karafkaLivePoll="enabled"}function setLivePollButton(){null!=(selector=document.getElementById("live-poll"))&&("enabled"==localStorage.karafkaLivePoll?(selector.classList.add("text-base-content"),selector.classList.remove("text-gray-500")):(selector.classList.add("text-gray-500"),selector.classList.remove("text-base-content")))}function checkResponse(e){if(e.ok)return e;throw e}function refreshPage(e){if(!isPollingPossible())return!1;var t,e=(new DOMParser).parseFromString(e,"text/html"),i=e.getElementById("content");oldDOM!=i.innerHTML&&(t=document.querySelectorAll(".chartjs").length,0==i.querySelectorAll(".chartjs").length||0==t?(document.getElementById("content").replaceWith(i),addListeners()):(t=e.getElementById("refreshable"),document.getElementById("refreshable").replaceWith(t),refreshCharts(e)),oldDOM=i.innerHTML)}function showError(e){console.error(e)}function scheduleLivePoll(){null==oldDOM&&(oldDOM=document.getElementById("content").innerHTML);let e=parseInt(localStorage.karafkaTimeInterval)||5e3;e<1e3&&(localStorage.karafkaTimeInterval=5e3,e=5e3),livePollTimer=setTimeout(livePollCallback,e)}function livePollCallback(){clearTimeout(livePollTimer),livePollTimer=null,isPollingPossible(!1)?(startURL=window.location.href,fetch(window.location.href).then(checkResponse).then(e=>e.text()).then(refreshPage).catch(showError).finally(setPollingListener)):setPollingListener()}function setPollingListener(){var e=document.getElementById("live-poll"),t=localStorage.karafkaLivePoll;"disabled"==t||null==t||null==e?(clearTimeout(livePollTimer),livePollTimer=null):(clearTimeout(livePollTimer),scheduleLivePoll())}
57
57
  /*! Source: lib/karafka/web/ui/public/javascripts/components/offset_datetime.js */function loadOffsetLookupDatePicker(){var e={locale:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],today:"Today",clear:"Clear",dateFormat:"yyyy-MM-dd",timeFormat:"HH:mm",firstDay:1},timepicker:!0,onSelect:({})=>{document.getElementById("offset-lookup-datepicker").value=""},onShow:function(){offsetLookupDatePicker.selectDate((new Date).getTime()),offsetLookupDatePicker.maxDate=new Date},onHide:function(){offsetLookupDatePicker.selectDate((new Date).getTime())},buttons:[{content(e){return"Go to offset"},onClick(e){var t=e.selectedDates[0]||new Date,i=e.$el.dataset.target;e.hide(),location.href=i+"/"+formatRedirectDateTime(t)}}]};null!=offsetLookupDatePicker&&offsetLookupDatePicker.destroy(),null!=document.getElementById("offset-lookup-datepicker")&&((offsetLookupDatePicker=new AirDatepicker("#offset-lookup-datepicker",e)).maxDate=new Date,offsetLookupDatePicker.selectDate((new Date).getTime()))}function formatRedirectDateTime(e){return e.getFullYear()+`-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}/${String(e.getHours()).padStart(2,"0")}:`+String(e.getMinutes()).padStart(2,"0")}function isOffsetLookupCalendarVisible(){return null!=offsetLookupDatePicker&&offsetLookupDatePicker.visible}
58
58
  /*! Source: lib/karafka/web/ui/public/javascripts/components/search.js */offsetLookupDatePicker=null;class SearchModalManager{constructor(){this.init()}init(){var t=document.getElementById("offset-input");if(!t)return!1;var i=document.getElementById("offset-timestamp-input"),e=document.querySelectorAll('input[name="search[offset_type]"]'),s=document.getElementById("no-search-criteria"),r=document.getElementById("search-form-errors");e.forEach(function(e){e.addEventListener("change",function(){t.disabled=!document.getElementById("offset-value").checked,t.required=document.getElementById("offset-value").checked,i.disabled=!document.getElementById("offset-timestamp").checked,i.required=document.getElementById("offset-timestamp").checked})}),t.disabled=!document.getElementById("offset-value").checked,t.required=document.getElementById("offset-value").checked,i.disabled=!document.getElementById("offset-timestamp").checked,i.required=document.getElementById("offset-timestamp").checked,document.getElementById("show-search-modal").addEventListener("click",function(){document.getElementById("messages_search_modal").showModal();var e=document.querySelector('#messages_search_modal input[type="text"]');e&&e.focus()}),(s||r)&&(document.getElementById("messages_search_modal").showModal(),e=document.querySelector('#messages_search_modal input[type="text"]'))&&e.focus()}}class SearchMetadataVisibilityManager{constructor(){this.storageKey="karafkaSearchMetadataVisibility",this.metadataElement=document.getElementById("search-metadata-details"),this.toggleButton=document.getElementById("toggle-search-metadata"),this.metadataElement&&this.init()}init(){this.restoreVisibility(),self=this;var t=document.getElementById("toggle-search-metadata");t.addEventListener("click",function(){var e=document.getElementById("search-metadata-details");e.classList.toggle("hidden"),t.classList.toggle("active"),self.saveVisibility(!e.classList.contains("hidden"))})}readVisibility(){return"true"===localStorage.getItem(this.storageKey)}saveVisibility(e){localStorage.setItem(this.storageKey,e)}restoreVisibility(){this.readVisibility()&&(document.getElementById("toggle-search-metadata").classList.add("active"),document.getElementById("search-metadata-details").classList.remove("hidden"))}}
59
59
  /*! Source: lib/karafka/web/ui/public/javascripts/components/tabs_manager.js */class TabsManager{constructor(){this.storageKey="karafkaActiveTabsv2"}readAllActiveTabs(){var e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):{}}saveAllActiveTabs(e){localStorage.setItem(this.storageKey,JSON.stringify(e))}saveCurrentActiveTabs(){var e=document.querySelectorAll(".inline-tabs > .active"),t=window.location.href.split("?")[0];let i=[];var s=this.readAllActiveTabs();e.forEach(e=>{i.push(e.id)}),s[t]=i,this.saveAllActiveTabs(s)}setActiveTabs(){var e=window.location.href.split("?")[0],e=this.readAllActiveTabs()[e];(e=e||Array.from(document.querySelectorAll(".inline-tabs > .active")).map(e=>e.id))&&e.forEach(e=>{e=document.getElementById(e);e&&(e.parentElement.querySelectorAll(".custom-tab").forEach(function(e){e.classList.remove("active")}),e.classList.add("active"),document.getElementById(e.getAttribute("data-target")).classList.remove("hidden"))})}manageTabs(){this.setActiveTabs();var t=this;document.querySelectorAll(".inline-tabs > .custom-tab").forEach(function(e){e.addEventListener("click",function(e){this.parentElement.querySelectorAll(".custom-tab").forEach(function(e){e.classList.remove("active");e=e.getAttribute("data-target");document.getElementById(e).classList.add("hidden")}),this.classList.add("active"),t.saveCurrentActiveTabs(),t.setActiveTabs()})})}}
60
60
  /*! Source: lib/karafka/web/ui/public/javascripts/components/theme_manager.js */class ThemeManager{constructor(){this.themeSelectorButton=document.getElementById("theme-selector"),this.themeSelectorLight=document.getElementById("theme-selector-light"),this.themeSelectorDark=document.getElementById("theme-selector-dark"),this.init()}init(){this.lightThemeLink=document.querySelector(".highlight-light"),this.darkThemeLink=document.querySelector(".highlight-dark"),this.lightThemeLink&&this.darkThemeLink&&this.themeSelectorButton?(this.restoreTheme(),this.bindThemeSelectorButton()):console.error("Theme CSS links or theme selector button not found")}bindThemeSelectorButton(){this.themeSelectorButton&&!this.themeSelectorButton.dataset.bound&&(this.themeSelectorButton.addEventListener("click",()=>{this.toggleTheme()}),this.themeSelectorButton.dataset.bound="true")}setTheme(e){document.documentElement.setAttribute("data-theme",e),"dark"===e?(this.lightThemeLink.disabled=!0,this.darkThemeLink.disabled=!1,this.themeSelectorLight.classList.add("hidden"),this.themeSelectorDark.classList.remove("hidden")):(this.lightThemeLink.disabled=!1,this.darkThemeLink.disabled=!0,this.themeSelectorLight.classList.remove("hidden"),this.themeSelectorDark.classList.add("hidden")),localStorage.setItem("theme",e)}toggleTheme(){var e=document.documentElement.getAttribute("data-theme");this.setTheme("dark"===e?"corporate":"dark")}restoreTheme(){var e=localStorage.getItem("theme"),e=e||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"corporate");this.setTheme(e),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",e=>{localStorage.getItem("theme")||this.setTheme(e.matches?"dark":"corporate")})}}
61
61
  /*! Source: lib/karafka/web/ui/public/javascripts/components/turbo_tracker.js */let turboIsOperating=!1;function isTurboOperating(){return turboIsOperating}
62
- /*! Source: lib/karafka/web/ui/public/javascripts/application.js */function updateTimeAgo(){0!=(e=document.querySelectorAll("time")).length&&(timeago.render(e),timeago.cancel());for(var e=document.getElementsByClassName("time-title"),t=0;t<e.length;t++){var i=e[t],s=i.getAttribute("title");i.setAttribute("title",timeago.format(s))}}function refreshTitle(){var e=document.querySelectorAll(".breadcrumbs a"),e=Array.from(e).slice(1).map(e=>e.textContent.trim());0<e.length?document.title=e.join(" > ")+" - Karafka Web UI":document.title="Karafka Web UI"}function redirectToPartition(){var e=document.getElementById("current-partition");null!=e&&e.addEventListener("change",function(){Turbo.visit(this.value)})}function bindActionsConfirmations(){for(var t=document.getElementsByClassName("confirm-action"),i=0;i<t.length;i++){var s=t[i];let e="click";"FORM"===s.nodeName&&(e="submit"),s.addEventListener(e,function(e){window.confirm("Are you sure?")||e.preventDefault()})}}function bindLockableButtons(){document.querySelectorAll(".btn-lockable").forEach(function(i){i.addEventListener("click",function(e){var t=i.closest("form");t?t.addEventListener("submit",function(){i.disabled=!0,i.textContent+="...",document.querySelectorAll(".modal").forEach(function(e){e.classList.add("modal-locked")})},{once:!0}):(i.disabled=!0,i.textContent+="...")})})}function addListeners(){initLivePolling(),bindPollingButtonClick(),bindLockableButtons(),setLivePollButton(),setPollingListener(),hljs.highlightAll(),updateTimeAgo(),redirectToPartition(),(new TabsManager).manageTabs(),manageCharts(),bindActionsConfirmations(),loadOffsetLookupDatePicker(),new BtnToggleManager,new ThemeManager,refreshTitle(),new SearchMetadataVisibilityManager,new SearchModalManager}document.addEventListener("turbo:visit",function(){turboIsOperating=!0}),document.addEventListener("turbo:before-fetch-request",function(){turboIsOperating=!0}),document.addEventListener("turbo:before-fetch-response",function(){turboIsOperating=!0}),document.addEventListener("turbo:load",function(){turboIsOperating=!1}),document.addEventListener("turbo:frame-load",function(){turboIsOperating=!1}),document.addEventListener("turbo:frame-render",function(){turboIsOperating=!1}),document.addEventListener("turbo:load",addListeners),Turbo.setProgressBarDelay(100)
62
+ /*! Source: lib/karafka/web/ui/public/javascripts/application.js */function updateTimeAgo(){0!=(e=document.querySelectorAll("time")).length&&(timeago.render(e),timeago.cancel());for(var e=document.getElementsByClassName("time-title"),t=0;t<e.length;t++){var i=e[t],s=i.getAttribute("title");i.setAttribute("title",timeago.format(s))}}function refreshTitle(){var e=document.querySelectorAll(".breadcrumbs a"),e=Array.from(e).slice(1).map(e=>e.textContent.trim());0<e.length?document.title=e.join(" > ")+" - Karafka Web UI":document.title="Karafka Web UI"}function redirectToPartition(){var e=document.getElementById("current-partition");null!=e&&e.addEventListener("change",function(){Turbo.visit(this.value)})}function bindActionsConfirmations(){for(var t=document.getElementsByClassName("confirm-action"),i=0;i<t.length;i++){var s=t[i];let e="click";"FORM"===s.nodeName&&(e="submit"),s.addEventListener(e,function(e){window.confirm("Are you sure?")||e.preventDefault()})}}function bindLockableButtons(){document.querySelectorAll(".btn-lockable").forEach(function(i){i.addEventListener("click",function(e){var t=i.closest("form");t?t.addEventListener("submit",function(){i.disabled=!0,i.textContent+="...",document.querySelectorAll(".modal").forEach(function(e){e.classList.add("modal-locked")})},{once:!0}):(i.disabled=!0,i.textContent+="...")})})}function addListeners(){initLivePolling(),bindPollingButtonClick(),bindLockableButtons(),setLivePollButton(),setPollingListener(),hljs.highlightAll(),updateTimeAgo(),redirectToPartition(),(new TabsManager).manageTabs(),manageCharts(),bindActionsConfirmations(),loadOffsetLookupDatePicker(),new BtnToggleManager,new BtnToggleManager(".btn-toggle-nav-collapsed","collapsed"),new ThemeManager,refreshTitle(),new SearchMetadataVisibilityManager,new SearchModalManager}document.addEventListener("turbo:visit",function(){turboIsOperating=!0}),document.addEventListener("turbo:before-fetch-request",function(){turboIsOperating=!0}),document.addEventListener("turbo:before-fetch-response",function(){turboIsOperating=!0}),document.addEventListener("turbo:load",function(){turboIsOperating=!1}),document.addEventListener("turbo:frame-load",function(){turboIsOperating=!1}),document.addEventListener("turbo:frame-render",function(){turboIsOperating=!1}),document.addEventListener("turbo:load",addListeners),Turbo.setProgressBarDelay(100)
63
63
  /*! Source: lib/karafka/web/ui/public/javascripts/charts/types/bar.js */;class BarChartManager{constructor(){this.datasetStateManager=new DatasetStateManager}refreshAndRenderBarCharts(c,u=!1){(u?c:document).querySelectorAll(".chartjs-bar").forEach(e=>{var t=e.id,i=(u?c:document).getElementById(t),s=JSON.parse(i.dataset.datasets);let r=[],a=[],n=[];var o=i.dataset.label_type_y;let l=i.dataset.label_type_x,h=this.datasetStateManager.getCurrentChart(t);Object.entries(s).forEach(([e,t],i)=>{t.forEach(([e,t])=>{n.push(t),0===i&&r.push(DataFormattingUtils.formatLabelX(e,l))}),a.push({data:t.map(([,e])=>e),label:e,hidden:h.includes(i),borderWidth:2.5})});var i=Math.min(...n),s=Math.max(...n),i=Math.round(i-.1*i),s=Math.round(s+.005*s),d=Math.round(n.reduce((e,t)=>e+t,0)/n.length);a.push({type:"line",label:"Average",data:new Array(r.length).fill(d),borderWidth:2,fill:!1,pointRadius:0,hoverBorderWidth:3,pointHitRadius:20}),u?((d=Chart.getChart(t)).data.datasets=a,d.data.labels=r,d.options.scales.y.min=i,d.options.scales.y.max=s,d.update("none")):this.renderBarChart(e,r,a,i,s,o)})}renderBarChart(e,t,i,s,r,a){new Chart(e,{type:"bar",data:{labels:t,datasets:i},options:{responsive:!0,maintainAspectRatio:!1,aspectRatio:5,scales:{x:{display:!0},y:{beginAtZero:!1,min:s,max:r,ticks:{maxTicksLimit:8,callback:function(e,t,i){return DataFormattingUtils.formatLabelY(a,e,t,i)}}}},animation:!1,animations:{colors:!1,x:!1},transitions:{active:{animation:{duration:!1}}},plugins:{legend:{position:"hidden"},tooltip:{callbacks:{label:function(e){let t=e.dataset.label||"";return"Average"!==t?DataFormattingUtils.formatTooltip(a,e):t+=": "+e.formattedValue}}}}}})}}
64
64
  /*! Source: lib/karafka/web/ui/public/javascripts/charts/types/line.js */class LineChartsManager{constructor(){this.datasetStateManager=new DatasetStateManager}getLegendHeightPercentage(e){var t=e.chartArea,e=e.height,t=e-(t.bottom-t.top);return Math.round(t/e*100)}afterRenderPlugin(){let i=this;return{id:"afterRender",afterRender:function(e){var t=i.getLegendHeightPercentage(e),e=document.getElementById(e.canvas.id);50<t&&""==e.parentElement.style.height&&(e.parentElement.style.height="400px")}}}refreshAndRender(d,c=!1){(c?d:document).querySelectorAll(".chartjs-line").forEach(e=>{var t=e.id,i=(c?d:document).getElementById(t),s=JSON.parse(i.dataset.datasets);let r=[],a=[],n=0;var o=i.dataset.label_type_y;let l=i.dataset.label_type_x,h=this.datasetStateManager.getCurrentChart(t);Object.entries(s).forEach(([e,t],i)=>{t.forEach(([e,t])=>{0===i&&r.push(DataFormattingUtils.formatLabelX(e,l)),DataFormattingUtils.isFractionalPrecision(t)&&(n=2)}),a.push({data:t,label:e,hidden:h.includes(i),borderWidth:2.5,pointHitRadius:10})}),c?((i=Chart.getChart(t)).data.datasets=a,i.data.labels=r,i.update("none")):this.render(e,r,a,n,o)})}render(e,t,i,s,r){var a=null,a=10<i.length?"point":"x";new Chart(e,{type:"line",data:{labels:t,datasets:i},options:{responsive:!0,maintainAspectRatio:!1,aspectRatio:5,title:{display:!1},interaction:{mode:"nearest",axis:"x",intersect:!1},animation:!1,transitions:{active:{animation:{duration:!1}}},plugins:{legend:{position:"bottom",labels:{padding:20},onClick:(e,t,i)=>{var s=t.datasetIndex,i=i.chart;i.isDatasetVisible(s)?(i.hide(s),t.hidden=!0):(i.show(s),t.hidden=!1),this.datasetStateManager.saveCurrent()}},tooltip:{mode:a,filter:function(e,t,i){return t<10},callbacks:{label:function(e){return DataFormattingUtils.formatTooltip(r,e)}}}},scales:{x:{display:!1},y:{ticks:{precision:s,count:5,callback:function(e,t,i){return DataFormattingUtils.formatLabelY(r,e,t,i)}}}},elements:{point:{radius:0,style:!1},line:{style:"star",radius:0,spanGaps:!1}},hover:{mode:"index",intersect:!1}},plugins:[this.afterRenderPlugin()]})}}
@@ -1,10 +1,20 @@
1
+ /*
2
+ This class allows buttons to toggle visibility classes on target elements.
3
+ It also saves the visibility state in local storage so that it persists across page loads.
4
+
5
+ By default, it will look for elements with class 'btn-toggle' and toggle the
6
+ 'hidden' class on their target elements (defined by the data attribute `data-toggle-target`)
7
+ when clicked.
8
+ */
1
9
  class BtnToggleManager {
2
- constructor() {
10
+ constructor(btnClass = '.btn-toggle', visibilityClass = 'hidden') {
11
+ this.btnClass = btnClass;
12
+ this.visibilityClass = visibilityClass;
3
13
  this.init();
4
14
  }
5
15
 
6
16
  init() {
7
- document.querySelectorAll('.btn-toggle').forEach(button => {
17
+ document.querySelectorAll(this.btnClass).forEach(button => {
8
18
  const targetId = button.getAttribute('data-toggle-target');
9
19
  const targetElement = document.getElementById(targetId);
10
20
 
@@ -15,8 +25,8 @@ class BtnToggleManager {
15
25
 
16
26
  // Add event listener to toggle visibility
17
27
  button.addEventListener('click', () => {
18
- const isVisible = !targetElement.classList.contains('hidden');
19
- targetElement.classList.toggle('hidden');
28
+ const isVisible = !targetElement.classList.contains(this.visibilityClass);
29
+ targetElement.classList.toggle(this.visibilityClass);
20
30
  button.classList.toggle('active', !isVisible);
21
31
  this.saveVisibility(targetId, !isVisible);
22
32
  });
@@ -29,9 +39,9 @@ class BtnToggleManager {
29
39
 
30
40
  restoreVisibility(button, targetElement) {
31
41
  const storedVisibility = localStorage.getItem(targetElement.id + '_visibility');
32
- const isVisible = storedVisibility ? (storedVisibility === 'true') : !targetElement.classList.contains('hidden');
42
+ const isVisible = storedVisibility ? (storedVisibility === 'true') : !targetElement.classList.contains(this.visibilityClass);
33
43
 
34
- targetElement.classList.toggle('hidden', !isVisible);
44
+ targetElement.classList.toggle(this.visibilityClass, !isVisible);
35
45
  button.classList.toggle('active', isVisible);
36
46
  }
37
47
  }
@@ -32,6 +32,14 @@ function initLivePolling() {
32
32
  localStorage.karafkaLivePoll = "enabled"
33
33
  }
34
34
 
35
+ function isFormActive() {
36
+ // Get the currently focused element
37
+ const activeElement = document.activeElement;
38
+
39
+ // Check if the focused element is a form control
40
+ return ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON', 'FIELDSET'].includes(activeElement.tagName);
41
+ }
42
+
35
43
  function isElementClickable(element) {
36
44
  // Check for common clickable elements
37
45
  if (element.tagName === 'A' ||
@@ -47,6 +55,12 @@ function isElementClickable(element) {
47
55
  return true;
48
56
  }
49
57
 
58
+ // Check if the element is wrapped in a <button>
59
+ if (element.closest('button')) { return true }
60
+
61
+ // Check if element is wrapped with a link
62
+ if (element.closest('a')) { return true }
63
+
50
64
  return false;
51
65
  }
52
66
 
@@ -79,6 +93,7 @@ function isCollapsingHappening() {
79
93
  // We should not poll and update if we have any text selected and we should not do it as well, when
80
94
  // datetime picker with time selection is present
81
95
  function isPollingPossible(check_url = false){
96
+ if (isFormActive()) { return false }
82
97
  if (isUserHoveringOverClickable()) { return false }
83
98
  if (isAnyTextSelected()) { return false }
84
99
  if (isOffsetLookupCalendarVisible()) { return false }
@@ -35,3 +35,24 @@ table td.commands {
35
35
  table td.commands-inline-3 {
36
36
  width: 180px
37
37
  }
38
+
39
+ .drawer-side .btn-toggle-nav-collapsed svg {
40
+ transform: scale(1, 1);
41
+ transition: transform 0.2s;
42
+ }
43
+
44
+ .drawer-side.collapsed .btn-toggle-nav-collapsed svg {
45
+ transform: scale(-1, -1);
46
+ }
47
+
48
+ .drawer-side .btn-toggle-nav-collapsed::after {
49
+ content: 'Collapse';
50
+ }
51
+
52
+ .drawer-side.collapsed .btn-toggle-nav-collapsed::after {
53
+ content: none;
54
+ }
55
+
56
+ .drawer-side.collapsed:hover .btn-toggle-nav-collapsed::after {
57
+ content: 'Expand';
58
+ }