karafka-web 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +3 -5
  3. data/CHANGELOG.md +12 -0
  4. data/Gemfile.lock +1 -1
  5. data/lib/karafka/web/config.rb +2 -0
  6. data/lib/karafka/web/tracking/consumers/reporter.rb +5 -3
  7. data/lib/karafka/web/ui/base.rb +6 -2
  8. data/lib/karafka/web/ui/controllers/base.rb +17 -0
  9. data/lib/karafka/web/ui/controllers/cluster.rb +5 -2
  10. data/lib/karafka/web/ui/controllers/consumers.rb +3 -1
  11. data/lib/karafka/web/ui/controllers/errors.rb +19 -6
  12. data/lib/karafka/web/ui/controllers/jobs.rb +3 -1
  13. data/lib/karafka/web/ui/controllers/requests/params.rb +10 -0
  14. data/lib/karafka/web/ui/lib/paginations/base.rb +61 -0
  15. data/lib/karafka/web/ui/lib/paginations/offset_based.rb +96 -0
  16. data/lib/karafka/web/ui/lib/paginations/page_based.rb +70 -0
  17. data/lib/karafka/web/ui/lib/paginations/paginators/arrays.rb +33 -0
  18. data/lib/karafka/web/ui/lib/paginations/paginators/base.rb +23 -0
  19. data/lib/karafka/web/ui/lib/paginations/paginators/partitions.rb +52 -0
  20. data/lib/karafka/web/ui/lib/paginations/paginators/sets.rb +85 -0
  21. data/lib/karafka/web/ui/lib/ttl_cache.rb +74 -0
  22. data/lib/karafka/web/ui/models/cluster_info.rb +59 -0
  23. data/lib/karafka/web/ui/models/message.rb +114 -38
  24. data/lib/karafka/web/ui/models/status.rb +3 -1
  25. data/lib/karafka/web/ui/pro/app.rb +11 -3
  26. data/lib/karafka/web/ui/pro/controllers/consumers.rb +3 -1
  27. data/lib/karafka/web/ui/pro/controllers/dlq.rb +1 -2
  28. data/lib/karafka/web/ui/pro/controllers/errors.rb +43 -10
  29. data/lib/karafka/web/ui/pro/controllers/explorer.rb +52 -7
  30. data/lib/karafka/web/ui/pro/views/errors/_breadcrumbs.erb +8 -6
  31. data/lib/karafka/web/ui/pro/views/errors/_error.erb +1 -1
  32. data/lib/karafka/web/ui/pro/views/errors/_partition_option.erb +1 -1
  33. data/lib/karafka/web/ui/pro/views/errors/_table.erb +21 -0
  34. data/lib/karafka/web/ui/pro/views/errors/_title_with_select.erb +31 -0
  35. data/lib/karafka/web/ui/pro/views/errors/index.erb +9 -56
  36. data/lib/karafka/web/ui/pro/views/errors/partition.erb +17 -0
  37. data/lib/karafka/web/ui/pro/views/explorer/_breadcrumbs.erb +1 -1
  38. data/lib/karafka/web/ui/pro/views/explorer/_message.erb +8 -2
  39. data/lib/karafka/web/ui/pro/views/explorer/_partition_option.erb +1 -1
  40. data/lib/karafka/web/ui/pro/views/explorer/_topic.erb +1 -1
  41. data/lib/karafka/web/ui/pro/views/explorer/partition/_messages.erb +1 -0
  42. data/lib/karafka/web/ui/pro/views/explorer/partition.erb +1 -1
  43. data/lib/karafka/web/ui/pro/views/explorer/topic/_empty.erb +3 -0
  44. data/lib/karafka/web/ui/pro/views/explorer/topic/_limited.erb +4 -0
  45. data/lib/karafka/web/ui/pro/views/explorer/topic/_partitions.erb +11 -0
  46. data/lib/karafka/web/ui/pro/views/explorer/topic.erb +49 -0
  47. data/lib/karafka/web/ui/pro/views/shared/_navigation.erb +1 -1
  48. data/lib/karafka/web/ui/views/cluster/_partition.erb +1 -1
  49. data/lib/karafka/web/ui/views/errors/_error.erb +1 -1
  50. data/lib/karafka/web/ui/views/shared/_pagination.erb +16 -12
  51. data/lib/karafka/web/version.rb +1 -1
  52. data.tar.gz.sig +0 -0
  53. metadata +18 -3
  54. metadata.gz.sig +0 -0
  55. data/lib/karafka/web/ui/lib/paginate_array.rb +0 -38
@@ -1,65 +1,18 @@
1
- <div class="container mb-4">
2
- <div class="row">
3
- <div class="col">
4
- <h3>
5
- Errors
6
- </h3>
7
- </div>
8
-
9
- <div class="col">
10
- <div class="col-auto text-end">
11
- <label class="col-form-label">Partition</label>
12
- </div>
13
- </div>
14
-
15
- <div class="col pt-1 mb-0 pb-0">
16
- <div class="col-auto">
17
- <select class="form-select form-select-sm mb-0 form-control" id="current-partition">
18
- <%==
19
- each_partial(
20
- @partitions_count.times.to_a,
21
- 'errors/partition_option',
22
- local: :partition
23
- )
24
- %>
25
- </select>
26
- </div>
27
- </div>
28
- </div>
29
-
30
- <hr>
31
- </div>
1
+ <%== partial('errors/title_with_select') %>
32
2
 
33
3
  <div class="container">
34
4
  <div class="row mb-5">
35
5
  <div class="col-sm-12">
36
- <%== partial('explorer/partition/watermark_offsets') %>
6
+ <%== partial('explorer/topic/partitions') %>
7
+
8
+ <% if @limited %>
9
+ <%== partial('explorer/topic/limited') %>
10
+ <% end %>
37
11
 
38
- <% if @watermark_offsets.empty? %>
39
- <%== partial 'errors/no_errors' %>
40
- <% elsif @watermark_offsets.cleaned? %>
41
- <%== partial 'errors/cleaned' %>
12
+ <% if @error_messages.empty? && params.current_page == 1 %>
13
+ <%== partial 'explorer/topic/empty' %>
42
14
  <% else %>
43
- <table class="processes bg-white table table-hover table-bordered table-striped mb-0 align-middle">
44
- <thead>
45
- <tr class="align-middle">
46
- <th>Origin</th>
47
- <th>Process name</th>
48
- <th>Error</th>
49
- <th>Occurred at</th>
50
- <th></th>
51
- </tr>
52
- </thead>
53
- <tbody>
54
- <%==
55
- each_partial(
56
- @error_messages,
57
- 'errors/error',
58
- local: :error_msg
59
- )
60
- %>
61
- </tbody>
62
- </table>
15
+ <%== partial 'errors/table' %>
63
16
  <% end %>
64
17
  </div>
65
18
  </div>
@@ -0,0 +1,17 @@
1
+ <%== partial('errors/title_with_select') %>
2
+
3
+ <div class="container">
4
+ <div class="row mb-5">
5
+ <div class="col-sm-12">
6
+ <%== partial('explorer/partition/watermark_offsets') %>
7
+
8
+ <% if @watermark_offsets.empty? %>
9
+ <%== partial 'errors/no_errors' %>
10
+ <% elsif @watermark_offsets.cleaned? %>
11
+ <%== partial 'errors/cleaned' %>
12
+ <% else %>
13
+ <%== partial 'errors/table' %>
14
+ <% end %>
15
+ </div>
16
+ </div>
17
+ </div>
@@ -6,7 +6,7 @@
6
6
 
7
7
  <% if @topic_id %>
8
8
  <li class="breadcrumb-item">
9
- <a href="<%= root_path('explorer', @topic_id, 0) %>">
9
+ <a href="<%= root_path('explorer', @topic_id) %>">
10
10
  <%= @topic_id %>
11
11
  </a>
12
12
  </li>
@@ -1,7 +1,10 @@
1
- <% if message.is_a?(Integer) %>
1
+ <% if message.is_a?(Array) %>
2
2
  <tr>
3
3
  <td class="text-muted">
4
- <%= message %>
4
+ <%= message[0] %>
5
+ </td>
6
+ <td class="text-muted">
7
+ <%= message[1] %>
5
8
  </td>
6
9
  <td colspan="3" class="text-center text-muted">
7
10
  This message has either been removed or compacted and is no longer available.
@@ -9,6 +12,9 @@
9
12
  </tr>
10
13
  <% else %>
11
14
  <tr>
15
+ <td>
16
+ <%= message.partition %>
17
+ </td>
12
18
  <td>
13
19
  <%= message.offset %>
14
20
  </td>
@@ -3,5 +3,5 @@
3
3
  <% else %>
4
4
  <option value="<%= root_path('explorer', @topic_id, partition) %>">
5
5
  <% end %>
6
- <%= partition %>
6
+ <%= partition || 'All' %>
7
7
  </option>
@@ -2,7 +2,7 @@
2
2
  <div class="card" >
3
3
  <div class="card-body p-2">
4
4
  <p class="card-text mb-0 p-2">
5
- <a href="<%= root_path('explorer', topic[:topic_name], 0) %>">
5
+ <a href="<%= root_path('explorer', topic[:topic_name]) %>">
6
6
  <%= topic[:topic_name] %> /
7
7
  <%= topic[:partition_count] %>
8
8
  </a>
@@ -1,6 +1,7 @@
1
1
  <table class="processes bg-white table table-hover table-bordered table-striped mb-0 align-middle">
2
2
  <thead>
3
3
  <tr class="align-middle">
4
+ <th>Partition</th>
4
5
  <th>Offset</th>
5
6
  <th>Timestamp</th>
6
7
  <th>Key</th>
@@ -17,7 +17,7 @@
17
17
  <select class="form-select form-select-sm mb-0 form-control" id="current-partition">
18
18
  <%==
19
19
  each_partial(
20
- @partitions_count.times.to_a,
20
+ [nil] + @partitions_count.times.to_a,
21
21
  'explorer/partition_option',
22
22
  local: :partition
23
23
  )
@@ -0,0 +1,3 @@
1
+ <div class="alert alert-info mt-4" role="alert">
2
+ This topic is empty and does not contain any data in any of the partitions.
3
+ </div>
@@ -0,0 +1,4 @@
1
+ <div class="alert alert-info mt-4 mb-4" role="alert">
2
+ Due to many partitions, only part of the data is visible on each page.
3
+ Please navigate through the pages to view all data.
4
+ </div>
@@ -0,0 +1,11 @@
1
+ <p class="text-end mb-4">
2
+ Partitions:
3
+ <span class="badge bg-secondary mt-1 mb-1">
4
+ total: <%= @partitions_count %>
5
+ </span>
6
+
7
+ <span class="badge bg-secondary mt-1 mb-1">
8
+ visible:
9
+ <%= [@active_partitions.first, @active_partitions.last].uniq.join(' to ') %>
10
+ </span>
11
+ </p>
@@ -0,0 +1,49 @@
1
+ <div class="container mb-4">
2
+ <div class="row">
3
+ <div class="col">
4
+ <h3>
5
+ <%= @topic_id %>
6
+ </h3>
7
+ </div>
8
+
9
+ <div class="col">
10
+ <div class="col-auto text-end">
11
+ <label class="col-form-label">Partition</label>
12
+ </div>
13
+ </div>
14
+
15
+ <div class="col pt-1 mb-0 pb-0">
16
+ <div class="col-auto">
17
+ <select class="form-select form-select-sm mb-0 form-control" id="current-partition">
18
+ <%==
19
+ each_partial(
20
+ [nil] + @partitions_count.times.to_a,
21
+ 'explorer/partition_option',
22
+ local: :partition
23
+ )
24
+ %>
25
+ </select>
26
+ </div>
27
+ </div>
28
+ </div>
29
+
30
+ <hr>
31
+ </div>
32
+
33
+ <div class="container">
34
+ <div class="row mb-5">
35
+ <div class="col-sm-12">
36
+ <%== partial('explorer/topic/partitions') %>
37
+
38
+ <% if @limited %>
39
+ <%== partial('explorer/topic/limited') %>
40
+ <% end %>
41
+
42
+ <% if @messages.empty? && params.current_page == 1 %>
43
+ <%== partial 'explorer/topic/empty' %>
44
+ <% else %>
45
+ <%== partial('explorer/partition/messages') %>
46
+ <% end %>
47
+ </div>
48
+ </div>
49
+ </div>
@@ -31,7 +31,7 @@
31
31
  </a>
32
32
  </li>
33
33
  <li class="nav-item ms-3">
34
- <a class="nav-link <%= nav_class(start_with: '/errors') %>" href="<%= root_path('errors/0') %>">
34
+ <a class="nav-link <%= nav_class(start_with: '/errors') %>" href="<%= root_path('errors') %>">
35
35
  Errors
36
36
  </a>
37
37
  </li>
@@ -3,7 +3,7 @@
3
3
  <% if topic[:topic_name] != '__consumer_offsets' %>
4
4
  <tr>
5
5
  <td>
6
- <a href="<%= root_path('explorer', topic[:topic_name], 0) %>">
6
+ <a href="<%= root_path('explorer', topic[:topic_name]) %>">
7
7
  <%= topic[:topic_name] %>
8
8
  </a>
9
9
  <td>
@@ -1,4 +1,4 @@
1
- <% if error_msg.is_a?(Integer) %>
1
+ <% if error_msg.is_a?(Array) %>
2
2
  <tr>
3
3
  <td colspan="5" class="text-center text-muted">
4
4
  This error has either been removed or compacted and is no longer available.
@@ -1,28 +1,32 @@
1
- <% if @current_page && (@current_page > 1 || @next_page) %>
1
+ <% if @pagination && @pagination.paginate? %>
2
2
  <div id="pagination" class="container mb-5">
3
3
  <div class="row">
4
4
  <nav>
5
5
  <ul class="pagination justify-content-center">
6
- <li class="page-item <%= 'disabled' if @current_page <= 1 %>">
7
- <a class="page-link" href="<%= current_path(page: 1) %>">
6
+ <li class="page-item <%= 'disabled' unless @pagination.first_offset? %>">
7
+ <a class="page-link" href="<%= current_path(@pagination.offset_key => @pagination.first_offset) %>">
8
8
  <span>&laquo;</span>
9
9
  </a>
10
10
  </li>
11
11
 
12
- <li class="page-item <%= 'disabled' if @current_page <= 1 %>">
13
- <a class="page-link" href="<%= current_path(page: @current_page - 1) %>">
12
+ <li class="page-item <%= 'disabled' unless @pagination.previous_offset? %>">
13
+ <a class="page-link" href="<%= current_path(@pagination.offset_key => @pagination.previous_offset) %>">
14
14
  <span>&lsaquo; Prev</span>
15
15
  </a>
16
16
  </li>
17
17
 
18
- <li class="page-item active disabled">
19
- <a class="page-link" href="<%= current_path(page: @current_page) %>">
20
- <span><%= @current_page %></span>
21
- </a>
22
- </li>
18
+ <% if @pagination.current_offset? %>
19
+ <li class="page-item active disabled">
20
+ <a class="page-link" href="<%= current_path(@pagination.offset_key => @pagination.current_offset) %>">
21
+ <span>
22
+ <%= @pagination.current_label %>
23
+ </span>
24
+ </a>
25
+ </li>
26
+ <% end %>
23
27
 
24
- <li class="page-item <%= 'disabled' unless @next_page %>">
25
- <a class="page-link" href="<%= current_path(page: @next_page) %>">
28
+ <li class="page-item <%= 'disabled' unless @pagination.next_offset? %>">
29
+ <a class="page-link" href="<%= current_path(@pagination.offset_key => @pagination.next_offset) %>">
26
30
  <span>Next &rsaquo;</span>
27
31
  </a>
28
32
  </li>
@@ -3,6 +3,6 @@
3
3
  module Karafka
4
4
  module Web
5
5
  # Current gem version
6
- VERSION = '0.6.1'
6
+ VERSION = '0.6.2'
7
7
  end
8
8
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karafka-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -35,7 +35,7 @@ cert_chain:
35
35
  Qf04B9ceLUaC4fPVEz10FyobjaFoY4i32xRto3XnrzeAgfEe4swLq8bQsR3w/EF3
36
36
  MGU0FeSV2Yj7Xc2x/7BzLK8xQn5l7Yy75iPF+KP3vVmDHnNl
37
37
  -----END CERTIFICATE-----
38
- date: 2023-06-25 00:00:00.000000000 Z
38
+ date: 2023-07-22 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: erubi
@@ -218,7 +218,15 @@ files:
218
218
  - lib/karafka/web/ui/controllers/status.rb
219
219
  - lib/karafka/web/ui/helpers/application_helper.rb
220
220
  - lib/karafka/web/ui/lib/hash_proxy.rb
221
- - lib/karafka/web/ui/lib/paginate_array.rb
221
+ - lib/karafka/web/ui/lib/paginations/base.rb
222
+ - lib/karafka/web/ui/lib/paginations/offset_based.rb
223
+ - lib/karafka/web/ui/lib/paginations/page_based.rb
224
+ - lib/karafka/web/ui/lib/paginations/paginators/arrays.rb
225
+ - lib/karafka/web/ui/lib/paginations/paginators/base.rb
226
+ - lib/karafka/web/ui/lib/paginations/paginators/partitions.rb
227
+ - lib/karafka/web/ui/lib/paginations/paginators/sets.rb
228
+ - lib/karafka/web/ui/lib/ttl_cache.rb
229
+ - lib/karafka/web/ui/models/cluster_info.rb
222
230
  - lib/karafka/web/ui/models/consumer_group.rb
223
231
  - lib/karafka/web/ui/models/counters.rb
224
232
  - lib/karafka/web/ui/models/health.rb
@@ -264,7 +272,10 @@ files:
264
272
  - lib/karafka/web/ui/pro/views/errors/_breadcrumbs.erb
265
273
  - lib/karafka/web/ui/pro/views/errors/_error.erb
266
274
  - lib/karafka/web/ui/pro/views/errors/_partition_option.erb
275
+ - lib/karafka/web/ui/pro/views/errors/_table.erb
276
+ - lib/karafka/web/ui/pro/views/errors/_title_with_select.erb
267
277
  - lib/karafka/web/ui/pro/views/errors/index.erb
278
+ - lib/karafka/web/ui/pro/views/errors/partition.erb
268
279
  - lib/karafka/web/ui/pro/views/errors/show.erb
269
280
  - lib/karafka/web/ui/pro/views/explorer/_breadcrumbs.erb
270
281
  - lib/karafka/web/ui/pro/views/explorer/_detail.erb
@@ -280,6 +291,10 @@ files:
280
291
  - lib/karafka/web/ui/pro/views/explorer/partition/_messages.erb
281
292
  - lib/karafka/web/ui/pro/views/explorer/partition/_watermark_offsets.erb
282
293
  - lib/karafka/web/ui/pro/views/explorer/show.erb
294
+ - lib/karafka/web/ui/pro/views/explorer/topic.erb
295
+ - lib/karafka/web/ui/pro/views/explorer/topic/_empty.erb
296
+ - lib/karafka/web/ui/pro/views/explorer/topic/_limited.erb
297
+ - lib/karafka/web/ui/pro/views/explorer/topic/_partitions.erb
283
298
  - lib/karafka/web/ui/pro/views/health/_breadcrumbs.erb
284
299
  - lib/karafka/web/ui/pro/views/health/_partition.erb
285
300
  - lib/karafka/web/ui/pro/views/health/index.erb
metadata.gz.sig CHANGED
Binary file
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Karafka
4
- module Web
5
- module Ui
6
- module Lib
7
- # A simple wrapper for paginating array related data structures
8
- class PaginateArray
9
- # @param array [Array] array we want to paginate
10
- # @param current_page [Integer] page we want to be on
11
- # @return [Array<Array, <Integer, nil>>] Array with two elements: first is the array with
12
- # data of the given page and second is the next page number of nil in case there is
13
- # no next page (end of data)
14
- def call(array, current_page)
15
- slices = array.each_slice(per_page).to_a
16
-
17
- current_data = slices[current_page - 1] || []
18
-
19
- if slices.count >= current_page - 1 && current_data.size >= per_page
20
- next_page = current_page + 1
21
- else
22
- next_page = nil
23
- end
24
-
25
- [current_data, next_page]
26
- end
27
-
28
- private
29
-
30
- # @return [Integer] how many elements should we display in the UI
31
- def per_page
32
- ::Karafka::Web.config.ui.per_page
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end