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:
parent
b86f077522
commit
ed06e2dcd2
3 changed files with 30 additions and 1 deletions
|
@ -165,6 +165,13 @@ module Sidekiq
|
||||||
redirect "#{root_path}queues"
|
redirect "#{root_path}queues"
|
||||||
end
|
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
|
get "/retries/:score" do
|
||||||
halt 404 unless params[:score]
|
halt 404 unless params[:score]
|
||||||
@score = params[:score].to_f
|
@score = params[:score].to_f
|
||||||
|
|
|
@ -75,6 +75,24 @@ class TestWeb < MiniTest::Unit::TestCase
|
||||||
end
|
end
|
||||||
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
|
it 'can display scheduled' do
|
||||||
get '/scheduled'
|
get '/scheduled'
|
||||||
assert_equal 200, last_response.status
|
assert_equal 200, last_response.status
|
||||||
|
|
|
@ -7,6 +7,7 @@ table class="table table-striped table-bordered"
|
||||||
tr
|
tr
|
||||||
th Class
|
th Class
|
||||||
th Arguments
|
th Arguments
|
||||||
|
th
|
||||||
- @messages.each_with_index do |msg, index|
|
- @messages.each_with_index do |msg, index|
|
||||||
tr
|
tr
|
||||||
td= msg['class']
|
td= msg['class']
|
||||||
|
@ -17,5 +18,8 @@ table class="table table-striped table-bordered"
|
||||||
.collapse[id="worker_#{index}"]= msg['args']
|
.collapse[id="worker_#{index}"]= msg['args']
|
||||||
- else
|
- else
|
||||||
= msg['args']
|
= 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}" }
|
== slim :_paging, :locals => { :url => "#{root_path}queues/#{@name}" }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue