mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 12:48:29 +00:00
Store refresh intervals in a common place for easy editing (and possibly future programatic adjustments)
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -12,6 +12,24 @@
|
||||
|
||||
var settingsLevel = 0;
|
||||
|
||||
const REFRESH_INTERVAL = {
|
||||
blocking: 10000, // 10 sec
|
||||
system: 20000, // 20 sec
|
||||
sensors: 20000, // 20 sec
|
||||
messages: 60000, // 1 min
|
||||
version: 120000, // 2 min
|
||||
ftl: 120000, // 2 min
|
||||
history: 600000, // 10 min
|
||||
clients: 600000, // 10 min
|
||||
query_types: 60000, // 1 min
|
||||
upstreams: 60000, // 1 min
|
||||
summary: 1000, // 1 sec
|
||||
top_lists: 60000, // 1 min
|
||||
hosts: 120000, // 2 min
|
||||
metrics: 10000, // 10 sec
|
||||
logs: 500, // 0.5 sec
|
||||
};
|
||||
|
||||
function secondsTimeSpanToHMS(s) {
|
||||
var h = Math.floor(s / 3600); //Get whole hours
|
||||
s -= h * 3600;
|
||||
@@ -92,11 +110,11 @@ function checkBlocking() {
|
||||
})
|
||||
.done(function (data) {
|
||||
piholeChanged(data.blocking);
|
||||
setTimeout(checkBlocking, 10000);
|
||||
setTimeout(checkBlocking, REFRESH_INTERVAL.blocking);
|
||||
})
|
||||
.fail(function (data) {
|
||||
apiFailure(data);
|
||||
setTimeout(checkBlocking, 30000);
|
||||
setTimeout(checkBlocking, 3 * REFRESH_INTERVAL.blocking);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -241,9 +259,8 @@ function updateFtlInfo() {
|
||||
ftl.allow_destructive ? "" : "Destructive actions are disabled by a config setting"
|
||||
);
|
||||
|
||||
// Update every 120 seconds
|
||||
clearTimeout(ftlinfoTimer);
|
||||
ftlinfoTimer = setTimeout(updateFtlInfo, 120000);
|
||||
ftlinfoTimer = setTimeout(updateFtlInfo, REFRESH_INTERVAL.ftl);
|
||||
})
|
||||
.fail(function (data) {
|
||||
apiFailure(data);
|
||||
@@ -340,9 +357,9 @@ function updateSystemInfo() {
|
||||
moment.duration(1000 * system.uptime).humanize() + " (running since " + startdate + ")"
|
||||
);
|
||||
$("#sysinfo-system-overlay").hide();
|
||||
// Update every 20 seconds
|
||||
|
||||
clearTimeout(systemTimer);
|
||||
systemTimer = setTimeout(updateSystemInfo, 20000);
|
||||
systemTimer = setTimeout(updateSystemInfo, REFRESH_INTERVAL.system);
|
||||
})
|
||||
.fail(function (data) {
|
||||
apiFailure(data);
|
||||
@@ -395,7 +412,7 @@ function updateSensorsInfo() {
|
||||
|
||||
// Update every 20 seconds
|
||||
clearTimeout(sensorsTimer);
|
||||
sensorsTimer = setTimeout(updateSensorsInfo, 20000);
|
||||
sensorsTimer = setTimeout(updateSensorsInfo, REFRESH_INTERVAL.sensors);
|
||||
})
|
||||
.fail(function (data) {
|
||||
apiFailure(data);
|
||||
@@ -564,9 +581,8 @@ function updateVersionInfo() {
|
||||
'To install updates, run <code><a href="https://docs.pi-hole.net/main/update/" rel="noopener" target="_blank">pihole -up</a></code>.'
|
||||
);
|
||||
|
||||
// Update every 120 seconds
|
||||
clearTimeout(versionTimer);
|
||||
versionTimer = setTimeout(updateVersionInfo, 120000);
|
||||
versionTimer = setTimeout(updateVersionInfo, REFRESH_INTERVAL.version);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -589,8 +605,8 @@ $(function () {
|
||||
if (window.location.pathname !== "/admin/login") {
|
||||
// Run check immediately after page loading ...
|
||||
utils.checkMessages();
|
||||
// ... and once again with five seconds delay
|
||||
setTimeout(utils.checkMessages, 5000);
|
||||
// ... and then periodically
|
||||
setInterval(utils.checkMessages, REFRESH_INTERVAL.messages);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user