luci-base: luci.js: use standard indicator framework for poll status
authorJo-Philipp Wich <jo@mein.io>
Mon, 13 Apr 2020 10:41:26 +0000 (12:41 +0200)
committerJo-Philipp Wich <jo@mein.io>
Thu, 7 May 2020 17:40:50 +0000 (19:40 +0200)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 68b2ce84ece62e3aec98b9be31e61ec5f6cdba2d)

modules/luci-base/htdocs/luci-static/resources/luci.js

index 6adbf2a50660ee8031e19dd270d9c822082f0fd3..6579832104a73f6db4ecb0298d811e4f9ca99bc9 100644 (file)
 
                        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);
                        });
                                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()