Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLAT-390] Add pagination in queues page and ability to pause/unpause inside queue page #3

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/sidekiq/web/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def self.set(key, val)
queue.clear
end

redirect "#{root_path}queues"
redirect "#{root_path}queues/#{route_params[:name]}"
end

post "/queues/:name/delete" do
Expand Down
4 changes: 2 additions & 2 deletions web/views/_poll_link.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% if current_path != '' %>
<!-- <% if current_path != '' %>
<% if params[:poll] %>
<a id="live-poll" class="btn btn-primary active" href="<%= root_path + current_path %>"><%= t('StopPolling') %></a>
<% else %>
<a id="live-poll" class="btn btn-primary" href="<%= root_path + current_path %>?<%= qparams(poll: true) %>"><%= t('LivePoll') %></a>
<% end %>
<% end %>
<% end %> -->
30 changes: 29 additions & 1 deletion web/views/queue.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
<header class="row">
<style>
.btn-warning {
color: #fff !important;
background-color: #cc8015 !important;
border-color: #eea236 !important;
background-image: none !important;
}

.label-warning {
background-color: #cc8015 !important;
}
</style>
<div class="col-sm-5">
<h3>
<%= t('CurrentMessagesInQueue', :queue => h(@name)) %>
<% if @queue.paused? %>
<% if (@paused = @queue.paused?) %>
<span class="label label-danger"><%= t('Paused') %></span>
<% end %>
<span class="badge badge-secondary"><%= number_with_delimiter(@total_size) %></span>
<form action="<%= root_path %>queues/<%= CGI.escape(@queue.name) %>" method="post">
<%= csrf_tag %>
<% if @queue.is_non_work_hour_only? %>
<input class="btn btn-danger btn-xs" type="submit" name="unset_non_work_hour" value="<%= t('StartExecution') %>" data-confirm="<%= t('AreYouSureUnpauseNonWorkHourQueue', :queue => h(@queue.name)) %>"/>
<% else %>
<input class="btn btn-danger btn-xs" type="submit" name="set_non_work_hour" value="<%= t('PauseTillNonWorkHours') %>" data-confirm="<%= t('AreYouSureNonWorkHourQueue', :queue => h(@queue.name)) %>"/>
<% end %>
<% unless @queue.is_non_work_hour_only? %>
<% if @queue.paused? %>
<input class="btn btn-warning btn-xs" type="submit" name="unpause" value="<%= t('Unpause') %>"/>
<% else %>
<input class="btn btn-warning btn-xs" type="submit" name="pause" value="<%= t('Pause') %>"/>
<% end %>
<% end %>
<input class="btn btn-danger btn-xs" type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSureDeleteQueue', :queue => h(@queue.name)) %>"/>
</form>
</h3>
</div>
<div class="col-sm-4 pull-right flip">
Expand Down
6 changes: 5 additions & 1 deletion web/views/queues.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
background-color: #cc8015 !important;
}
</style>
<% @count = (params['per_page'] || 20).to_i %>
<% @current_page = (params['page'] || 1).to_i %>
<% @total_size = @queues.size %>
<table class="queues table table-hover table-bordered table-striped table-white">
<thead>
<th><%= t('Queue') %></th>
<th><%= t('Size') %></th>
<th><%= t('Latency') %></th>
<th class="col-md-3"><%= t('Actions') %></th>
</thead>
<% @queues.each do |queue| %>
<% @queues.sort_by(&:name).each_slice(@count).to_a[@current_page - 1].each do |queue| %>
<tr>
<td>
<a href="<%= root_path %>queues/<%= CGI.escape(queue.name) %>"><%= h queue.name %></a>
Expand Down Expand Up @@ -54,4 +57,5 @@
</tr>
<% end %>
</table>
<%= erb :_paging, locals: { url: "#{root_path}queues" } %>
</div>