mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Prevent redundant polling in the web UI
This commit is contained in:
parent
b3bea3f36b
commit
7982e4e890
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
|
assert_match /#{msg['args'][2]}/, last_response.body
|
||||||
end
|
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
|
it 'escape job args and error messages' do
|
||||||
# on /retries page
|
# on /retries page
|
||||||
params = add_xss_retry
|
params = add_xss_retry
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
<div class="navbar-toggle collapsed navbar-livereload">
|
<div class="navbar-toggle collapsed navbar-livereload">
|
||||||
<%= erb :_poll %>
|
<%= erb :_poll_link %>
|
||||||
<% if Sidekiq::Web.app_url %>
|
<% if Sidekiq::Web.app_url %>
|
||||||
<a class="btn btn-inverse" href="<%= Sidekiq::Web.app_url %>">Back to App</a>
|
<a class="btn btn-inverse" href="<%= Sidekiq::Web.app_url %>">Back to App</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
<ul class="nav navbar-nav navbar-right navbar-livereload" data-navbar="static">
|
<ul class="nav navbar-nav navbar-right navbar-livereload" data-navbar="static">
|
||||||
<li>
|
<li>
|
||||||
<div class="poll-wrapper pull-right">
|
<div class="poll-wrapper pull-right">
|
||||||
<%= erb :_poll %>
|
<%= erb :_poll_link %>
|
||||||
<% if Sidekiq::Web.app_url %>
|
<% if Sidekiq::Web.app_url %>
|
||||||
<a class="btn btn-inverse" href="<%= Sidekiq::Web.app_url %>">Back to App</a>
|
<a class="btn btn-inverse" href="<%= Sidekiq::Web.app_url %>">Back to App</a>
|
||||||
<% end %>
|
<% 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 current_path != '' %>
|
||||||
<% if params[:poll] %>
|
<% 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>
|
<a id="live-poll" class="btn btn-primary active" href="<%= root_path + current_path %>"><%= t('StopPolling') %></a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a id="live-poll" class="btn btn-primary" href="<%= root_path + current_path %>?<%= qparams(poll: true) %>"><%= t('LivePoll') %></a>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
<%= erb :_footer %>
|
<%= erb :_footer %>
|
||||||
|
<%= erb :_poll_js %>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue