luci-mod-status: reorganize poll function for index page
authorChristian Marangi <[email protected]>
Tue, 21 Nov 2023 20:37:43 +0000 (21:37 +0100)
committerPaul Donald <[email protected]>
Thu, 2 Oct 2025 12:57:49 +0000 (14:57 +0200)
Reorganize poll function for index page. Drop the external function and
use the poll_status pattern used in other page that use poll.add API.

Signed-off-by: Christian Marangi <[email protected]>
modules/luci-mod-status/htdocs/luci-static/resources/view/status/index.js

index 911c187584e56dfa682fabbc4ce830c30131fece..f19a5e4f5de450390868036d086f7981cc6dbd63 100644 (file)
@@ -24,8 +24,8 @@ function invokeIncludesLoad(includes) {
        return has_load ? Promise.all(tasks) : Promise.resolve(null);
 }
 
-function startPolling(includes, containers) {
-       var step = function() {
+return view.extend({
+       poll_status: function(includes, containers) {
                return network.flushCache().then(function() {
                        return invokeIncludesLoad(includes);
                }).then(function(results) {
@@ -59,14 +59,8 @@ function startPolling(includes, containers) {
                                ssi.classList.add('fade-in');
                        }
                });
-       };
-
-       return step().then(function() {
-               poll.add(step);
-       });
-}
+       },
 
-return view.extend({
        load: function() {
                return L.resolveDefault(fs.list('/www' + L.resource('view/status/include')), []).then(function(entries) {
                        return Promise.all(entries.filter(function(e) {
@@ -103,7 +97,9 @@ return view.extend({
                        containers.push(container);
                }
 
-               return startPolling(includes, containers).then(function() {
+               return this.poll_status(includes, containers).then(function() {
+                       return poll.add(L.bind(this.poll_status, this, includes, containers))
+               }).then(function() {
                        return rv;
                });
        },