From 7159857639029668756e2ff0888750630ace5fa2 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 13 Apr 2020 12:41:26 +0200 Subject: [PATCH] luci-base: luci.js: use standard indicator framework for poll status Signed-off-by: Jo-Philipp Wich (cherry picked from commit 68b2ce84ece62e3aec98b9be31e61ec5f6cdba2d) --- .../htdocs/luci-static/resources/luci.js | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js index 6adbf2a50..657983210 100644 --- a/modules/luci-base/htdocs/luci-static/resources/luci.js +++ b/modules/luci-base/htdocs/luci-static/resources/luci.js @@ -2228,18 +2228,6 @@ Object.assign(env, setenv); - document.addEventListener('poll-start', function(ev) { - document.querySelectorAll('[id^="xhr_poll_status"]').forEach(function(e) { - e.style.display = (e.id == 'xhr_poll_status_off') ? 'none' : ''; - }); - }); - - document.addEventListener('poll-stop', function(ev) { - document.querySelectorAll('[id^="xhr_poll_status"]').forEach(function(e) { - e.style.display = (e.id == 'xhr_poll_status_on') ? 'none' : ''; - }); - }); - var domReady = new Promise(function(resolveFn, rejectFn) { document.addEventListener('DOMContentLoaded', resolveFn); }); @@ -2699,6 +2687,16 @@ LuCI.prototype.notifySessionExpiry(); }); + document.addEventListener('poll-start', function(ev) { + uiClass.showIndicator('poll-status', _('Refreshing'), function(ev) { + Request.poll.active() ? Request.poll.stop() : Request.poll.start(); + }); + }); + + document.addEventListener('poll-stop', function(ev) { + uiClass.showIndicator('poll-status', _('Paused'), null, 'inactive'); + }); + return Promise.all([ this.probeSystemFeatures(), this.probePreloadClasses() -- 2.25.1