Add version to JS files to flush cache #659

This commit is contained in:
jokob-sk
2024-05-01 18:25:48 +10:00
parent 525b05db5a
commit 584fdb7734
13 changed files with 50 additions and 45 deletions

View File

@@ -18,7 +18,8 @@
## 📕 Basic Usage ## 📕 Basic Usage
- You will have to run the container on the `host` network, e.g: > [!WARNING]
> You will have to run the container on the `host` network.
```yaml ```yaml
docker run -d --rm --network=host \ docker run -d --rm --network=host \
@@ -63,26 +64,16 @@ docker run -d --rm --network=host \
- You can modify [app.conf](https://github.com/jokob-sk/NetAlertX/tree/main/config) directly, if needed. - You can modify [app.conf](https://github.com/jokob-sk/NetAlertX/tree/main/config) directly, if needed.
- If unavailable, the app generates a default `app.conf` and `app.db` file on the first run. - If unavailable, the app generates a default `app.conf` and `app.db` file on the first run.
#### Important settings ### Important settings
These are the most important settings to get at least some output in your Devices screen. Usually, only one approach is used, but you should be able to combine these approaches. These are the most important settings to get at least some output in your Devices screen. Usually, only one approach is used, but you can combine these approaches.
##### For arp-scan: ARPSCAN_RUN, SCAN_SUBNETS | Scan method | Setting | Description |
| :------------- | :------------- | :-------------|
| arp-scan, nmap-scan | `SCAN_SUBNETS` | See the documentation on how [to setup SUBNETS, VLANs & limitations](https://github.com/jokob-sk/NetAlertX/blob/main/docs/SUBNETS.md) |
| PiHole | `PIHOLE_RUN` | There are 2 approaches how to get PiHole devices imported. Via the PiHole import (`PIHOLE`) plugin or DHCP leases (`DHCPLSS`) plugin. The `PIHOLE` plugin requires you to map the PiHole database, as mentioned above. |
| dhcp.leases | `DHCPLSS_RUN` | You need to map `:/etc/pihole/dhcp.leases` in the `docker-compose.yml` file if you enable this setting. This path has to be matched with a corresponding `DHCPLSS_paths_to_check` setting entry (If using a PiHole dhcp.leases file the path in the container must contain `pihole` as PiHole uses a different format of the `dhcp.leases` file). |
- ❗ To use the arp-scan method, you need to set the `SCAN_SUBNETS` variable. See the documentation on how [to setup SUBNETS, VLANs & limitations](https://github.com/jokob-sk/NetAlertX/blob/main/docs/SUBNETS.md)
##### For pihole: PIHOLE_RUN, DHCPLSS_RUN
There are 2 approaches how to get PiHole devices imported. Via the PiHole import (PIHOLE) plugin or DHCP leases (DHCPLSS) plugin.
**PiHole (Device sync)**
* `PIHOLE_RUN`: You need to map `:/etc/pihole/pihole-FTL.db` in the `docker-compose.yml` file if you enable this setting.
**DHCP Leases (Device import)**
* `DHCPLSS_RUN`: You need to map `:/etc/pihole/dhcp.leases` in the `docker-compose.yml` file if you enable this setting.
* The above setting has to be matched with a corresponding `DHCPLSS_paths_to_check` setting entry (the path in the container must contain `pihole` as PiHole uses a different format of the `dhcp.leases` file).
> [!NOTE] > [!NOTE]
> It's recommended to use the same schedule interval for all plugins responsible for discovering new devices. > It's recommended to use the same schedule interval for all plugins responsible for discovering new devices.

View File

@@ -891,12 +891,12 @@ input[readonly] {
.interactable-option::before { .interactable-option::before {
content: '1x 📝 | 2x 🚮'; content: '1x 📝 | 2x 🚮';
position: absolute; position: sticky;
right: 0; right: 0px;
top: 0; top: 0;
color: white; color: white;
float: right;
background-color: rgb(0, 0, 0); background-color: rgb(0, 0, 0);
padding: 3px;
transition: opacity 0.5s; transition: opacity 0.5s;
opacity: 0.1; opacity: 0.1;
border-radius: 3px; border-radius: 3px;

View File

@@ -627,8 +627,8 @@
<script src="lib/AdminLTE/bower_components/fullcalendar/dist/fullcalendar.min.js"></script> <script src="lib/AdminLTE/bower_components/fullcalendar/dist/fullcalendar.min.js"></script>
<script src="lib/AdminLTE/bower_components/fullcalendar/dist/locale-all.js"></script> <script src="lib/AdminLTE/bower_components/fullcalendar/dist/locale-all.js"></script>
<!-- ----------------------------------------------------------------------- --> <!-- ----------------------------------------------------------------------- -->
<script src="js/ui_components.js"></script> <script src="js/ui_components.js?v=<?php include 'php/templates/version.php'; ?>"></script>
<script src="js/db_methods.js"></script> <script src="js/db_methods.js?v=<?php include 'php/templates/version.php'; ?>"></script>
<!-- ----------------------------------------------------------------------- --> <!-- ----------------------------------------------------------------------- -->
<!-- Dark-Mode Patch --> <!-- Dark-Mode Patch -->

View File

@@ -25,7 +25,7 @@
checkPermissions([$dbPath, $confPath]); checkPermissions([$dbPath, $confPath]);
?> ?>
<script src="js/ui_components.js"></script> <script src="js/ui_components.js?v=<?php include 'php/templates/version.php'; ?>"></script>
<!-- Page ------------------------------------------------------------------ --> <!-- Page ------------------------------------------------------------------ -->
<div class="content-wrapper"> <div class="content-wrapper">
@@ -127,7 +127,7 @@
</div> </div>
<div class="box-body"> <div class="box-body">
<div class="chart"> <div class="chart">
<script src="lib/AdminLTE/bower_components/chart.js/Chart.js"></script> <script src="lib/AdminLTE/bower_components/chart.js/Chart.js?v=<?php include 'php/templates/version.php'; ?>"></script>
<canvas id="OnlineChart" style="width:100%; height: 150px; margin-bottom: 15px;"></canvas> <canvas id="OnlineChart" style="width:100%; height: 150px; margin-bottom: 15px;"></canvas>
</div> </div>
</div> </div>

View File

@@ -230,7 +230,7 @@ function cacheStrings()
// Get translated language string // Get translated language string
function getString (key) { function getString (key) {
// handle initial laod to make sure everything is set-up and cached // handle initial load to make sure everything is set-up and cached
handleFirstLoad(getString) handleFirstLoad(getString)
UI_LANG = getSetting("UI_LANG"); UI_LANG = getSetting("UI_LANG");
@@ -864,6 +864,15 @@ function getGuid() {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
function showSpinner(stringKey='Loading') function showSpinner(stringKey='Loading')
{ {
if(stringKey == "")
{
text = ''
} else
{
text = getString(stringKey)
}
if($("#loadingSpinner").length) if($("#loadingSpinner").length)
{ {
$("#loadingSpinner").show(); $("#loadingSpinner").show();
@@ -875,7 +884,7 @@ function showSpinner(stringKey='Loading')
<div class="pa_semitransparent-panel"></div> <div class="pa_semitransparent-panel"></div>
<div class="panel panel-default pa_spinner"> <div class="panel panel-default pa_spinner">
<table> <table>
<td width="130px" align="middle">${getString(stringKey)}</td> <td width="130px" align="middle">${text}</td>
<td><i class="ion ion-ios-loop-strong fa-spin fa-2x fa-fw"></td> <td><i class="ion ion-ios-loop-strong fa-spin fa-2x fa-fw"></td>
</table> </table>
</div> </div>
@@ -1109,9 +1118,9 @@ function isAppInitialized()
// Define a function that will execute the code only once // Define a function that will execute the code only once
function executeOnce() { function executeOnce() {
if ( !isAppInitialized()) { showSpinner('')
showSpinner() if ( !isAppInitialized()) {
// Use cache to keep track of completed AJAX calls // Use cache to keep track of completed AJAX calls
var tmp_completedCalls = getCache("completedCalls") var tmp_completedCalls = getCache("completedCalls")

View File

@@ -227,6 +227,8 @@ function initListInteractionOptions(selectorId) {
$options.on('click', function() { $options.on('click', function() {
const $option = $(this); const $option = $(this);
console.log('aaa');
// Increment click counter // Increment click counter
clickCounter++; clickCounter++;

View File

@@ -325,8 +325,8 @@ getData();
</script> </script>
<!-- ----------------------------------------------------------------------- --> <!-- ----------------------------------------------------------------------- -->
<script src="js/ui_components.js"></script> <script src="js/ui_components.js?v=<?php include 'php/templates/version.php'; ?>"></script>
<script src="js/db_methods.js"></script> <script src="js/db_methods.js?v=<?php include 'php/templates/version.php'; ?>"></script>
<!-- ----------------------------------------------------------------------- --> <!-- ----------------------------------------------------------------------- -->

View File

@@ -30,8 +30,8 @@ require dirname(__FILE__).'/security.php';
<!-- jQuery 3 --> <!-- jQuery 3 -->
<script src="lib/AdminLTE/bower_components/jquery/dist/jquery.min.js"></script> <script src="lib/AdminLTE/bower_components/jquery/dist/jquery.min.js"></script>
<script src="js/common.js"></script> <script src="js/common.js?v=<?php include 'php/templates/version.php'; ?>"></script>
<script src="js/modal.js"></script> <script src="js/modal.js?v=<?php include 'php/templates/version.php'; ?>"></script>
<!-- Bootstrap 3.3.7 --> <!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="lib/AdminLTE/bower_components/bootstrap/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="lib/AdminLTE/bower_components/bootstrap/dist/css/bootstrap.min.css">

0
front/php/templates/language/pl_pl.json Normal file → Executable file
View File

View File

@@ -16,6 +16,6 @@
echo file_get_contents($filename); echo file_get_contents($filename);
} }
else{ else{
echo "File not found"; echo date('Y-m-d H:i:s') . " - N/A";
} }
?> ?>

View File

@@ -606,7 +606,7 @@
} }
] ]
}, },
{ {
"function": "LESS_NAME_CLEANUP", "function": "LESS_NAME_CLEANUP",
"type": "integer.checkbox", "type": "integer.checkbox",
"default_value": 0, "default_value": 0,

View File

@@ -53,9 +53,9 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
<!-- Page ------------------------------------------------------------------ --> <!-- Page ------------------------------------------------------------------ -->
<!-- Page ------------------------------------------------------------------ --> <!-- Page ------------------------------------------------------------------ -->
<script src="js/settings_utils.js"></script> <script src="js/settings_utils.js?v=<?php include 'php/templates/version.php'; ?>"></script>
<script src="js/db_methods.js"></script> <script src="js/db_methods.js?v=<?php include 'php/templates/version.php'; ?>"></script>
<script src="js/ui_components.js"></script> <script src="js/ui_components.js?v=<?php include 'php/templates/version.php'; ?>"></script>
<script src="lib/crypto/crypto-js.min.js"></script> <script src="lib/crypto/crypto-js.min.js"></script>
@@ -63,7 +63,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
<!-- Content header--------------------------------------------------------- --> <!-- Content header--------------------------------------------------------- -->
<section class="content-header"> <section class="content-header">
<?php require 'php/templates/notification.php'; ?>
<div class="col-sm-5"> <div class="col-sm-5">
@@ -487,7 +487,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
options = createArray(val); options = createArray(val);
options.forEach(option => { options.forEach(option => {
inputHtml += `<option value="${option}" disabled>${option}</option>`; inputHtml += `<option value="${option}" >${option}</option>`;
}); });
@@ -522,7 +522,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
options.forEach(option => { options.forEach(option => {
inputHtml += `<option value="${option}" disabled>${option}</option>`; inputHtml += `<option value="${option}" >${option}</option>`;
}); });
inputHtml += '</select></div>' + inputHtml += '</select></div>' +
@@ -568,7 +568,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
// generate settings in the correct group section // generate settings in the correct group section
$(`#${group} .panel-body`).append(setHtml); $(`#${group} .panel-body`).append(setHtml);
// init remove list item buttons // init remove and edit listitem click gestures
if(['subnets', 'list' ].includes(setType)) if(['subnets', 'list' ].includes(setType))
{ {
initListInteractionOptions(codeName) initListInteractionOptions(codeName)

View File

@@ -573,8 +573,11 @@ def resolve_device_name_pholus (pMAC, pIP, allRes, nameNotFound, match_IP = Fals
import dns.resolver import dns.resolver
def cleanDeviceName(str, match_IP): def cleanDeviceName(str, match_IP):
mylog('debug', ["[Name cleanup] NEWDEV_LESS_NAME_CLEANUP Setting:" + get_setting_value('NEWDEV_LESS_NAME_CLEANUP')])
if get_setting_value('NEWDEV_LESS_NAME_CLEANUP'): if get_setting_value('NEWDEV_LESS_NAME_CLEANUP'):
mylog('debug', ["Using new cleanDeviceName(" + str + ")"]) mylog('debug', ["[Name cleanup] Using new cleanDeviceName(" + str + ")"])
# replace all labels starting with underscore # replace all labels starting with underscore
str = re.sub(r'^_[^\.]*\.', '', str) # leading label str = re.sub(r'^_[^\.]*\.', '', str) # leading label
@@ -605,13 +608,13 @@ def cleanDeviceName(str, match_IP):
str = str + " (IP match)" str = str + " (IP match)"
# done # done
mylog('debug', ["cleanDeviceName = " + str]) mylog('debug', ["[Name cleanup] cleanDeviceName = " + str])
return str return str
################################ ################################
# #
# OLD cleanDeviceName # OLD cleanDeviceName
mylog('debug', ["Using old cleanDeviceName(" + str + ")"]) mylog('debug', ["[Name cleanup] Using old cleanDeviceName(" + str + ")"])
# alternative str.split('.')[0] # alternative str.split('.')[0]
str = str.replace("._airplay", "") str = str.replace("._airplay", "")