Refreshing the settings page cache #663

This commit is contained in:
jokob-sk
2024-05-03 08:10:39 +10:00
parent 0b6071a272
commit 95fd7435d2
3 changed files with 50 additions and 17 deletions

View File

@@ -1051,15 +1051,9 @@ var completedCalls_final = ['cacheSettings', 'cacheStrings', 'cacheDevices'];
// Clearing all the caches
function clearCache() {
showSpinner();
resetInitializedFlag();
window.location.reload();
}
// -----------------------------------------------------------------------------
function resetInitializedFlag() {
// Clear both sessionStorage and localStorage
sessionStorage.clear();
localStorage.clear();
window.location.reload();
}
// -----------------------------------------------------------------------------
@@ -1072,8 +1066,7 @@ function checkSettingChanges() {
if (importedMilliseconds > lastReloaded) {
console.log("Cache needs to be refreshed because of setting changes");
setTimeout(() => {
resetInitializedFlag();
location.reload();
clearCache();
}, 500);
}
});
@@ -1161,9 +1154,20 @@ const areAllStringsInitialized = () => {
// Call the function to execute the code
executeOnce();
// Set timer for regular checks
setTimeout(() => {
// page refresh if configured
const refreshTime = getSetting("UI_REFRESH");
if (refreshTime && refreshTime !== "0" && refreshTime !== "") {
newTimerRefreshData(clearCache, parseInt(refreshTime)*1000);
}
// Check if page needs to refresh due to setting changes
checkSettingChanges()
}, 10000);
// Set timer for page refresh if configured
setTimeout(checkSettingChanges, 10000);
console.log("init common.js");

View File

@@ -6,6 +6,8 @@ A plugin allowing for importing devices from DHCP.leases files.
- Specify full paths of all `dhcp.leases` files you want to import and watch in the `DHCPLSS_paths_to_check`setting.
- Map the paths specified in the `DHCPLSS_paths_to_check`setting in your `docker-compose.yml` file.
- If you are using pihole or dnsmasq dhcp.leases, include `pihole` or `dnsmasq` into the mapping path respectively, check the below example for details
#### Example:
@@ -18,20 +20,47 @@ A plugin allowing for importing devices from DHCP.leases files.
# mapping different dhcp.leases files
- /first/location/dhcp.leases:/mnt/dhcp1.leases
- /second/location/dhcp.leases:/mnt/dhcp2.leases
- /third/location/dhcp.leases:/etc/pihole/dhcp.leases # a pihole specific dhcp.leases file
- /fourth/location/dhcp.leases:/etc/dnsmasq/dhcp.leases # a dnsmasq specific dhcp.leases file
...
```
`DHCPLSS_paths_to_check` Setting:
The `DHCPLSS_paths_to_check` setting should then contain the following:
```python
DHCPLSS_paths_to_check = ['/mnt/dhcp1.leases','/mnt/dhcp2.leases']
DHCPLSS_paths_to_check = ['/mnt/dhcp1.leases','/mnt/dhcp2.leases','/etc/pihole/dhcp.leases','/etc/dnsmasq/dhcp.leases']
```
### Notes
- No specific configuration needed.
No specific configuration is needed. This plugin supports `dhcp.leases` file(s) in the following formats:
1. PiHole
2. Dnsmasq
3. Generic format
#### pihole format
Example File Format: _(not all lines are required)_
```
TBC
```
#### dnsmasq format
`[Lease expiry time] [mac address] [ip address] [hostname] [client id, if known]`
Example File Format: _(not all lines are required)_
```
1715932537 01:5c:5c:5c:5c:5c:5c 192.168.1.115 ryans-laptop 01:5c:5c:5c:5c:5c:5c
```
> Note, only `[mac address] [ip address] [hostname]` are captured
#### Generic format
- This plugin expects the dhcp.leases file(s) to be in the format of **dhcpd.leases** that is different to the format that PiHole uses.
[dhcpd.leases(5) - Linux man page]( https://linux.die.net/man/5/dhcpd.leases#:~:text=This%20database%20is%20a%20free,file%20is%20the%20current%20one.)
Example File Format: _(not all lines are required)_
@@ -50,4 +79,4 @@ lease 192.168.79.15 {
option agent.remote-id c0:a8:9:5;
client-hostname "android-8182e21c852776e7";
}
```
```

View File

@@ -782,7 +782,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
window.onbeforeunload = null;
// Reloads the current page
setTimeout("window.location.reload()", 3000);
setTimeout("clearCache()", 5000);
}
});