Compare commits

...

30 Commits

Author SHA1 Message Date
jokob-sk
84d8363383 Presence start-end tooltip #1066 2025-05-24 09:38:02 +10:00
Jokob @NetAlertX
3830b00c33 Merge pull request #1068 from KihtrakRaknas/patch-1
Some checks failed
Code checks / check-url-paths (push) Has been cancelled
docker / docker_dev (push) Has been cancelled
Deploy MkDocs / deploy (push) Has been cancelled
Fix minor typo "longet"
2025-05-21 12:10:16 +10:00
Karthik Sankar
84103bb8ed Fix typo "longet"
`longet` should have been `longer`
2025-05-20 21:08:50 -04:00
slothsnow
0d7202f7a2 Translated using Weblate (German)
Some checks failed
Code checks / check-url-paths (push) Has been cancelled
docker / docker_dev (push) Has been cancelled
Deploy MkDocs / deploy (push) Has been cancelled
Currently translated at 89.3% (664 of 743 strings)

Translation: NetAlertX/core
Translate-URL: https://hosted.weblate.org/projects/pialert/core/de/
2025-05-18 21:01:54 +02:00
jokob-sk
a1f4f9b92f Merge branch 'main' of https://github.com/jokob-sk/NetAlertX
Some checks failed
Code checks / check-url-paths (push) Has been cancelled
docker / docker_dev (push) Has been cancelled
Deploy MkDocs / deploy (push) Has been cancelled
2025-05-12 20:24:49 +10:00
jokob-sk
82410814de DateTime format based on TIMEZONE #1044 2025-05-12 20:24:44 +10:00
Hosted Weblate
98cf0a4bc0 Merge branch 'origin/main' into Weblate.
Some checks are pending
Code checks / check-url-paths (push) Waiting to run
docker / docker_dev (push) Waiting to run
Deploy MkDocs / deploy (push) Waiting to run
2025-05-11 23:10:59 +02:00
Максим Горпиніч
5efc9dcb16 Translated using Weblate (Ukrainian)
Currently translated at 100.0% (743 of 743 strings)

Translation: NetAlertX/core
Translate-URL: https://hosted.weblate.org/projects/pialert/core/uk/
2025-05-11 23:10:59 +02:00
Massimo Pissarello
cfa7fb47e4 Translated using Weblate (Italian)
Currently translated at 100.0% (743 of 743 strings)

Translation: NetAlertX/core
Translate-URL: https://hosted.weblate.org/projects/pialert/core/it/
2025-05-11 23:10:59 +02:00
Safeguard
29d677253e Translated using Weblate (Russian)
Currently translated at 100.0% (743 of 743 strings)

Translation: NetAlertX/core
Translate-URL: https://hosted.weblate.org/projects/pialert/core/ru/
2025-05-11 23:10:58 +02:00
Sylvain Pichon
210a5e9ae2 Translated using Weblate (French)
Currently translated at 100.0% (743 of 743 strings)

Translation: NetAlertX/core
Translate-URL: https://hosted.weblate.org/projects/pialert/core/fr/
2025-05-11 23:10:58 +02:00
Hans Meine
49465715a6 Translated using Weblate (German)
Currently translated at 89.2% (663 of 743 strings)

Translation: NetAlertX/core
Translate-URL: https://hosted.weblate.org/projects/pialert/core/de/
2025-05-11 23:10:58 +02:00
jokob-sk
a0a14f24cc docs #1064 2025-05-12 07:10:20 +10:00
jokob-sk
209d06421c Merge branch 'main' of https://github.com/jokob-sk/NetAlertX
Some checks are pending
Code checks / check-url-paths (push) Waiting to run
docker / docker_dev (push) Waiting to run
Deploy MkDocs / deploy (push) Waiting to run
2025-05-11 08:34:38 +10:00
jokob-sk
cac2af8422 docs 2025-05-11 08:34:07 +10:00
Anonymous
57a9b269a0 Translated using Weblate (Ukrainian)
Currently translated at 99.8% (742 of 743 strings)

Translation: NetAlertX/core
Translate-URL: https://hosted.weblate.org/projects/pialert/core/uk/
2025-05-10 23:40:30 +02:00
Anonymous
17b11a016c Translated using Weblate (Catalan)
Currently translated at 99.8% (742 of 743 strings)

Translation: NetAlertX/core
Translate-URL: https://hosted.weblate.org/projects/pialert/core/ca/
2025-05-10 23:40:30 +02:00
Anonymous
d05de62cc7 Translated using Weblate (Turkish)
Currently translated at 67.9% (505 of 743 strings)

Translation: NetAlertX/core
Translate-URL: https://hosted.weblate.org/projects/pialert/core/tr/
2025-05-10 23:40:30 +02:00
Anonymous
3c28f9ed36 Translated using Weblate (Portuguese (Brazil))
Currently translated at 58.9% (438 of 743 strings)

Translation: NetAlertX/core
Translate-URL: https://hosted.weblate.org/projects/pialert/core/pt_BR/
2025-05-10 23:40:30 +02:00
Anonymous
56bd1d2772 Translated using Weblate (Italian)
Currently translated at 99.8% (742 of 743 strings)

Translation: NetAlertX/core
Translate-URL: https://hosted.weblate.org/projects/pialert/core/it/
2025-05-10 23:40:29 +02:00
Anonymous
7e65b06ff2 Translated using Weblate (Russian)
Currently translated at 99.8% (742 of 743 strings)

Translation: NetAlertX/core
Translate-URL: https://hosted.weblate.org/projects/pialert/core/ru/
2025-05-10 23:40:29 +02:00
Anonymous
78cb68d2c4 Translated using Weblate (French)
Currently translated at 99.8% (742 of 743 strings)

Translation: NetAlertX/core
Translate-URL: https://hosted.weblate.org/projects/pialert/core/fr/
2025-05-10 23:40:29 +02:00
Anonymous
f8df8dc41a Translated using Weblate (Spanish)
Currently translated at 99.8% (742 of 743 strings)

Translation: NetAlertX/core
Translate-URL: https://hosted.weblate.org/projects/pialert/core/es/
2025-05-10 23:40:29 +02:00
Hosted Weblate
4199f8891c Merge branch 'origin/main' into Weblate. 2025-05-10 23:28:02 +02:00
Hans Meine
7aa5f499b9 Translated using Weblate (German)
Currently translated at 89.2% (663 of 743 strings)

Translation: NetAlertX/core
Translate-URL: https://hosted.weblate.org/projects/pialert/core/de/
2025-05-10 23:28:01 +02:00
jokob-sk
990f490fb3 docs #1064 2025-05-11 07:27:33 +10:00
jokob-sk
7dba186e39 Docker swarm guide #1031
Some checks are pending
Code checks / check-url-paths (push) Waiting to run
docker / docker_dev (push) Waiting to run
Deploy MkDocs / deploy (push) Waiting to run
2025-05-10 15:43:46 +10:00
jokob-sk
7443c52021 DateTime format based on TIMEZONE #1044 2025-05-10 15:28:54 +10:00
jokob-sk
03822ac8fa DateTime format based on TIMEZONE #1044 2025-05-10 15:23:02 +10:00
jokob-sk
01f7a18dce Auto delete in-app notifications #1052 2025-05-10 14:33:27 +10:00
53 changed files with 380 additions and 150 deletions

79
docs/DOCKER_SWARM.md Executable file
View File

@@ -0,0 +1,79 @@
# Docker Swarm Deployment Guide (IPvlan)
This guide describes how to deploy **NetAlertX** in a **Docker Swarm** environment using an `ipvlan` network. This enables the container to receive a LAN IP address directly, which is ideal for network monitoring.
---
## ⚙️ Step 1: Create an IPvlan Config-Only Network on All Nodes
> Run this command on **each node** in the Swarm.
```bash
docker network create -d ipvlan \
--subnet=192.168.1.0/24 \ # 🔧 Replace with your LAN subnet
--gateway=192.168.1.1 \ # 🔧 Replace with your LAN gateway
-o ipvlan_mode=l2 \
-o parent=eno1 \ # 🔧 Replace with your network interface (e.g., eth0, eno1)
--config-only \
ipvlan-swarm-config
```
---
## 🖥️ Step 2: Create the Swarm-Scoped IPvlan Network (One-Time Setup)
> Run this on **one Swarm manager node only**.
```bash
docker network create -d ipvlan \
--scope swarm \
--config-from ipvlan-swarm-config \
swarm-ipvlan
```
---
## 🧾 Step 3: Deploy NetAlertX with Docker Compose
Use the following Compose snippet to deploy NetAlertX with a **static LAN IP** assigned via the `swarm-ipvlan` network.
```yaml
services:
netalertx:
image: ghcr.io/jokob-sk/netalertx:latest
ports:
- 20211:20211
volumes:
- /mnt/YOUR_SERVER/netalertx/config:/app/config:rw
- /mnt/YOUR_SERVER/netalertx/db:/netalertx/app/db:rw
- /mnt/YOUR_SERVER/netalertx/logs:/netalertx/app/log:rw
environment:
- TZ=Europe/London
- PORT=20211
networks:
swarm-ipvlan:
ipv4_address: 192.168.1.240 # ⚠️ Choose a free IP from your LAN
deploy:
mode: replicated
replicas: 1
restart_policy:
condition: on-failure
placement:
constraints:
- node.role == manager # 🔄 Or use: node.labels.netalertx == true
networks:
swarm-ipvlan:
external: true
```
---
## ✅ Notes
* The `ipvlan` setup allows **NetAlertX** to have a direct IP on your LAN.
* Replace `eno1` with your interface, IP addresses, and volume paths to match your environment.
* Make sure the assigned IP (`192.168.1.240` above) is not in use or managed by DHCP.
* You may also use a node label constraint instead of `node.role == manager` for more control.

View File

@@ -1,4 +1,4 @@
# Overview
# Home Assistant integration overview
NetAlertX comes with MQTT support, allowing you to show all detected devices as devices in Home Assistant. It also supplies a collection of stats, such as number of online devices.

View File

@@ -173,7 +173,7 @@
// Additional form elements like the random MAC address button for devMac
let inlineControl = "";
// handle rendom mac
// handle random mac
if (setting.setKey == "NEWDEV_devMac" && deviceData["devIsRandomMAC"] == true) {
inlineControl += `<span class="input-group-addon pointer"
title="${getString("RandomMAC_hover")}">

View File

@@ -65,7 +65,7 @@ function initializeSessionsDatatable () {
// Replace HTML codes
{targets: [0],
'createdCell': function (td, cellData, rowData, row, col) {
$(td).html (translateHTMLcodes (cellData));
$(td).html (translateHTMLcodes (localizeTimestamp(cellData)));
} }
],

View File

@@ -219,9 +219,8 @@ function initializeCalendar() {
},
eventRender: function (event, element) {
$(element).tooltip({container: 'body', placement: 'bottom',
title: event.tooltip});
// element.attr ('title', event.tooltip); // Alternative tooltip
// $(element).tooltip({container: 'body', placement: 'bottom', title: event.tooltip});
element.attr ('title', event.tooltip); // Alternative tooltip
},
loading: function( isLoading, view ) {

View File

@@ -47,9 +47,28 @@
{visible: false, targets: [0]},
// Replace HTML codes
{targets: [1,2,3,5],
{targets: [3,5],
'createdCell': function (td, cellData, rowData, row, col) {
$(td).html (translateHTMLcodes (cellData));
} },
// Date
{targets: [1,2],
"createdCell": function (td, cellData, rowData, row, col) {
// console.log(cellData);
if (!cellData.includes("missing event") && !cellData.includes("..."))
{
if (cellData.includes("+")) { // Check if timezone offset is present
cellData = cellData.split('+')[0]; // Remove timezone offset
}
// console.log(cellData);
result = localizeTimestamp(cellData);
} else
{
result = translateHTMLcodes(cellData)
}
$(td).html (result);
} }
],

View File

@@ -216,7 +216,7 @@ function initializeDatatable () {
} },
// Replace HTML codes
{targets: [3,4,5,6,7],
{targets: [4,5,6,7],
"createdCell": function (td, cellData, rowData, row, col) {
$(td).html (translateHTMLcodes (cellData));
} },
@@ -226,6 +226,12 @@ function initializeDatatable () {
"createdCell": function (td, cellData, rowData, row, col) {
// console.log(cellData);
$(td).html (cellData);
} },
// Date
{targets: [3],
"createdCell": function (td, cellData, rowData, row, col) {
// console.log(cellData);
$(td).html (localizeTimestamp(cellData));
} }
],

View File

@@ -353,6 +353,28 @@ function getLangCode() {
// String utilities
// -----------------------------------------------------------------------------
function localizeTimestamp(result)
{
// contains TZ in format Europe/Berlin
tz = getSetting("TIMEZONE")
const date = new Date(result); // Assumes result is a timestamp or ISO string
const formatter = new Intl.DateTimeFormat('default', {
timeZone: tz,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false // change to true if you want AM/PM format
});
return formatter.format(date);
}
// ----------------------------------------------------
/**
* Replaces double quotes within single-quoted strings, then converts all single quotes to double quotes,

5
front/lib/popper_tooltip/popper.min.js vendored Executable file

File diff suppressed because one or more lines are too long

View File

@@ -42,6 +42,7 @@
<script src="lib/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="lib/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<script src="lib/datatables.net/js/dataTables.select.min.js"></script>
<script src="lib/popper_tooltip/popper.min.js"></script>
<script src="js/common.js?v=<?php include 'php/templates/version.php'; ?>"></script>
<script src="js/modal.js?v=<?php include 'php/templates/version.php'; ?>"></script>
@@ -120,34 +121,8 @@
let timeZone = "<?php echo $timeZone ?>";
let now = new Date();
// Convert to the specified time zone
let formatter = new Intl.DateTimeFormat("en-UK", {
timeZone: timeZone,
day: "2-digit",
month: "short",
year: "numeric",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false, // Use 24-hour format
});
let parts = formatter.formatToParts(now);
// Extract date components
let day = parts.find(p => p.type === "day").value;
let month = parts.find(p => p.type === "month").value;
let year = parts.find(p => p.type === "year").value;
// Extract time components
let hour = parts.find(p => p.type === "hour").value;
let minute = parts.find(p => p.type === "minute").value;
let second = parts.find(p => p.type === "second").value;
// Construct the date and time in DD-MMM-YYYY HH:MM:SS format
let formattedDateTime = `${day}-${month}-${year} ${hour}:${minute}:${second}`;
if (document.getElementById) {
document.getElementById("NAX_Servertime_plc").innerHTML = '(' + formattedDateTime + ')';
document.getElementById("NAX_Servertime_plc").innerHTML = '(' + localizeTimestamp(now) + ')';
document.getElementById("NAX_TZ").innerHTML = timeZone;
}

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

18
front/php/templates/language/de_de.json Executable file → Normal file
View File

@@ -1,7 +1,7 @@
{
"API_CUSTOM_SQL_description": "Benutzerdefinierte SQL-Abfrage, welche eine JSON-Datei generiert und diese mit dem <a href=\"/php/server/query_json.php?file=table_custom_endpoint.json\" target=\"_blank\">Dateiendpunkt <code>table_custom_endpoint.json</code></a> zur Verfügung stellt.",
"API_CUSTOM_SQL_name": "Benutzerdefinierte SQL-Abfrage",
"API_TOKEN_description": "API-Token zur Absicherung der Kommunikation Sie können einen generieren oder einen beliebigen Wert eingeben. Er wird im Anfrage-Header übermittelt. Wird im <code>SYNC</code>-Plugin und GraphQL-Server verwendet.",
"API_TOKEN_description": "API-Token zur Absicherung der Kommunikation Sie können einen neuen generieren oder einen beliebigen Wert eingeben. Er wird im Anfrage-Header übermittelt und zum Beispiel im <code>SYNC</code>-Plugin, im GraphQL-Server und in anderen API Endpunkten verwendet (siehe auch <a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md\" target=\"_blank\">API Dokumentation)</a>..",
"API_TOKEN_name": "API-Schlüssel",
"API_display_name": "API",
"API_icon": "<i class=\"fa fa-arrow-down-up-across-line\"></i>",
@@ -61,7 +61,7 @@
"BackDevices_DBTools_ImportCSVError": "Die CSV-Datei konnte nicht importiert werden. Stellen Sie sicher, dass das Format korrekt ist.",
"BackDevices_DBTools_ImportCSVMissing": "Die CSV-Datei konnte nicht in <b>/config/devices.csv</b> gefunden werden.",
"BackDevices_DBTools_Purge": "Die ältesten Backups wurden gelöscht",
"BackDevices_DBTools_UpdDev": "Gerät wurde erfolgreich aktualisiert",
"BackDevices_DBTools_UpdDev": "Gerät wurde erfolgreich aktualisiert. Es kann etwas dauern bis die Übersicht neu geladen ist, wenn ein Scan aktiv ist.",
"BackDevices_DBTools_UpdDevError": "Fehler beim Aktualisieren des Gerätes",
"BackDevices_DBTools_Upgrade": "Datenbank wurde erfolgreich aktualisiert",
"BackDevices_DBTools_UpgradeError": "Fehler beim Aktualisieren der Datenbank",
@@ -76,7 +76,7 @@
"CustProps_cant_remove": "Kann nicht entfernt werden, es wird mindestens eine Eigenschaft benötigt.",
"DAYS_TO_KEEP_EVENTS_description": "Dies ist eine Wartungseinstellung. Spezifiziert wie viele Tage Events gespeichert bleiben. Alle älteren Events werden periodisch gelöscht. Wird auch auf die Plugins History angewendet.",
"DAYS_TO_KEEP_EVENTS_name": "Ereignisse löschen, die älter sind als",
"DISCOVER_PLUGINS_description": "Deaktiviere diese Option um die Initialisierung und Speicherdauer der Einstellungen zu verringern. Wenn es deaktiviert ist, können keine Plugins gefunden oder neue Plugins zu den vorhandenen hinzugefügt werden.",
"DISCOVER_PLUGINS_description": "Deaktiviere diese Option, um Initialisierung und Speichern der Einstellungen zu beschleunigen. Wenn es deaktiviert ist, werden keine neuen Plugins gefunden und es können keine manuell hinzugefügt werden.",
"DISCOVER_PLUGINS_name": "Entdecke Erweiterungen",
"DevDetail_Copy_Device_Title": "Details von Gerät kopieren",
"DevDetail_Copy_Device_Tooltip": "Details vom Gerät aus der Dropdown-Liste kopieren. Alles auf dieser Seite wird überschrieben",
@@ -295,7 +295,7 @@
"Events_Tablelenght": "Zeige _MENU_ Einträge",
"Events_Tablelenght_all": "Alle",
"Events_Title": "Ereignisse",
"GRAPHQL_PORT_description": "Die Portnummer des GraphQL-Servers.",
"GRAPHQL_PORT_description": "Die Portnummer des GraphQL-Servers. Stellen Sie sicher, dass dieser Port von keiner anderen Anwendung oder NetAlertX Instanz verwendet wird.",
"GRAPHQL_PORT_name": "GraphQL-Port",
"Gen_Action": "Action",
"Gen_Add": "Hinzufügen",
@@ -341,7 +341,7 @@
"Gen_Warning": "Warnung",
"Gen_Work_In_Progress": "Keine Finalversion, feedback bitte unter: https://github.com/jokob-sk/NetAlertX/issues",
"Gen_create_new_device": "Neues Gerät",
"Gen_create_new_device_info": "",
"Gen_create_new_device_info": "Geräte werden normalerweise über <a target=\"_blank\" href=\"https://github.com/jokob-sk/NetAlertX/tree/main/docs/PLUGINS.md\">Plugins</a> gefunden. In Ausnahmefällen kann es nötig sein, sie manuell hinzuzufügen. Konkrete Szenarien sind in der <a target=\"_blank\" href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/REMOTE_NETWORKS.md\">Dokumentation über entfernte Netzwerke</a> zu finden.",
"General_display_name": "Allgemein",
"General_icon": "<i class=\"fa fa-gears\"></i>",
"HRS_TO_KEEP_NEWDEV_description": "Dies ist eine Wartungseinstellung <b>DELETING devices</b>. Wenn aktiviert (<code>0</code> bedeutet deaktiviert), werden als <b>\"Neues Gerät\"</b> markierte Geräte gelöscht, wenn ihre <b>erste Sitzung</b> länger her ist als in dieser Einstellung angegeben. Verwenden Sie diese Einstellung, wenn Sie <b>Neue Geräte</b> nach <code>X</code> Stunden automatisch löschen wollen.",
@@ -383,11 +383,11 @@
"MQTT_icon": "<i class=\"fa fa-square-rss\"></i>",
"Maint_PurgeLog": "Protokoll bereinigen",
"Maint_RestartServer": "Server neu starten",
"Maint_Restart_Server_noti_text": "",
"Maint_Restart_Server_noti_text": "Soll der Backend-Server wirklich neu gestartet werden? Das könnte Instabilitäten verursachen. Vorher ein Backup erstellen. <br/><br/>Hinweis: Das kann einige Minuten dauern.",
"Maintenance_Running_Version": "Installierte Version",
"Maintenance_Status": "Status",
"Maintenance_Title": "Wartungswerkzeuge",
"Maintenance_Tool_DownloadConfig": "",
"Maintenance_Tool_DownloadConfig": "Einstellungen exportieren",
"Maintenance_Tool_DownloadConfig_text": "",
"Maintenance_Tool_DownloadWorkflows": "",
"Maintenance_Tool_DownloadWorkflows_text": "",
@@ -479,7 +479,7 @@
"Maintenance_lang_selector_apply": "Übernehmen",
"Maintenance_lang_selector_empty": "Sprache wählen",
"Maintenance_lang_selector_lable": "Sprachauswahl",
"Maintenance_lang_selector_text": "Die Änderung findet serverseitig statt, betrifft also alle verwendeten Geräte.",
"Maintenance_lang_selector_text": "Die Änderung findet clientseitig statt, betrifft also nur den aktuellen Browser.",
"Maintenance_new_version": "Eine neue Version ist vefügbar. Sieh dir die <a href=\"https://github.com/jokob-sk/NetAlertX/releases\" target=\"_blank\">Versionshinweise</a> an.",
"Maintenance_themeselector_apply": "Übernehmen",
"Maintenance_themeselector_empty": "Skin wählen",
@@ -823,4 +823,4 @@
"settings_update_item_warning": "",
"test_event_icon": "",
"test_event_tooltip": "Speichere die Änderungen, bevor Sie die Einstellungen testen."
}
}

View File

@@ -334,7 +334,7 @@
"General_icon": "<i class=\"fa fa-gears\"></i>",
"HRS_TO_KEEP_NEWDEV_description": "This is a maintenance setting <b>DELETING devices</b>. If enabled (<code>0</code> is disabled), devices marked as <b>New Device</b> will be deleted if their <b>First Session</b> time was older than the specified hours in this setting. Use this setting if you want to auto-delete <b>New Devices</b> after <code>X</code> hours.",
"HRS_TO_KEEP_NEWDEV_name": "Delete new devices after",
"HRS_TO_KEEP_OFFDEV_description": "This is a maintenance setting <b>DELETING devices</b>. If enabled (<code>0</code> is disabled), devices that are <b>Offline</b> and their <b>Last Offline</b> date time is older than the specified hours in this setting, will be deleted. Use this setting if you want to auto-delete <b>Offline Devices</b> after <code>X</code> hours being offline.",
"HRS_TO_KEEP_OFFDEV_description": "This is a maintenance setting <b>DELETING devices</b>. If enabled (<code>0</code> is disabled), devices that are <b>Offline</b> and their <b>Last Connection</b> date time is older than the specified hours in this setting, will be deleted. Use this setting if you want to auto-delete <b>Offline Devices</b> after <code>X</code> hours being offline.",
"HRS_TO_KEEP_OFFDEV_name": "Delete offline devices after",
"LOADED_PLUGINS_description": "Which Plugins to load. Adding plugins might slow the application. Read more about which plugins need to be enabled, types, or scanning options in the <a target=\"_blank\" href=\"https://github.com/jokob-sk/NetAlertX/tree/main/docs/PLUGINS.md\">plugins docs</a>. Unloaded plugins will lose your settings. Only <code>disabled</code> plugins can be unloaded.",
"LOADED_PLUGINS_name": "Loaded plugins",

View File

@@ -334,7 +334,7 @@
"General_icon": "<i class=\"fa fa-gears\"></i>",
"HRS_TO_KEEP_NEWDEV_description": "Paramètre de maintenance. S'il est activé (<code>0</code> s'il est désactivé), les appareils marqués comme <b>Nouvel appareil</b> seront supprimés si leur durée depuis la <b>première session</b> est plus ancienne que le nombre d'heures paramétré. Utilisez ce paramétrage si vous voulez supprimer automatiquement les <b>Nouveaux appareils</b> après <code>X</code> heures.",
"HRS_TO_KEEP_NEWDEV_name": "Supprimer les nouveaux appareils après",
"HRS_TO_KEEP_OFFDEV_description": "Il s'agit d'un paramètre de maintenance <b>SUPPRIMER des appareils</b>. Si cette option est activée (<code>0</code> est désactivé), les appareils qui sont <b>Hors ligne</b> et dont la <b>dernière heure hors ligne</b> est plus ancienne que les heures spécifiées dans ce paramètre. Utilisez ce paramètre si vous souhaitez supprimer automatiquement <b>Appareils hors ligne</b> après <code>X</code> heures de déconnexion.",
"HRS_TO_KEEP_OFFDEV_description": "Il s'agit d'un paramètre de maintenance <b>SUPPRIMER des appareils</b>. Si cette option est activée (<code>0</code> est désactivé), les appareils qui sont <b>Hors ligne</b> et dont la <b>dernière connexion</b> est plus ancienne que les heures spécifiées dans ce paramètre. Utilisez ce paramètre si vous souhaitez supprimer automatiquement <b>Appareils hors ligne</b> après <code>X</code> heures de déconnexion.",
"HRS_TO_KEEP_OFFDEV_name": "Supprimez les appareils hors ligne après",
"LOADED_PLUGINS_description": "Affiche les plugins chargés. Ajouter des plugins peut ralentir l'application. Obtenez plus d'informations dur quels plugins dont à activer, ou les options de scan dans la <a target=\"_blank\" href=\"https://github.com/jokob-sk/NetAlertX/tree/main/docs/PLUGINS.md\">documentation des plugins</a>. Décharger des plugins leur fait perdre leurs paramètres. Seuls les plugins <code>désactivés</code> peuvent être déchargés.",
"LOADED_PLUGINS_name": "Plugins chargés",

View File

@@ -334,7 +334,7 @@
"General_icon": "<i class=\"fa fa-gears\"></i>",
"HRS_TO_KEEP_NEWDEV_description": "Questa è un'impostazione di manutenzione <b>ELIMINAZIONE dispositivi</b>. Se abilitata (<code>0</code> è disabilitata), tutti i dispositivi marcati con <b>Nuovo dispositivo</b> verranno eliminati se l'orario della <b>Prima sessione</b> è precedente all'orario di questa impostazione. Usa questa impostazione se vuoi eliminare automaticamente i <b>Nuovi dispositivi</b> dopo <code>X</code> ore.",
"HRS_TO_KEEP_NEWDEV_name": "Elimina nuovi dispositivi dopo",
"HRS_TO_KEEP_OFFDEV_description": "Questa è un'impostazione di manutenzione <b>ELIMINAZIONE dispositivi</b>. Se abilitata (<code>0</code> è disabilitata), i dispositivi che sono <b>Offline</b> e la loro data e ora <b>Ultima offline</b> sono più vecchi delle ore specificate in questa impostazione saranno eliminati. Usa questa impostazione se vuoi eliminare automaticamente <b>Dispositivi offline</b> dopo <code>X</code> ore trascorse offline.",
"HRS_TO_KEEP_OFFDEV_description": "Questa è un'impostazione di manutenzione <b>ELIMINAZIONE dispositivi</b>. Se abilitata (<code>0</code> è disabilitata), i dispositivi che sono <b>Offline</b> e la loro data e ora <b>Ultima connessione</b> sono più vecchi delle ore specificate in questa impostazione saranno eliminati. Usa questa impostazione se vuoi eliminare automaticamente <b>Dispositivi offline</b> dopo <code>X</code> ore trascorse offline.",
"HRS_TO_KEEP_OFFDEV_name": "Elimina dispositivi offline dopo",
"LOADED_PLUGINS_description": "Quali Plugin caricare. L'aggiunta di plugin potrebbe rallentare l'applicazione. Leggi di più su quali plugin necessitano di essere abilitati, tipi e opzioni di scansione nella <a target=\"_blank\" href=\"https://github.com/jokob-sk/NetAlertX/tree/main/docs/PLUGINS.md\">documentazione plugin</a>. I plugin disinstallati perdono la loro configurazione. Solo i plugin <code>disabilitati</code> possono essere disinstallati.",
"LOADED_PLUGINS_name": "Plugin caricati",

View File

@@ -742,4 +742,4 @@
"settings_update_item_warning": "",
"test_event_icon": "",
"test_event_tooltip": "Guarde as alterações antes de testar as definições."
}
}

View File

@@ -334,7 +334,7 @@
"General_icon": "<i class=\"fa fa-gears\"></i>",
"HRS_TO_KEEP_NEWDEV_description": "Это настройка обслуживания <b>УДАЛЕНИЕ устройств</b>. Если этот параметр включен (<code>0</code> отключен), устройства, помеченные как <b>Новое устройство</b>, будут удалены, если время их <b>Первого сеанса</b> было старше указанных в этой настройке часов. Используйте этот параметр, если вы хотите автоматически удалять <b>Новые устройства</b> через <code>X</code> часов.",
"HRS_TO_KEEP_NEWDEV_name": "Удалить новые устройства после",
"HRS_TO_KEEP_OFFDEV_description": "Это настройка обслуживания <b>УДАЛЕНИЕ устройств</b>. Если этот параметр включен (<code>0</code> отключен), устройства, которые находятся <b>в Offline</b> и их дата и время <b>последнего Offline</b> старше, чем часы, указанные в этом параметре. Используйте этот параметр, если вы хотите автоматически удалять <b>Offline устройства</b> после <code>X</code> часов отсутствия в сети.",
"HRS_TO_KEEP_OFFDEV_description": "Это настройка обслуживания <b>УДАЛЕНИЕ устройств</b>. Если этот параметр включен (<code>0</code> отключен), устройства, которые находятся <b>в Offline</b> и их дата и время <b>последнего подключения</b> старше, чем часы, указанные в этом параметре. Используйте этот параметр, если вы хотите автоматически удалять <b>Offline устройства</b> после <code>X</code> часов отсутствия в сети.",
"HRS_TO_KEEP_OFFDEV_name": "Удалить устройства Offline после",
"LOADED_PLUGINS_description": "Какие плагины загружать. Добавление плагинов может замедлить работу приложения. Подробнее о том, какие плагины необходимо включить, их типах или параметрах сканирования, читайте в <a target=\"_blank\" href=\"https://github.com/jokob-sk/NetAlertX/tree/main/docs/PLUGINS.md \">Документация по плагинам</a>. Выгруженные плагины потеряют ваши настройки. Можно выгрузить только <code>отключенные</code> плагины.",
"LOADED_PLUGINS_name": "Загруженные плагины",

View File

@@ -334,7 +334,7 @@
"General_icon": "<i class=\"fa fa-gears\"></i>",
"HRS_TO_KEEP_NEWDEV_description": "Це налаштування обслуговування <b>ВИДАЛЕННЯ пристроїв</b>. Якщо ввімкнено (<code>0</code> вимкнено), пристрої, позначені як <b>Новий пристрій</b>, буде видалено, якщо час їхнього <b>першого сеансу</b> був старшим за вказані години в цьому налаштування. Використовуйте це налаштування, якщо ви хочете автоматично видаляти <b>Нові пристрої</b> через <code>X</code> годин.",
"HRS_TO_KEEP_NEWDEV_name": "Видаліть нові пристрої після",
"HRS_TO_KEEP_OFFDEV_description": "Це налаштування обслуговування <b>ВИДАЛЕННЯ пристроїв</b>. Якщо ввімкнути (<code>0</code> вимкнено), пристрої, які <b>офлайн</b> і дата їх <b>останнього вимкнення</b> старші за вказані години в цьому параметрі, будуть бути видалено. Використовуйте це налаштування, якщо ви хочете автоматично видаляти <b>Автономні пристрої</b> після <code>X</code> годин роботи в режимі офлайн.",
"HRS_TO_KEEP_OFFDEV_description": "Це налаштування обслуговування <b>ВИДАЛЕННЯ пристроїв</b>. Якщо ввімкнено (<code>0</code> вимкнено), пристрої, які <b>офлайн</b>, та їх <b>Останнє підключення</b> дата та час старіші за вказані години в цьому налаштуванні, будуть видалені. Використовуйте це налаштування, якщо ви хочете автоматично видаляти <b>офлайн-пристрої</b> після <code>X</code> годин перебування в мережі.",
"HRS_TO_KEEP_OFFDEV_name": "Видаліть офлайн-пристрої після",
"LOADED_PLUGINS_description": "Які плагіни завантажити. Додавання плагінів може уповільнити роботу програми. Дізнайтеся більше про те, які плагіни потрібно ввімкнути, типи чи параметри сканування в <a target=\"_blank\" href=\"https://github.com/jokob-sk/NetAlertX/tree/main/docs/PLUGINS.md \">документи плагінів</a>. Вивантажені плагіни втратять налаштування. Лише <code>вимкнені</code> плагіни можна вивантажити.",
"LOADED_PLUGINS_name": "Завантажені плагіни",

View File

@@ -16,7 +16,8 @@ from plugin_utils import get_plugins_configs
from logger import mylog, Logger
from const import pluginsPath, fullDbPath, logPath
from helper import timeNowTZ, get_setting_value
from notification import write_notification
from messaging.in_app import write_notification
import conf
# Make sure the TIMEZONE for logging is correct

View File

@@ -24,7 +24,7 @@ from plugin_utils import getPluginObject
from plugin_helper import Plugin_Objects
from logger import mylog, Logger, append_line_to_file
from helper import timeNowTZ, get_setting_value, bytes_to_string, sanitize_string, cleanDeviceName
from notification import Notification_obj
from models.notification_instance import NotificationInstance
from database import DB, get_device_stats
pluginName = 'TESTONLY'

View File

@@ -17,7 +17,7 @@ from const import confFileName, logPath
from plugin_helper import Plugin_Objects
from logger import mylog, Logger, append_line_to_file
from helper import timeNowTZ, get_setting_value
from notification import Notification_obj
from models.notification_instance import NotificationInstance
from database import DB
from pytz import timezone
@@ -50,8 +50,8 @@ def main():
# Initialize the Plugin obj output file
plugin_objects = Plugin_Objects(RESULT_FILE)
# Create a Notification_obj instance
notifications = Notification_obj(db)
# Create a NotificationInstance instance
notifications = NotificationInstance(db)
# Retrieve new notifications
new_notifications = notifications.getNew()

View File

@@ -26,7 +26,7 @@ from const import confFileName, logPath
from plugin_helper import Plugin_Objects
from logger import mylog, Logger, append_line_to_file
from helper import timeNowTZ, get_setting_value, hide_email
from notification import Notification_obj
from models.notification_instance import NotificationInstance
from database import DB
from pytz import timezone
@@ -59,8 +59,8 @@ def main():
# Initialize the Plugin obj output file
plugin_objects = Plugin_Objects(RESULT_FILE)
# Create a Notification_obj instance
notifications = Notification_obj(db)
# Create a NotificationInstance instance
notifications = NotificationInstance(db)
# Retrieve new notifications
new_notifications = notifications.getNew()

View File

@@ -28,7 +28,7 @@ from plugin_utils import getPluginObject
from plugin_helper import Plugin_Objects
from logger import mylog, Logger, append_line_to_file
from helper import timeNowTZ, get_setting_value, bytes_to_string, sanitize_string, normalize_string
from notification import Notification_obj
from models.notification_instance import NotificationInstance
from database import DB, get_device_stats
from pytz import timezone

View File

@@ -20,7 +20,7 @@ from const import confFileName, logPath
from plugin_helper import Plugin_Objects, handleEmpty
from logger import mylog, Logger, append_line_to_file
from helper import timeNowTZ, get_setting_value
from notification import Notification_obj
from models.notification_instance import NotificationInstance
from database import DB
from pytz import timezone
@@ -53,8 +53,8 @@ def main():
# Initialize the Plugin obj output file
plugin_objects = Plugin_Objects(RESULT_FILE)
# Create a Notification_obj instance
notifications = Notification_obj(db)
# Create a NotificationInstance instance
notifications = NotificationInstance(db)
# Retrieve new notifications
new_notifications = notifications.getNew()

View File

@@ -12,7 +12,7 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Objects, handleEmpty # noqa: E402
from logger import mylog, Logger # noqa: E402
from helper import timeNowTZ, get_setting_value, hide_string # noqa: E402
from notification import Notification_obj # noqa: E402
from models.notification_instance import NotificationInstance # noqa: E402
from database import DB # noqa: E402
import conf
from const import confFileName, logPath
@@ -49,8 +49,8 @@ def main():
# Initialize the Plugin obj output file
plugin_objects = Plugin_Objects(RESULT_FILE)
# Create a Notification_obj instance
notifications = Notification_obj(db)
# Create a NotificationInstance instance
notifications = NotificationInstance(db)
# Retrieve new notifications
new_notifications = notifications.getNew()

View File

@@ -20,7 +20,7 @@ from const import confFileName, logPath
from plugin_helper import Plugin_Objects, handleEmpty
from logger import mylog, Logger, append_line_to_file
from helper import timeNowTZ, get_setting_value, hide_string
from notification import Notification_obj
from models.notification_instance import NotificationInstance
from database import DB
from pytz import timezone
@@ -53,8 +53,8 @@ def main():
# Initialize the Plugin obj output file
plugin_objects = Plugin_Objects(RESULT_FILE)
# Create a Notification_obj instance
notifications = Notification_obj(db)
# Create a NotificationInstance instance
notifications = NotificationInstance(db)
# Retrieve new notifications
new_notifications = notifications.getNew()

View File

@@ -17,7 +17,7 @@ from const import confFileName, logPath
from plugin_helper import Plugin_Objects
from logger import mylog, Logger, append_line_to_file
from helper import timeNowTZ, get_setting_value
from notification import Notification_obj
from models.notification_instance import NotificationInstance
from database import DB
from pytz import timezone
@@ -51,8 +51,8 @@ def main():
# Initialize the Plugin obj output file
plugin_objects = Plugin_Objects(RESULT_FILE)
# Create a Notification_obj instance
notifications = Notification_obj(db)
# Create a NotificationInstance instance
notifications = NotificationInstance(db)
# Retrieve new notifications
new_notifications = notifications.getNew()

View File

@@ -23,7 +23,7 @@ from const import logPath, confFileName
from plugin_helper import Plugin_Objects, handleEmpty
from logger import mylog, Logger, append_line_to_file
from helper import timeNowTZ, get_setting_value, hide_string, write_file
from notification import Notification_obj
from models.notification_instance import NotificationInstance
from database import DB
from pytz import timezone
@@ -56,8 +56,8 @@ def main():
# Initialize the Plugin obj output file
plugin_objects = Plugin_Objects(RESULT_FILE)
# Create a Notification_obj instance
notifications = Notification_obj(db)
# Create a NotificationInstance instance
notifications = NotificationInstance(db)
# Retrieve new notifications
new_notifications = notifications.getNew()

View File

@@ -16,7 +16,7 @@ from plugin_utils import get_plugins_configs
from logger import mylog, Logger
from const import pluginsPath, fullDbPath, logPath
from helper import timeNowTZ, get_setting_value
from notification import write_notification
from messaging.in_app import write_notification
from database import DB
from models.device_instance import DeviceInstance
import conf

View File

@@ -25,7 +25,7 @@ from plugin_utils import get_plugins_configs
from logger import mylog, Logger
from const import pluginsPath, fullDbPath, logPath
from helper import timeNowTZ, get_setting_value
from notification import write_notification
from messaging.in_app import write_notification
import conf
# Make sure the TIMEZONE for logging is correct

View File

@@ -19,7 +19,7 @@ from plugin_utils import get_plugins_configs
from logger import mylog, Logger
from const import pluginsPath, fullDbPath, logPath
from helper import timeNowTZ, get_setting_value
from notification import write_notification
from messaging.in_app import write_notification
import conf
# Make sure the TIMEZONE for logging is correct

View File

@@ -243,6 +243,34 @@
"string": "How many last <code>app.log</code> lines to keep. If <code>LOG_LEVEL</code> is set to <code>debug</code> the app generates about 10000 lines per hour, so when debugging an issue the recommended setting should cover the bug occurence timeframe. For example for a bug with a 3 day periodical appearence the value <code>1000000</code> should be sufficient. Setting this value to <code>1000000</code> generates approximatelly a 50MB <code>app.log</code> file. Set to <code>0</code> to disable log purging."
}
]
},
{
"function": "NOTI_LENGTH",
"type": {
"dataType": "integer",
"elements": [
{
"elementType": "input",
"elementOptions": [{ "type": "number" }],
"transformers": []
}
]
},
"default_value": 0,
"options": [],
"localized": ["name", "description"],
"name": [
{
"language_code": "en_us",
"string": "Notifications history"
}
],
"description": [
{
"language_code": "en_us",
"string": "How many latest in-app Notification entries to keep. Set to <code>0</code> to disable."
}
]
}
],

View File

@@ -19,6 +19,7 @@ from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64
from logger import mylog, Logger, append_line_to_file
from helper import timeNowTZ, get_setting_value
from const import logPath, applicationPath
from messaging.in_app import remove_old
import conf
from pytz import timezone
@@ -41,6 +42,7 @@ def main():
mylog('verbose', [f'[{pluginName}] In script'])
MAINT_LOG_LENGTH = int(get_setting_value('MAINT_LOG_LENGTH'))
MAINT_NOTI_LENGTH = int(get_setting_value('MAINT_NOTI_LENGTH'))
# Check if set
if MAINT_LOG_LENGTH != 0:
@@ -63,7 +65,10 @@ def main():
mylog('verbose', [f'[{pluginName}] Cleanup finished'])
# Check if set
if MAINT_NOTI_LENGTH != 0:
mylog('verbose', [f'[{pluginName}] Cleaning in-app notification history'])
remove_old(MAINT_NOTI_LENGTH)
return 0

View File

@@ -16,7 +16,7 @@ from plugin_utils import get_plugins_configs
from logger import mylog, Logger
from const import pluginsPath, fullDbPath, logPath
from helper import timeNowTZ, get_setting_value
from notification import write_notification
from messaging.in_app import write_notification
from database import DB
from models.device_instance import DeviceInstance
import conf

View File

@@ -969,13 +969,13 @@
"name": [
{
"language_code": "en_us",
"string": "Last Connection"
"string": "Last Seen"
}
],
"description": [
{
"language_code": "en_us",
"string": "The date and time of the last connection with the device. Uneditable - Autodetected."
"string": "The date and time of the last seen connection with the device. Uneditable - Autodetected."
}
]
},
@@ -1150,7 +1150,7 @@
"description": [
{
"language_code": "en_us",
"string": "Indicates whether an alert should be triggered when the device goes down. The device has to be down for longet than the time set in the <b>Alert Down After</b> <code>NTFPRCS_alert_down_time</code> setting."
"string": "Indicates whether an alert should be triggered when the device goes down. The device has to be down for longer than the time set in the <b>Alert Down After</b> <code>NTFPRCS_alert_down_time</code> setting."
}
]
},
@@ -1633,4 +1633,4 @@
],
"required": [],
"additionalProperties": false
}
}

View File

@@ -2,10 +2,6 @@
This plugin scans your network for open ports. Only IPs are scanned that are accessible by the app container.
### Usage
- TBD
### Notes
- N/A
![Screenshot](nmap_ports_services.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

View File

@@ -45,7 +45,7 @@ from plugin_utils import get_plugins_configs
from logger import mylog, Logger
from const import pluginsPath, fullDbPath, logPath
from helper import timeNowTZ, get_setting_value
from notification import write_notification
from messaging.in_app import write_notification
from pytz import timezone
import conf

View File

@@ -20,7 +20,7 @@ from logger import mylog, Logger
from const import pluginsPath, fullDbPath, logPath
from helper import timeNowTZ, get_setting_value
from crypto_utils import encrypt_data
from notification import write_notification
from messaging.in_app import write_notification
import conf
from pytz import timezone

View File

@@ -17,7 +17,7 @@ from plugin_utils import get_plugins_configs
from logger import mylog, Logger
from const import pluginsPath, fullDbPath, logPath
from helper import timeNowTZ, get_setting_value
from notification import write_notification
from messaging.in_app import write_notification
from database import DB
from models.device_instance import DeviceInstance
import conf

View File

@@ -324,8 +324,15 @@ function initializeCalendar () {
},
eventRender: function (event, element, view) {
$(element).tooltip({container: 'body', placement: 'bottom', title: event.tooltip});
// element.attr ('title', event.tooltip); // Alternative tooltip
// $(element).tooltip({container: 'body', placement: 'bottom', title: event.tooltip});
tltp = event.tooltip.replace('\n',' | ')
element.attr ('title', tltp); // Alternative tooltip
},
eventClick: function(info) {
console.log(info);
},
loading: function( isLoading, view ) {

View File

@@ -78,6 +78,9 @@ require 'php/templates/header.php';
if (result.includes("+")) { // Check if timezone offset is present
result = result.split('+')[0]; // Remove timezone offset
}
result = localizeTimestamp(result);
return result;
}
},

View File

@@ -43,6 +43,7 @@ nav:
- Reverse Proxy: REVERSE_PROXY.md
- Webhooks (n8n): WEBHOOK_N8N.md
- Workflows: WORKFLOWS.md
- Docker Swarm: DOCKER_SWARM.md
- Help:
- Common issues: COMMON_ISSUES.md
- Random MAC: RANDOM_MAC.md

View File

@@ -31,8 +31,8 @@ from api import update_api
from scan.session_events import process_scan
from initialise import importConfigs
from database import DB
from reporting import get_notifications
from notification import Notification_obj
from messaging.reporting import get_notifications
from models.notification_instance import NotificationInstance
from plugin import plugin_manager
from scan.device_handling import update_devices_names
from workflows.manager import WorkflowManager
@@ -172,7 +172,7 @@ def main ():
final_json = get_notifications(db)
# Write the notifications into the DB
notification = Notification_obj(db)
notification = NotificationInstance(db)
notificationObj = notification.create(final_json, "")
# run all enabled publisher gateways

View File

@@ -9,8 +9,8 @@ from const import (apiPath, sql_appevents, sql_devices_all, sql_events_pending_a
from logger import mylog
from helper import write_file, get_setting_value, timeNowTZ
from app_state import updateState
from user_events_queue import UserEventsQueue
from notification import write_notification
from models.user_events_queue_instance import UserEventsQueueInstance
from messaging.in_app import write_notification
# Import the start_server function
from graphql_server.graphql_server_start import start_server
@@ -147,7 +147,7 @@ class api_endpoint_class:
# Update user event execution log
# mylog('verbose', [f'[API] api_endpoint_class: is_ad_hoc_user_event {self.is_ad_hoc_user_event}'])
if self.is_ad_hoc_user_event:
execution_log = UserEventsQueue()
execution_log = UserEventsQueueInstance()
execution_log.finalize_event("update_api")
self.is_ad_hoc_user_event = False

View File

@@ -11,7 +11,7 @@ sys.path.extend([f"{INSTALL_PATH}/server"])
from logger import mylog
from helper import get_setting_value, timeNowTZ
from app_state import updateState
from notification import write_notification
from messaging.in_app import write_notification
# Flask application
app = Flask(__name__)

View File

@@ -19,7 +19,7 @@ from api import update_api
from scheduler import schedule_class
from plugin import plugin_manager, print_plugin_info
from plugin_utils import get_plugins_configs, get_set_value_for_init
from notification import write_notification
from messaging.in_app import write_notification
from crypto_utils import get_random_bytes
#===============================================================================

105
server/messaging/in_app.py Executable file
View File

@@ -0,0 +1,105 @@
import datetime
import os
import sys
import _io
import json
import uuid
import socket
import subprocess
import requests
from yattag import indent
from json2table import convert
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/server"])
# Register NetAlertX modules
import conf
from const import applicationPath, logPath, apiPath, confFileName, reportTemplatesPath
from logger import logResult, mylog
from helper import generate_mac_links, removeDuplicateNewLines, timeNowTZ, get_file_content, write_file, get_setting_value, get_timezone_offset
NOTIFICATION_API_FILE = apiPath + 'user_notifications.json'
# Show Frontend User Notification
def write_notification(content, level, timestamp):
# Generate GUID
guid = str(uuid.uuid4())
# Prepare notification dictionary
notification = {
'timestamp': str(timestamp),
'guid': guid,
'read': 0,
'level': level,
'content': content
}
# If file exists, load existing data, otherwise initialize as empty list
if os.path.exists(NOTIFICATION_API_FILE):
with open(NOTIFICATION_API_FILE, 'r') as file:
# Check if the file object is of type _io.TextIOWrapper
if isinstance(file, _io.TextIOWrapper):
file_contents = file.read() # Read file contents
if file_contents == '':
file_contents = '[]' # If file is empty, initialize as empty list
# mylog('debug', ['[Notification] User Notifications file: ', file_contents])
notifications = json.loads(file_contents) # Parse JSON data
else:
mylog('none', '[Notification] File is not of type _io.TextIOWrapper')
notifications = []
else:
notifications = []
# Append new notification
notifications.append(notification)
# Write updated data back to file
with open(NOTIFICATION_API_FILE, 'w') as file:
json.dump(notifications, file, indent=4)
# Trim notifications
def remove_old(keepNumberOfEntries):
# Check if file exists
if not os.path.exists(NOTIFICATION_API_FILE):
mylog('info', '[Notification] No notifications file to clean.')
return
# Load existing notifications
try:
with open(NOTIFICATION_API_FILE, 'r') as file:
file_contents = file.read().strip()
if file_contents == '':
notifications = []
else:
notifications = json.loads(file_contents)
except Exception as e:
mylog('none', f'[Notification] Error reading notifications file: {e}')
return
if not isinstance(notifications, list):
mylog('none', '[Notification] Invalid format: not a list')
return
# Sort by timestamp descending
try:
notifications.sort(key=lambda x: x['timestamp'], reverse=True)
except KeyError:
mylog('none', '[Notification] Missing timestamp in one or more entries')
return
# Trim to the latest entries
trimmed = notifications[:keepNumberOfEntries]
# Write back the trimmed list
try:
with open(NOTIFICATION_API_FILE, 'w') as file:
json.dump(trimmed, file, indent=4)
mylog('verbose', f'[Notification] Trimmed notifications to latest {keepNumberOfEntries}')
except Exception as e:
mylog('none', f'Error writing trimmed notifications file: {e}')

View File

@@ -12,6 +12,11 @@
import datetime
import json
import sys
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/server"])
import conf
from const import applicationPath, logPath, apiPath, confFileName

View File

@@ -2,6 +2,7 @@ import datetime
import os
import _io
import json
import sys
import uuid
import socket
import subprocess
@@ -9,16 +10,22 @@ import requests
from yattag import indent
from json2table import convert
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/server"])
# Register NetAlertX modules
import conf
from const import applicationPath, logPath, apiPath, confFileName, reportTemplatesPath
from logger import logResult, mylog
from helper import generate_mac_links, removeDuplicateNewLines, timeNowTZ, get_file_content, write_file, get_setting_value, get_timezone_offset
from messaging.in_app import write_notification
#-------------------------------------------------------------------------------
# Notification object handling
#-------------------------------------------------------------------------------
class Notification_obj:
class NotificationInstance:
def __init__(self, db):
self.db = db
@@ -290,45 +297,7 @@ class Notification_obj:
# Reporting
#-------------------------------------------------------------------------------
# Handle Frontend User Notifications
def write_notification(content, level, timestamp):
NOTIFICATION_API_FILE = apiPath + 'user_notifications.json'
# Generate GUID
guid = str(uuid.uuid4())
# Prepare notification dictionary
notification = {
'timestamp': str(timestamp),
'guid': guid,
'read': 0,
'level': level,
'content': content
}
# If file exists, load existing data, otherwise initialize as empty list
if os.path.exists(NOTIFICATION_API_FILE):
with open(NOTIFICATION_API_FILE, 'r') as file:
# Check if the file object is of type _io.TextIOWrapper
if isinstance(file, _io.TextIOWrapper):
file_contents = file.read() # Read file contents
if file_contents == '':
file_contents = '[]' # If file is empty, initialize as empty list
# mylog('debug', ['[Notification] User Notifications file: ', file_contents])
notifications = json.loads(file_contents) # Parse JSON data
else:
mylog('error', 'File is not of type _io.TextIOWrapper')
notifications = []
else:
notifications = []
# Append new notification
notifications.append(notification)
# Write updated data back to file
with open(NOTIFICATION_API_FILE, 'w') as file:
json.dump(notifications, file, indent=4)
#-------------------------------------------------------------------------------
def construct_notifications(JSON, section):

View File

@@ -1,10 +1,15 @@
import os
import sys
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/server"])
# Register NetAlertX modules
from const import pluginsPath, logPath, applicationPath, reportTemplatesPath
from logger import mylog
class UserEventsQueue:
class UserEventsQueueInstance:
"""
Handles the execution queue log file, allowing reading, writing,
and removing processed events.
@@ -30,7 +35,7 @@ class UserEventsQueue:
Returns an empty list if the file doesn't exist.
"""
if not os.path.exists(self.log_file):
mylog('none', ['[UserEventsQueue] Log file not found: ', self.log_file])
mylog('none', ['[UserEventsQueueInstance] Log file not found: ', self.log_file])
return [] # No log file, return empty list
with open(self.log_file, "r") as file:
return file.readlines()
@@ -72,7 +77,7 @@ class UserEventsQueue:
self.write_log(updated_lines)
mylog('minimal', ['[UserEventsQueue] Processed event: ', event])
mylog('minimal', ['[UserEventsQueueInstance] Processed event: ', event])
return removed

View File

@@ -16,11 +16,11 @@ from helper import timeNowTZ, get_file_content, write_file, get_setting, get_set
from app_state import updateState
from api import update_api
from plugin_utils import logEventStatusCounts, get_plugin_string, get_plugin_setting_obj, print_plugin_info, list_to_csv, combine_plugin_objects, resolve_wildcards_arr, handle_empty, custom_plugin_decoder, decode_and_rename_files
from notification import Notification_obj, write_notification
from user_events_queue import UserEventsQueue
from models.notification_instance import NotificationInstance
from messaging.in_app import write_notification
from models.user_events_queue_instance import UserEventsQueueInstance
from crypto_utils import generate_deterministic_guid
#-------------------------------------------------------------------------------
class plugin_manager:
def __init__(self, db, all_plugins):
@@ -79,7 +79,7 @@ class plugin_manager:
"""
Process user events from the execution queue log file and notify the user about executed events.
"""
execution_log = UserEventsQueue()
execution_log = UserEventsQueueInstance()
# Track whether to show notification for executed events
executed_events = []
@@ -151,7 +151,7 @@ class plugin_manager:
sample_json = json.loads(get_file_content(reportTemplatesPath + 'webhook_json_sample.json'))[0]["body"]["attachments"][0]["text"]
# Create fake notification
notification = Notification_obj(self.db)
notification = NotificationInstance(self.db)
notificationObj = notification.create(sample_json, "")
# Run test
@@ -562,7 +562,7 @@ def execute_plugin(db, all_plugins, plugin ):
endpoints = ["plugins_events","plugins_objects", "plugins_history", "appevents"]
# check if we need to update devices api endpoint as well to prevent long user waits on Loading...
userUpdatedDevices = UserEventsQueue().has_update_devices
userUpdatedDevices = UserEventsQueueInstance().has_update_devices
if userUpdatedDevices:
endpoints += ["devices"]

View File

@@ -8,7 +8,7 @@ import conf
from scan.device_handling import create_new_devices, print_scan_stats, save_scanned_devices, update_devices_data_from_scan, exclude_ignored_devices
from helper import timeNowTZ
from logger import mylog
from reporting import skip_repeated_notifications
from messaging.reporting import skip_repeated_notifications
#===============================================================================