Add pause/resume download button to the download manager

This commit is contained in:
Alex Ling
2020-03-02 16:30:05 +00:00
parent fecb96c91b
commit 30af64e9ca
4 changed files with 63 additions and 29 deletions

View File

@@ -129,7 +129,10 @@ class APIRouter < Router
get "/api/admin/mangadex/queue" do |env|
jobs = @context.queue.get_all
send_json env, jobs.to_json
send_json env, {
"jobs" => jobs,
"paused" => @context.queue.paused?
}.to_json
end
post "/api/admin/mangadex/queue/delete/:id" do |env|
@@ -145,19 +148,6 @@ class APIRouter < Router
end
end
# Delete all completed tasks from the queue
post "/api/admin/mangadex/queue/delete" do |env|
begin
@context.queue.delete_status MangaDex::JobStatus::Completed
send_json env, {"success" => true}.to_json
rescue e
send_json env, {
"success" => false,
"error" => e.message
}.to_json
end
end
post "/api/admin/mangadex/queue/retry/:id" do |env|
begin
id = env.params.url["id"]
@@ -171,9 +161,22 @@ class APIRouter < Router
end
end
post "/api/admin/mangadex/queue/retry" do |env|
post "/api/admin/mangadex/queue/:action" do |env|
begin
@context.queue.reset
action = env.params.url["action"]
case action
when "delete"
@context.queue.delete_status MangaDex::JobStatus::Completed
when "retry"
@context.queue.reset
when "pause"
@context.queue.pause
when "resume"
@context.queue.resume
else
raise "Unknown queue action #{action}"
end
send_json env, {"success" => true}.to_json
rescue e
send_json env, {