Module: Sidekiq::TUI::Tabs::SetTab
- Defined in:
- lib/sidekiq/tui/tabs/set_tab.rb
Constant Summary
Constants included from Paginator
Instance Method Summary collapse
- #alter_rows!(action) ⇒ Object
- #controls ⇒ Object
- #features ⇒ Object
- #refresh_data ⇒ Object
- #refresh_data_for_set ⇒ Object
- #render(tui, frame, area) ⇒ Object
Methods included from Filtering
#append_to_filter, #current_filter, #filtering?, #on_filter_change, #remove_last_char_from_filter, #start_filtering, #stop_and_clear_filtering, #stop_filtering
Methods included from Paginator
Instance Method Details
#alter_rows!(action) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/sidekiq/tui/tabs/set_tab.rb', line 23 def alter_rows!(action) # log(to_s, @data[:selected]) set = set_class.new each_selection do |id| score, jid = id.split("|") item = set.fetch(score, jid)&.first item&.send(action) end end |
#controls ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sidekiq/tui/tabs/set_tab.rb', line 12 def controls @controls ||= super + [{code: "D", modifiers: ["shift"], display: "D", description: "Delete", action: ->(tui, tab) { tab.alter_rows!(:delete) }, refresh: true}, {code: "R", modifiers: ["shift"], display: "R", description: "Retry", action: ->(tui, tab) { tab.alter_rows!(:retry) }, refresh: true}, {code: "E", modifiers: ["shift"], display: "E", description: "Enqueue", action: ->(tui, tab) { tab.alter_rows!(:add_to_queue) }, refresh: true}, {code: "K", modifiers: ["shift"], display: "K", description: "Kill", action: ->(tui, tab) { tab.alter_rows!(:kill) }, refresh: true}] end |
#features ⇒ Object
8 9 10 |
# File 'lib/sidekiq/tui/tabs/set_tab.rb', line 8 def features %i[selectable pageable filterable] end |
#refresh_data ⇒ Object
33 34 35 36 |
# File 'lib/sidekiq/tui/tabs/set_tab.rb', line 33 def refresh_data refresh_data_for_stats refresh_data_for_set end |
#refresh_data_for_set ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/sidekiq/tui/tabs/set_tab.rb', line 38 def refresh_data_for_set set = set_class.new f = current_filter pager, rows, current, total = if f && f.size > 2 rows = set.scan(f).to_a sz = rows.size [Sidekiq::TUI::PageOptions.new(1, sz), rows, 1, sz] else pager = @data.dig(:table, :pager) || Sidekiq::TUI::PageOptions.new(1, 25) current, total, items = page(set.name, pager.page, pager.size) rows = items.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) } [pager, rows, current, total] end @data.merge!( table: {pager:, rows:, current_page: current, total:, next_page: (current * pager.size < total) ? pager.page + 1 : nil, row_ids: rows.map { |job| [job.score, job["jid"]].join("|") }} ) end |
#render(tui, frame, area) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/sidekiq/tui/tabs/set_tab.rb', line 59 def render(tui, frame, area) chunks = stats_content_split(tui, area) render_stats_section(tui, frame, chunks[0]) render_table(tui, frame, chunks[1]) do { title: t(name), header: ["☑️", "When", "Queue", "Job", "Arguments"].map { |x| t(x) }, widths: [ tui.constraint_length(5), tui.constraint_length(24), tui.constraint_length(20), tui.constraint_length(30), tui.constraint_fill(1) ] }.tap do |h| cells = @data[:table][:rows].map { |entry| [ selected?(entry) ? "✅" : "", entry.at, entry.queue, entry.display_class, entry.display_args ] } h[:rows] = striped_rows(tui, cells) end end end |