mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Merge pull request #2399 from tombenner/prevent_redundant_polling
Prevent redundant polling in the web UI
This commit is contained in:
commit
bab47b5c43
5 changed files with 14 additions and 5 deletions
|
@ -295,6 +295,12 @@ class TestWeb < Sidekiq::Test
|
|||
assert_match /#{msg['args'][2]}/, last_response.body
|
||||
end
|
||||
|
||||
it 'calls updatePage() once when polling' do
|
||||
get '/busy?poll=true'
|
||||
assert_equal 200, last_response.status
|
||||
assert_equal 1, last_response.body.scan('updatePage(').count
|
||||
end
|
||||
|
||||
it 'escape job args and error messages' do
|
||||
# on /retries page
|
||||
params = add_xss_retry
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<div class="navbar-toggle collapsed navbar-livereload">
|
||||
<%= erb :_poll %>
|
||||
<%= erb :_poll_link %>
|
||||
<% if Sidekiq::Web.app_url %>
|
||||
<a class="btn btn-inverse" href="<%= Sidekiq::Web.app_url %>">Back to App</a>
|
||||
<% end %>
|
||||
|
@ -54,7 +54,7 @@
|
|||
<ul class="nav navbar-nav navbar-right navbar-livereload" data-navbar="static">
|
||||
<li>
|
||||
<div class="poll-wrapper pull-right">
|
||||
<%= erb :_poll %>
|
||||
<%= erb :_poll_link %>
|
||||
<% if Sidekiq::Web.app_url %>
|
||||
<a class="btn btn-inverse" href="<%= Sidekiq::Web.app_url %>">Back to App</a>
|
||||
<% end %>
|
||||
|
|
5
web/views/_poll_js.erb
Normal file
5
web/views/_poll_js.erb
Normal file
|
@ -0,0 +1,5 @@
|
|||
<% if current_path != '' && params[:poll] %>
|
||||
<script>
|
||||
updatePage('<%= root_path + current_path %>')
|
||||
</script>
|
||||
<% end %>
|
|
@ -1,8 +1,5 @@
|
|||
<% if current_path != '' %>
|
||||
<% if params[:poll] %>
|
||||
<script>
|
||||
updatePage('<%= root_path + current_path %>')
|
||||
</script>
|
||||
<a id="live-poll" class="btn btn-primary active" href="<%= root_path + current_path %>"><%= t('StopPolling') %></a>
|
||||
<% else %>
|
||||
<a id="live-poll" class="btn btn-primary" href="<%= root_path + current_path %>?<%= qparams(poll: true) %>"><%= t('LivePoll') %></a>
|
|
@ -26,5 +26,6 @@
|
|||
</div>
|
||||
</div>
|
||||
<%= erb :_footer %>
|
||||
<%= erb :_poll_js %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue