Progress Bar for Background Process in Rails

2019-04-23 13:38发布

I have a couple of processes in my Rails application that call to an external web API - and take a long time to finish. I've considered moving them to process in the background.

I would like to be able to show the user the progress of the background process (i.e. a progress bar).

First, are there any good tutorials/learning resources on implementing a progress bar with jQuery in Rails (not related to a file upload process)? I've seen a lot of resources on displaying the graphic - but not a lot of information on how to hook the graphic updating to the actual background process.

Second, as I consider the various gems for background processing, is there one that would work better with a progress bar (i.e. Delayed Jobs, Resque, Sidekiq)?

Thank you

3条回答
We Are One
2楼-- · 2019-04-23 14:02

The gem Progress Job looks promising for providing progress updates on background jobs. At this time it looks like it works with DelayedJob.

查看更多
疯言疯语
3楼-- · 2019-04-23 14:06

Use the startAjax event to trigger a function that hide/shows the progress bar.

I just answered this question in another post.

The url for the jqueryui progress meter docs is http://jqueryui.com/progressbar/

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-04-23 14:17

I just wrote a blog post about using Sidekiq + SidekiqStatus + Bootstrap theme progress bar = to implement a progress bar. I know it's been a while since this has been asked but hopefully, others will find it useful:

How to Implement a Progress Bar Using Sidekiq Status


progress bar sample

查看更多
登录 后发表回答