mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00

* Introduce the ability to pause queue from the UI Considering sidekiq web UI allow to perform complex tasks with ease. Having the ability to pause a queue during an emergency (or operational intense) scenarios would come in quite handy. This PR introduces a new button to under the "Actions" column on `sidekiq/queues` pages, right next to the `Delete` button. Depending on the state of the queue, it will according show the `Pause` or `Unpause` text, with appropriate form element that `POST`s to the same endpoint. The endpoint logic is updated to handle the new cases. Added some relevant unit tests. Adding mock `Sidekiq::Queue#pause!` and `Sidekiq::Queue#unpause!` functions to the API, which I believe will be overridden by sidekiq pro. * Remove confirmation text and switch ordering of new copy in en.yml * Only allow pause/unpause operations from sidekiq pro This means the button from UI is hidden and api route has validation in place such that it will only perform the respective pause/unpause operation on proper payload, in sidekiq pro. Its using `Sidekiq::Pro` constant as a check to detect whether or not pro is present. * Initialize Queue only once in api router action
38 lines
1.6 KiB
Text
38 lines
1.6 KiB
Text
<h3><%= t('Queues') %></h3>
|
|
|
|
<div class="table_container">
|
|
<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><%= t('Actions') %></th>
|
|
</thead>
|
|
<% @queues.each do |queue| %>
|
|
<tr>
|
|
<td>
|
|
<a href="<%= root_path %>queues/<%= CGI.escape(queue.name) %>"><%= h queue.name %></a>
|
|
<% if queue.paused? %>
|
|
<span class="label label-danger"><%= t('Paused') %></span>
|
|
<% end %>
|
|
</td>
|
|
<td><%= number_with_delimiter(queue.size) %> </td>
|
|
<td><% queue_latency = queue.latency %><%= number_with_delimiter(queue_latency.round(2)) %><%= (queue_latency < 60) ? '' : " (#{relative_time(Time.at(Time.now.to_f - queue_latency))})" %> </td>
|
|
<td class="delete-confirm">
|
|
<form action="<%=root_path %>queues/<%= CGI.escape(queue.name) %>" method="post">
|
|
<%= csrf_tag %>
|
|
<input class="btn btn-danger btn-xs" type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSureDeleteQueue', :queue => h(queue.name)) %>" />
|
|
|
|
<% if Sidekiq.pro? %>
|
|
<% if queue.paused? %>
|
|
<input class="btn btn-danger btn-xs" type="submit" name="unpause" value="<%= t('Unpause') %>" />
|
|
<% else %>
|
|
<input class="btn btn-danger btn-xs" type="submit" name="pause" value="<%= t('Pause') %>" />
|
|
<% end %>
|
|
<% end %>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</table>
|
|
</div>
|