mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-05-19 14:16:47 -04:00
BE+FE: timestamps for sessions and emails corrected #1639
This commit is contained in:
@@ -56,9 +56,6 @@ function initializeSessionsDatatable (sessionsRows) {
|
||||
|
||||
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
|
||||
|
||||
@@ -613,7 +613,8 @@
|
||||
"options": [
|
||||
"devMac",
|
||||
"devName",
|
||||
"devVendor"
|
||||
"devVendor",
|
||||
"devLastIP"
|
||||
],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
@@ -810,7 +811,7 @@
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "sync"
|
||||
"value": "SYNC"
|
||||
},
|
||||
"css_classes": "col-sm-2",
|
||||
"show": false,
|
||||
|
||||
@@ -185,9 +185,6 @@ def is_authorized():
|
||||
return is_authorized_result
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@app.route('/mcp/sse', methods=['GET', 'POST', 'OPTIONS'])
|
||||
def api_mcp_sse():
|
||||
if not is_authorized():
|
||||
|
||||
@@ -35,11 +35,10 @@ from messaging.notification_sections import ( # noqa: E402 [flake8 lint suppres
|
||||
)
|
||||
import conf # noqa: E402 [flake8 lint suppression]
|
||||
|
||||
|
||||
# ===============================================================================
|
||||
# Timezone conversion
|
||||
# ===============================================================================
|
||||
|
||||
|
||||
def get_datetime_fields_from_columns(column_names):
|
||||
return [
|
||||
col for col in column_names
|
||||
@@ -81,6 +80,7 @@ def apply_timezone(data, fields):
|
||||
|
||||
for field in fields:
|
||||
value = row.get(field)
|
||||
|
||||
if not value:
|
||||
continue
|
||||
|
||||
@@ -226,11 +226,12 @@ def get_notifications(db):
|
||||
|
||||
try:
|
||||
json_obj = db.get_table_as_json(sqlQuery, parameters)
|
||||
data = apply_timezone_to_json(json_obj, section)
|
||||
except Exception as e:
|
||||
mylog("minimal", [f"[Notification] DB error in section {section}: ", e])
|
||||
continue
|
||||
|
||||
final_json[section] = json_obj.json.get("data", [])
|
||||
final_json[section] = data
|
||||
final_json[f"{section}_meta"] = {
|
||||
"title": SECTION_TITLES.get(section, section),
|
||||
"columnNames": getattr(json_obj, "columnNames", [])
|
||||
|
||||
@@ -206,17 +206,18 @@ def format_date_iso(date_val: str) -> Optional[str]:
|
||||
else:
|
||||
dt = date_val
|
||||
|
||||
# 2. If it has no timezone, assume it's UTC (our DB storage format)
|
||||
# then CONVERT to user's configured timezone
|
||||
# 2. Normalize to UTC first, then convert to target timezone
|
||||
if dt.tzinfo is None:
|
||||
# Mark as UTC first — critical: localize() would label without converting
|
||||
dt = dt.replace(tzinfo=datetime.UTC)
|
||||
# Resolve target timezone; fall back to UTC if conf.tz is missing/invalid
|
||||
try:
|
||||
target_tz = conf.tz if isinstance(conf.tz, datetime.tzinfo) else ZoneInfo(conf.tz)
|
||||
except (ZoneInfoNotFoundError, ValueError, TypeError):
|
||||
target_tz = datetime.UTC
|
||||
dt = dt.astimezone(target_tz)
|
||||
else:
|
||||
dt = dt.astimezone(datetime.UTC)
|
||||
|
||||
try:
|
||||
target_tz = conf.tz if isinstance(conf.tz, datetime.tzinfo) else ZoneInfo(str(conf.tz))
|
||||
except Exception:
|
||||
target_tz = datetime.UTC
|
||||
|
||||
dt = dt.astimezone(target_tz)
|
||||
|
||||
# 3. Return the string. .isoformat() will now include the +11:00 or +10:00
|
||||
return dt.isoformat()
|
||||
|
||||
Reference in New Issue
Block a user