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

Improve expiring locks display with filtering and pagination #842

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/sidekiq_unique_jobs/web.rb
Expand Up @@ -61,12 +61,12 @@ def self.registered(app) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
page_size: @count,
)

erb(unique_template(:locks))
erb(unique_template(:expiring_locks))
end

app.get "/locks/delete_all" do
digests.delete_by_pattern("*", count: digests.count)
expiring_digests.delete_by_pattern("*", count: digests.count)
expiring_digests.delete_by_pattern("*", count: expiring_digests.count)
redirect_to :locks
end

Expand Down
59 changes: 59 additions & 0 deletions lib/sidekiq_unique_jobs/web/views/expiring_locks.erb
@@ -0,0 +1,59 @@
<header class="row">
<div class="col-sm-5">
<h3>
<%= t('Locks') %>
</h3>
</div>
<form action="<%= root_path %>expiring_locks" class="form form-inline" method="get">
<%= csrf_tag %>
<input name="filter" class="form-control" type="text" value="<%= @filter %>" />

<button class="btn btn-default" type="submit">
<%= t('Filter') %>
</button>

</form>

<% if @locks.any? && @total_size > @count %>
<div class="col-sm-4">
<%= erb unique_template(:_paging), locals: { url: "#{root_path}expiring_locks" } %>
</div>
<% end %>
</header>

<% if @locks.any? %>
<div class="table_container">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th><%= t('Delete') %></th>
<th><%= t('Digest') %></th>
<th><%= t('Lock') %></th>
<th><%= t('Locks') %></th>
<th><%= t('Since') %></th>
</tr>
</thead>
<% @locks.each do |lock| %>
<tbody>
<tr class="lock-row">
<td>
<form action="<%= root_path %>locks/<%= lock.key %>/delete" method="get">
<%= csrf_tag %>
<input name="lock" value="<%= h lock.key %>" type="hidden" />
<input class="btn btn-danger btn-xs" type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSure') %>" />
</form>
</td>
<td><a href="<%= root_path %>locks/<%= lock.key %>"><%= lock.key %></a></td>
<td><%= lock.info["lock"] %></td>
<td><%= lock.locked.count %></td>
<td><%= _safe_relative_time(lock.created_at) %></td>
</tr>
</tbody>
<% end %>
</table>

<form action="<%= root_path %>locks/delete_all" method="get">
<input class="btn btn-danger btn-xs" type="submit" name="delete_all" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSure') %>" />
</form>
</div>
<% end %>