Changing UI Refresh to a Longer Poll + Manual Refresh (#587)

* Added refresh button and reduced lag for large campaigns (#565)

* Amended refresh function to allow manual refreshes

Moved the function out of document.ready and tied it to the button. Also reduced automatic refresh to 60 seconds, to make it easier for medium - large campaigns to be viewed without lagging.

* Amended refresh function to allow manual refreshes

* Update campaign_results.html

* Re-building the campaign_results JS
pull/604/head
Jordan Wright 2017-04-05 22:20:00 -05:00 committed by GitHub
parent 2514bccb05
commit bddb9fdb28
3 changed files with 704 additions and 692 deletions

File diff suppressed because one or more lines are too long

View File

@ -399,6 +399,8 @@ function poll() {
} }
}) })
map.bubbles(bubbles) map.bubbles(bubbles)
$("#refresh_message").hide()
$("#refresh_btn").show()
}) })
} }
@ -674,18 +676,25 @@ function load() {
errorFlash(" Campaign not found!") errorFlash(" Campaign not found!")
}) })
} }
$(document).ready(function() {
load(); var setRefresh
// Start the polling loop
function refresh() { function refresh() {
if (!doPoll) { if (!doPoll) {
return; return;
} }
$("#refresh_message").show() $("#refresh_message").show()
$("#refresh_btn").hide()
poll() poll()
$("#refresh_message").hide() clearTimeout(setRefresh)
setTimeout(refresh, 10000) setRefresh = setTimeout(refresh, 60000)
}; };
$(document).ready(function() {
load();
// Start the polling loop // Start the polling loop
setTimeout(refresh, 10000)
// Start the polling loop
setRefresh = setTimeout(refresh, 60000)
}) })

View File

@ -54,6 +54,9 @@
<button type="button" class="btn btn-danger" data-toggle="tooltip" onclick="deleteCampaign()"> <button type="button" class="btn btn-danger" data-toggle="tooltip" onclick="deleteCampaign()">
<i class="fa fa-trash-o fa-lg"></i> Delete <i class="fa fa-trash-o fa-lg"></i> Delete
</button> </button>
<button id="refresh_btn" type="button" class="btn btn-blue" data-toggle="tooltip" onclick="refresh()">
<i class="fa fa-refresh fa-lg"></i> Refresh
</button>
<span id="refresh_message"> <span id="refresh_message">
<i class="fa fa-spin fa-spinner"></i> Refreshing <i class="fa fa-spin fa-spinner"></i> Refreshing
</span> </span>