diff --git a/front/php/templates/language/ar_ar.json b/front/php/templates/language/ar_ar.json old mode 100755 new mode 100644 index e0b87213..b4d6caef --- a/front/php/templates/language/ar_ar.json +++ b/front/php/templates/language/ar_ar.json @@ -761,4 +761,4 @@ "settings_system_label": "تسمية النظام", "settings_update_item_warning": "تحذير تحديث العنصر", "test_event_tooltip": "تلميح اختبار الحدث" -} \ No newline at end of file +} diff --git a/front/report_templates/report_sample.txt b/front/report_templates/report_sample.txt index e476e5da..4c8526ce 100755 --- a/front/report_templates/report_sample.txt +++ b/front/report_templates/report_sample.txt @@ -44,3 +44,4 @@ More Info: Report Date: 2021-12-08 12:30 Server: Synology-NAS +Link: netalertx.com diff --git a/front/report_templates/report_template.html b/front/report_templates/report_template.html index 7be350b5..58c600bd 100755 --- a/front/report_templates/report_template.html +++ b/front/report_templates/report_template.html @@ -1,12 +1,3 @@ - - @@ -20,11 +11,11 @@ - - - - - + NEW_DEVICES_TABLE + DOWN_DEVICES_TABLE + DOWN_RECONNECTED_TABLE + EVENTS_TABLE + PLUGINS_TABLE @@ -34,11 +25,11 @@
- - | Sent: - | Server: - | Built: - | Version: + NEW_VERSION + | Sent: REPORT_DATE + | Server: SERVER_NAME + | Built: BUILD_DATE + | Version: BUILD_VERSION
diff --git a/front/report_templates/report_template.txt b/front/report_templates/report_template.txt index 8be4447b..c0fabe6f 100755 --- a/front/report_templates/report_template.txt +++ b/front/report_templates/report_template.txt @@ -1,9 +1,10 @@ - - - - - +NEW_DEVICES_TABLE +DOWN_DEVICES_TABLE +DOWN_RECONNECTED_TABLE +EVENTS_TABLE +PLUGINS_TABLE -Report Date: -Server: - \ No newline at end of file +Report Date: REPORT_DATE +Server: SERVER_NAME +Link: REPORT_DASHBOARD_URL +NEW_VERSION \ No newline at end of file diff --git a/server/api_server/sync_endpoint.py b/server/api_server/sync_endpoint.py index 883a8645..d756d286 100755 --- a/server/api_server/sync_endpoint.py +++ b/server/api_server/sync_endpoint.py @@ -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: diff --git a/server/initialise.py b/server/initialise.py index 891ad452..4389ebb3 100755 --- a/server/initialise.py +++ b/server/initialise.py @@ -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:
  1. Click OK below
  2. Clear the browser cache (shift + browser refresh button)
  3. Clear app cache with the (reload) button in the header
  4. Go to Settings and click Save
Check out new features and what has changed in the 📓 release notes.', 'interrupt', timeNowDB()) + write_notification(f'[Upgrade] : App upgraded from {prev_version} to {new_version} 🚀 Please clear the cache:
  1. Click OK below
  2. Clear the browser cache (shift + browser refresh button)
  3. Clear app cache with the (reload) button in the header
  4. Go to Settings and click Save
Check out new features and what has changed in the 📓 release notes.', 'interrupt', timeNowDB()) # ----------------- diff --git a/server/models/notification_instance.py b/server/models/notification_instance.py index 09c78efd..c4367c67 100755 --- a/server/models/notification_instance.py +++ b/server/models/notification_instance.py @@ -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("", newVersionText) - mail_html = mail_html.replace("", 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('', timeFormated) - mail_html = mail_html.replace('', 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("", socket.gethostname()) - mail_html = mail_html.replace("", 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("", VERSIONFILE) - mail_html = mail_html.replace("", 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("", BUILDFILE) - mail_html = mail_html.replace("", 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("", text + "\n") - mail_html = mail_html.replace("", 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("", text + "\n") - mail_html = mail_html.replace("", 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("", text + "\n") - mail_html = mail_html.replace("", 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("", text + "\n") - mail_html = mail_html.replace("", 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("", text + "\n") - mail_html = mail_html.replace("", html) + mail_text = mail_text.replace("PLUGINS_TABLE", text + "\n") + mail_html = mail_html.replace("PLUGINS_TABLE", html) mylog("verbose", ["[Notification] Plugins sections done."])