work #504 - New Dev + Events filter setting⚙

This commit is contained in:
Jokob-sk
2024-01-04 14:33:26 +11:00
parent 6809688623
commit f33d753cc1
4 changed files with 49 additions and 99 deletions

View File

@@ -46,7 +46,7 @@ class Notification_obj:
# Create a new DB entry if new notifications available, otherwise skip
def create(self, JSON, Extra=""):
JSON, Extra = self.on_before_create(self, JSON, Extra)
JSON, Extra = self.on_before_create(JSON, Extra)
# Write output data for debug
write_file (logPath + '/report_output.json', json.dumps(JSON))

View File

@@ -61,9 +61,10 @@ def get_notifications (db):
if 'new_devices' in conf.INCLUDED_SECTIONS:
# Compose New Devices Section
sqlQuery = """SELECT eve_MAC as MAC, eve_DateTime as Datetime, dev_LastIP as IP, eve_EventType as "Event Type", dev_Name as "Device name", dev_Comments as Comments FROM Events_Devices
sqlQuery = f"""SELECT eve_MAC as MAC, eve_DateTime as Datetime, dev_LastIP as IP, eve_EventType as "Event Type", dev_Name as "Device name", dev_Comments as Comments FROM Events_Devices
WHERE eve_PendingAlertEmail = 1
AND eve_EventType = 'New Device'
{get_setting_value('NTFPRCS_new_dev_condition')}
ORDER BY eve_DateTime"""
# Get the events as JSON
@@ -73,6 +74,7 @@ def get_notifications (db):
"title": "New devices",
"columnNames": json_obj.columnNames
}
json_new_devices = json_obj.json["data"]
if 'down_devices' in conf.INCLUDED_SECTIONS:
@@ -105,10 +107,11 @@ def get_notifications (db):
if 'events' in conf.INCLUDED_SECTIONS:
# Compose Events Section
sqlQuery = """SELECT eve_MAC as MAC, eve_DateTime as Datetime, dev_LastIP as IP, eve_EventType as "Event Type", dev_Name as "Device name", dev_Comments as Comments FROM Events_Devices
sqlQuery = f"""SELECT eve_MAC as MAC, eve_DateTime as Datetime, dev_LastIP as IP, eve_EventType as "Event Type", dev_Name as "Device name", dev_Comments as Comments FROM Events_Devices
WHERE eve_PendingAlertEmail = 1
AND eve_EventType IN ('Connected','Disconnected',
'IP Changed')
{get_setting_value('NTFPRCS_event_condition')}
ORDER BY eve_DateTime"""
# Get the events as JSON