1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Enable live poll from url params (#5275)

* Turn on Polling if url has param poll=true.

poll=false does nothing. This is because the page is reloaded each time polling happens, and the url param may be out of sync with the current status.
One solution would be to rewrite the URL each time the polling status changes, but that seems unnecessary.
This commit is contained in:
Benratelade 2022-04-05 08:20:09 +10:00 committed by GitHub
parent d0a4b1fdc8
commit 637e50906e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,6 +32,7 @@ function addListeners() {
})
updateFuzzyTimes();
setLivePollFromUrl();
var buttons = document.querySelectorAll(".live-poll");
if (buttons.length > 0) {
@ -83,6 +84,14 @@ function updateFuzzyTimes() {
t.cancel();
}
function setLivePollFromUrl() {
var url_params = new URL(window.location.href).searchParams
if (url_params.get("poll") == "true") {
localStorage.sidekiqLivePoll = "enabled";
}
}
function updateLivePollButton() {
if (localStorage.sidekiqLivePoll == "enabled") {
document.querySelectorAll('.live-poll-stop').forEach(box => { box.style.display = "inline-block" })