From 6475221d54be41dbfa4639c4cef5046b186e296f Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Tue, 18 Dec 2018 15:46:53 +0100 Subject: modules: use configurable poll interval Make poll interval configurable. Use option from ---- config core 'main' option pollinterval '5' --- This will only be used if the interval option is less or equal zero. If the poll interval is not configured then a default value of 5 seconds is used. Signed-off-by: Florian Eckert --- modules/luci-base/htdocs/luci-static/resources/xhr.js | 4 ++-- modules/luci-base/luasrc/view/header.htm | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'modules/luci-base') diff --git a/modules/luci-base/htdocs/luci-static/resources/xhr.js b/modules/luci-base/htdocs/luci-static/resources/xhr.js index 8292fcdb6c..3133898b5e 100644 --- a/modules/luci-base/htdocs/luci-static/resources/xhr.js +++ b/modules/luci-base/htdocs/luci-static/resources/xhr.js @@ -169,8 +169,8 @@ XHR.post = function(url, data, callback) { } XHR.poll = function(interval, url, data, callback, post) { - if (isNaN(interval) || interval < 1) - interval = 5; + if (isNaN(interval) || interval <= 0) + interval = L.env.pollinterval; if (!XHR._q) { XHR._t = 0; diff --git a/modules/luci-base/luasrc/view/header.htm b/modules/luci-base/luasrc/view/header.htm index 2813c4d943..d68e39f917 100644 --- a/modules/luci-base/luasrc/view/header.htm +++ b/modules/luci-base/luasrc/view/header.htm @@ -18,6 +18,7 @@ resource = resource, scriptname = luci.http.getenv("SCRIPT_NAME"), pathinfo = luci.http.getenv("PATH_INFO"), - requestpath = luci.dispatcher.context.requestpath + requestpath = luci.dispatcher.context.requestpath, + pollinterval = luci.config.main.pollinterval or 5 }) %>); -- cgit v1.2.3 From 3b9ba0210e9da62861f260b4ed367e2a05789afe Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Thu, 20 Dec 2018 10:10:26 +0100 Subject: luci-base: use default poll interval Replace all XHR poll time number with -1 so they will use the default poll interval time value from "/etc/config/luci". If this is not set then 5 seconds as default is used. Signed-off-by: Florian Eckert --- modules/luci-base/luasrc/view/lease_status.htm | 2 +- modules/luci-base/luasrc/view/wifi_assoclist.htm | 2 +- modules/luci-mod-network/luasrc/view/admin_network/switch_status.htm | 2 +- modules/luci-mod-system/luasrc/view/admin_system/clock_status.htm | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'modules/luci-base') diff --git a/modules/luci-base/luasrc/view/lease_status.htm b/modules/luci-base/luasrc/view/lease_status.htm index 15b6b6908e..bf2a8968d1 100644 --- a/modules/luci-base/luasrc/view/lease_status.htm +++ b/modules/luci-base/luasrc/view/lease_status.htm @@ -1,5 +1,5 @@