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

Modified web ui to add a delete button to cancel jobs in queue

This commit is contained in:
David Leung 2012-10-23 16:11:14 -07:00
parent b86f077522
commit ed06e2dcd2
3 changed files with 30 additions and 1 deletions

View file

@ -165,6 +165,13 @@ module Sidekiq
redirect "#{root_path}queues"
end
post "/queues/:name/delete" do
Sidekiq.redis do |conn|
conn.lrem("queue:#{params[:name]}", 0, params[:key_val])
end
redirect "#{root_path}queues/#{params[:name]}"
end
get "/retries/:score" do
halt 404 unless params[:score]
@score = params[:score].to_f

View file

@ -74,6 +74,24 @@ class TestWeb < MiniTest::Unit::TestCase
refute conn.smembers('queues').include?('foo')
end
end
it 'can delete a job' do
Sidekiq.redis do |conn|
conn.rpush('queue:foo', "{}")
conn.rpush('queue:foo', "{\"foo\":\"bar\"}")
conn.rpush('queue:foo', "{\"foo2\":\"bar2\"}")
end
get '/queues/foo'
assert_equal 200, last_response.status
post '/queues/foo/delete', key_val: "{\"foo\":\"bar\"}"
assert_equal 302, last_response.status
Sidekiq.redis do |conn|
refute conn.lrange('queue:foo', 0, -1).include?("{\"foo\":\"bar\"}")
end
end
it 'can display scheduled' do
get '/scheduled'

View file

@ -7,6 +7,7 @@ table class="table table-striped table-bordered"
tr
th Class
th Arguments
th
- @messages.each_with_index do |msg, index|
tr
td= msg['class']
@ -17,5 +18,8 @@ table class="table table-striped table-bordered"
.collapse[id="worker_#{index}"]= msg['args']
- else
= msg['args']
td
form action="#{root_path}queues/#{@name}/delete" method="post"
input name="key_val" value="#{msg.to_json}" type="hidden"
input.btn.btn-danger.btn-mini type="submit" name="delete" value="Delete" data-confirm="Are you sure you want to delete this job?"
== slim :_paging, :locals => { :url => "#{root_path}queues/#{@name}" }