mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-06 17:15:38 -08:00
Merge branch 'jokob-sk:main' into port-fixes
This commit is contained in:
2
front/php/templates/language/ar_ar.json
Executable file → Normal file
2
front/php/templates/language/ar_ar.json
Executable file → Normal file
@@ -761,4 +761,4 @@
|
||||
"settings_system_label": "تسمية النظام",
|
||||
"settings_update_item_warning": "تحذير تحديث العنصر",
|
||||
"test_event_tooltip": "تلميح اختبار الحدث"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,3 +44,4 @@ More Info:
|
||||
|
||||
Report Date: 2021-12-08 12:30
|
||||
Server: Synology-NAS
|
||||
Link: netalertx.com
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
<!--
|
||||
#---------------------------------------------------------------------------------#
|
||||
# NetAlertX #
|
||||
# Open Source Network Guard / WIFI & LAN intrusion detector #
|
||||
# #
|
||||
# report_template.html - Back module. Template to email reporting in HTML format #
|
||||
#---------------------------------------------------------------------------------#
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
@@ -20,11 +11,11 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td height=200 valign=top style="padding: 10px">
|
||||
<NEW_DEVICES_TABLE>
|
||||
<DOWN_DEVICES_TABLE>
|
||||
<DOWN_RECONNECTED_TABLE>
|
||||
<EVENTS_TABLE>
|
||||
<PLUGINS_TABLE>
|
||||
NEW_DEVICES_TABLE
|
||||
DOWN_DEVICES_TABLE
|
||||
DOWN_RECONNECTED_TABLE
|
||||
EVENTS_TABLE
|
||||
PLUGINS_TABLE
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@@ -34,11 +25,11 @@
|
||||
<table width=100% bgcolor=#3c8dbc cellpadding=5px cellspacing=0 style="font-size: 10px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;">
|
||||
<tr>
|
||||
<td width=50% style="text-align:center;color: white;" bgcolor="#3c8dbc">
|
||||
<NEW_VERSION>
|
||||
| Sent: <REPORT_DATE>
|
||||
| Server: <SERVER_NAME>
|
||||
| Built: <BUILD_DATE>
|
||||
| Version: <BUILD_VERSION>
|
||||
NEW_VERSION
|
||||
| Sent: REPORT_DATE
|
||||
| Server: <a href="REPORT_DASHBOARD_URL" target="_blank" style="color:#ffffff;">SERVER_NAME</a>
|
||||
| Built: BUILD_DATE
|
||||
| Version: BUILD_VERSION
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<NEW_DEVICES_TABLE>
|
||||
<DOWN_DEVICES_TABLE>
|
||||
<DOWN_RECONNECTED_TABLE>
|
||||
<EVENTS_TABLE>
|
||||
<PLUGINS_TABLE>
|
||||
NEW_DEVICES_TABLE
|
||||
DOWN_DEVICES_TABLE
|
||||
DOWN_RECONNECTED_TABLE
|
||||
EVENTS_TABLE
|
||||
PLUGINS_TABLE
|
||||
|
||||
Report Date: <REPORT_DATE>
|
||||
Server: <SERVER_NAME>
|
||||
<NEW_VERSION>
|
||||
Report Date: REPORT_DATE
|
||||
Server: SERVER_NAME
|
||||
Link: REPORT_DASHBOARD_URL
|
||||
NEW_VERSION
|
||||
@@ -11,7 +11,11 @@ INSTALL_PATH = os.getenv("NETALERTX_APP", "/app")
|
||||
|
||||
def handle_sync_get():
|
||||
"""Handle GET requests for SYNC (NODE → HUB)."""
|
||||
file_path = INSTALL_PATH + "/api/table_devices.json"
|
||||
|
||||
# get all dwevices from the api endpoint
|
||||
api_path = os.environ.get('NETALERTX_API', '/tmp/api')
|
||||
|
||||
file_path = f"/{api_path}/table_devices.json"
|
||||
|
||||
try:
|
||||
with open(file_path, "rb") as f:
|
||||
|
||||
@@ -673,7 +673,7 @@ def importConfigs(pm, db, all_plugins):
|
||||
# Check if app was upgraded
|
||||
|
||||
buildTimestamp, new_version = getBuildTimeStampAndVersion()
|
||||
prev_version = conf.VERSION
|
||||
prev_version = conf.VERSION if conf.VERSION != '' else "unknown"
|
||||
|
||||
mylog('debug', [f"[Config] buildTimestamp | prev_version | .VERSION file: '{buildTimestamp}|{prev_version}|{new_version}'"])
|
||||
|
||||
@@ -684,7 +684,7 @@ def importConfigs(pm, db, all_plugins):
|
||||
# ccd(key, default, config_dir, name, inputtype, options, group, events=None, desc="", setJsonMetadata=None, overrideTemplate=None, forceDefault=False)
|
||||
ccd('VERSION', new_version , c_d, '_KEEP_', '_KEEP_', '_KEEP_', '_KEEP_', None, "_KEEP_", None, None, True)
|
||||
|
||||
write_notification(f'[Upgrade] : App upgraded from {prev_version} to {new_version} 🚀 Please clear the cache: <ol> <li>Click OK below</li> <li>Clear the browser cache (shift + browser refresh button)</li> <li> Clear app cache with the <i class="fa-solid fa-rotate"></i> (reload) button in the header</li><li>Go to Settings and click Save</li> </ol> Check out new features and what has changed in the <a href="https://github.com/jokob-sk/NetAlertX/releases" target="_blank">📓 release notes</a>.', 'interrupt', timeNowDB())
|
||||
write_notification(f'[Upgrade] : App upgraded from <code>{prev_version}</code> to <code>{new_version}</code> 🚀 Please clear the cache: <ol> <li>Click OK below</li> <li>Clear the browser cache (shift + browser refresh button)</li> <li> Clear app cache with the <i class="fa-solid fa-rotate"></i> (reload) button in the header</li><li>Go to Settings and click Save</li> </ol> Check out new features and what has changed in the <a href="https://github.com/jokob-sk/NetAlertX/releases" target="_blank">📓 release notes</a>.', 'interrupt', timeNowDB())
|
||||
|
||||
|
||||
# -----------------
|
||||
|
||||
@@ -14,6 +14,7 @@ from helper import (
|
||||
removeDuplicateNewLines,
|
||||
write_file,
|
||||
get_setting_value,
|
||||
getBuildTimeStampAndVersion,
|
||||
)
|
||||
from messaging.in_app import write_notification
|
||||
from utils.datetime_utils import timeNowDB, get_timezone_offset
|
||||
@@ -25,6 +26,7 @@ from utils.datetime_utils import timeNowDB, get_timezone_offset
|
||||
class NotificationInstance:
|
||||
def __init__(self, db):
|
||||
self.db = db
|
||||
self.serverUrl = get_setting_value("REPORT_DASHBOARD_URL")
|
||||
|
||||
# Create Notifications table if missing
|
||||
self.db.sql.execute("""CREATE TABLE IF NOT EXISTS "Notifications" (
|
||||
@@ -108,83 +110,71 @@ class NotificationInstance:
|
||||
if conf.newVersionAvailable:
|
||||
newVersionText = "🚀A new version is available."
|
||||
|
||||
mail_text = mail_text.replace("<NEW_VERSION>", newVersionText)
|
||||
mail_html = mail_html.replace("<NEW_VERSION>", newVersionText)
|
||||
mail_text = mail_text.replace("NEW_VERSION", newVersionText)
|
||||
mail_html = mail_html.replace("NEW_VERSION", newVersionText)
|
||||
|
||||
# Report "REPORT_DATE" in Header & footer
|
||||
timeFormated = timeNowDB()
|
||||
mail_text = mail_text.replace('<REPORT_DATE>', timeFormated)
|
||||
mail_html = mail_html.replace('<REPORT_DATE>', timeFormated)
|
||||
mail_text = mail_text.replace("REPORT_DATE", timeFormated)
|
||||
mail_html = mail_html.replace("REPORT_DATE", timeFormated)
|
||||
|
||||
# Report "SERVER_NAME" in Header & footer
|
||||
mail_text = mail_text.replace("<SERVER_NAME>", socket.gethostname())
|
||||
mail_html = mail_html.replace("<SERVER_NAME>", socket.gethostname())
|
||||
mail_text = mail_text.replace("SERVER_NAME", socket.gethostname())
|
||||
mail_html = mail_html.replace("SERVER_NAME", socket.gethostname())
|
||||
|
||||
# Report "VERSION" in Header & footer
|
||||
try:
|
||||
VERSIONFILE = subprocess.check_output(
|
||||
["php", applicationPath + "/front/php/templates/version.php"],
|
||||
timeout=5,
|
||||
).decode("utf-8")
|
||||
except Exception as e:
|
||||
mylog("debug", [f"[Notification] Unable to read version.php: {e}"])
|
||||
VERSIONFILE = "unknown"
|
||||
buildTimestamp, newBuildVersion = getBuildTimeStampAndVersion()
|
||||
|
||||
mail_text = mail_text.replace("<BUILD_VERSION>", VERSIONFILE)
|
||||
mail_html = mail_html.replace("<BUILD_VERSION>", VERSIONFILE)
|
||||
mail_text = mail_text.replace("BUILD_VERSION", newBuildVersion)
|
||||
mail_html = mail_html.replace("BUILD_VERSION", newBuildVersion)
|
||||
|
||||
# Report "BUILD" in Header & footer
|
||||
try:
|
||||
BUILDFILE = subprocess.check_output(
|
||||
["php", applicationPath + "/front/php/templates/build.php"],
|
||||
timeout=5,
|
||||
).decode("utf-8")
|
||||
except Exception as e:
|
||||
mylog("debug", [f"[Notification] Unable to read build.php: {e}"])
|
||||
BUILDFILE = "unknown"
|
||||
mail_text = mail_text.replace("BUILD_DATE", str(buildTimestamp))
|
||||
mail_html = mail_html.replace("BUILD_DATE", str(buildTimestamp))
|
||||
|
||||
mail_text = mail_text.replace("<BUILD_DATE>", BUILDFILE)
|
||||
mail_html = mail_html.replace("<BUILD_DATE>", BUILDFILE)
|
||||
# Report "REPORT_DASHBOARD_URL" in footer
|
||||
mail_text = mail_text.replace("REPORT_DASHBOARD_URL", self.serverUrl)
|
||||
mail_html = mail_html.replace("REPORT_DASHBOARD_URL", self.serverUrl)
|
||||
|
||||
# Start generating the TEXT & HTML notification messages
|
||||
# new_devices
|
||||
# ---
|
||||
html, text = construct_notifications(self.JSON, "new_devices")
|
||||
|
||||
mail_text = mail_text.replace("<NEW_DEVICES_TABLE>", text + "\n")
|
||||
mail_html = mail_html.replace("<NEW_DEVICES_TABLE>", html)
|
||||
mail_text = mail_text.replace("NEW_DEVICES_TABLE", text + "\n")
|
||||
mail_html = mail_html.replace("NEW_DEVICES_TABLE", html)
|
||||
mylog("verbose", ["[Notification] New Devices sections done."])
|
||||
|
||||
# down_devices
|
||||
# ---
|
||||
html, text = construct_notifications(self.JSON, "down_devices")
|
||||
|
||||
mail_text = mail_text.replace("<DOWN_DEVICES_TABLE>", text + "\n")
|
||||
mail_html = mail_html.replace("<DOWN_DEVICES_TABLE>", html)
|
||||
mail_text = mail_text.replace("DOWN_DEVICES_TABLE", text + "\n")
|
||||
mail_html = mail_html.replace("DOWN_DEVICES_TABLE", html)
|
||||
mylog("verbose", ["[Notification] Down Devices sections done."])
|
||||
|
||||
# down_reconnected
|
||||
# ---
|
||||
html, text = construct_notifications(self.JSON, "down_reconnected")
|
||||
|
||||
mail_text = mail_text.replace("<DOWN_RECONNECTED_TABLE>", text + "\n")
|
||||
mail_html = mail_html.replace("<DOWN_RECONNECTED_TABLE>", html)
|
||||
mail_text = mail_text.replace("DOWN_RECONNECTED_TABLE", text + "\n")
|
||||
mail_html = mail_html.replace("DOWN_RECONNECTED_TABLE", html)
|
||||
mylog("verbose", ["[Notification] Reconnected Down Devices sections done."])
|
||||
|
||||
# events
|
||||
# ---
|
||||
html, text = construct_notifications(self.JSON, "events")
|
||||
|
||||
mail_text = mail_text.replace("<EVENTS_TABLE>", text + "\n")
|
||||
mail_html = mail_html.replace("<EVENTS_TABLE>", html)
|
||||
mail_text = mail_text.replace("EVENTS_TABLE", text + "\n")
|
||||
mail_html = mail_html.replace("EVENTS_TABLE", html)
|
||||
mylog("verbose", ["[Notification] Events sections done."])
|
||||
|
||||
# plugins
|
||||
# ---
|
||||
html, text = construct_notifications(self.JSON, "plugins")
|
||||
|
||||
mail_text = mail_text.replace("<PLUGINS_TABLE>", text + "\n")
|
||||
mail_html = mail_html.replace("<PLUGINS_TABLE>", html)
|
||||
mail_text = mail_text.replace("PLUGINS_TABLE", text + "\n")
|
||||
mail_html = mail_html.replace("PLUGINS_TABLE", html)
|
||||
|
||||
mylog("verbose", ["[Notification] Plugins sections done."])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user