From 02771cf3993f059c883b1f544153d4d373be2a71 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Mon, 5 Feb 2024 20:51:00 +1100 Subject: [PATCH] =?UTF-8?q?Workflows=20v0.1.13=20=F0=9F=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/appEventsCore.php | 7 ++++--- front/js/pialert_common.js | 25 +++++++++++++++++++++++-- front/php/templates/language/en_us.json | 3 +-- pialert/appevent.py | 6 ++---- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/front/appEventsCore.php b/front/appEventsCore.php index b298be42..96831e19 100755 --- a/front/appEventsCore.php +++ b/front/appEventsCore.php @@ -57,10 +57,11 @@ function processData(data) { { data: 'DateTimeCreated', title: getString('AppEvents_DateTimeCreated') }, { data: 'AppEventType', title: getString('AppEvents_Type') }, { data: 'ObjectType', title: getString('AppEvents_ObjectType') }, - { data: 'ObjectMAC', title: getString('AppEvents_ObjectMAC') }, - { data: 'ObjectIP', title: getString('AppEvents_ObjectIP') }, + { data: 'ObjectPrimaryID', title: getString('AppEvents_ObjectPrimaryID') }, + { data: 'ObjectSecondaryID', title: getString('AppEvents_ObjectSecondaryID') }, { data: 'ObjectStatus', title: getString('AppEvents_ObjectStatus') }, { data: 'Extra', title: getString('AppEvents_Extra') }, + { data: 'ObjectPlugin', title: getString('AppEvents_Plugin') }, // Add other columns as needed ], // Add column-specific configurations if needed @@ -69,7 +70,7 @@ function processData(data) { { width: '80px', targets: [6] }, // ... Add other columnDefs as needed // Full MAC - {targets: [3], + {targets: [3, 4], 'createdCell': function (td, cellData, rowData, row, col) { if (!emptyArr.includes(cellData)){ $(td).html (createDeviceLink(cellData)); diff --git a/front/js/pialert_common.js b/front/js/pialert_common.js index 16174bce..4428e795 100755 --- a/front/js/pialert_common.js +++ b/front/js/pialert_common.js @@ -429,9 +429,14 @@ function saveData(functionName, id, value) { // ----------------------------------------------------------------------------- // create a link to the device -function createDeviceLink(mac) +function createDeviceLink(input) { - return `${getNameByMacAddress(mac)}` + if(checkMacOrInternet(input)) + { + return `${getNameByMacAddress(input)}` + } + + return input; } @@ -547,6 +552,22 @@ function getNameByMacAddress(macAddress) { return getDeviceDataByMacAddress(macAddress, "dev_Name") } +// ----------------------------------------------------------------------------- +// Check if MAC or Internet +function checkMacOrInternet(inputStr) { + // Regular expression pattern for matching a MAC address + const macPattern = /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/; + + if (inputStr.toLowerCase() === 'internet') { + return true; + } else if (macPattern.test(inputStr)) { + return true; + } else { + return false; + } +} + + // ----------------------------------------------------------------------------- // A function used to make the IP address orderable function isValidIPv6(ipAddress) { diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index 021136e8..68ae1577 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -7,8 +7,6 @@ "AppEvents_DateTimeCreated" : "Logged", "AppEvents_ObjectType" : "Object Type", "AppEvents_ObjectPlugin" : "Linked Plugin", - "AppEvents_ObjectMAC" : "Linked MAC (at log time)", - "AppEvents_ObjectIP" : "Linked IP (at log time)", "AppEvents_ObjectPrimaryID" : "Primary ID", "AppEvents_ObjectSecondaryID" : "Secondary ID", "AppEvents_ObjectForeignKey" : "Foreign Key", @@ -17,6 +15,7 @@ "AppEvents_ObjectIsArchived" : "Is archived (at log time)", "AppEvents_ObjectStatusColumn" : "Status column", "AppEvents_ObjectStatus" : "Status (at log time)", + "AppEvents_Plugin" : "Plugin", "AppEvents_Type" : "Type", "AppEvents_Helper1" : "Helper 1", "AppEvents_Helper2" : "Helper 2", diff --git a/pialert/appevent.py b/pialert/appevent.py index 26b10136..a896a433 100755 --- a/pialert/appevent.py +++ b/pialert/appevent.py @@ -37,8 +37,6 @@ class AppEvent_obj: "ObjectType" TEXT, -- ObjectType (Plugins, Notifications, Events) "ObjectGUID" TEXT, "ObjectPlugin" TEXT, - "ObjectMAC" TEXT, - "ObjectIP" TEXT, "ObjectPrimaryID" TEXT, "ObjectSecondaryID" TEXT, "ObjectForeignKey" TEXT, @@ -74,8 +72,8 @@ class AppEvent_obj: "GUID", "DateTimeCreated", "ObjectType", - "ObjectMAC", - "ObjectIP", + "ObjectPrimaryID", + "ObjectSecondaryID", "ObjectStatus", "ObjectStatusColumn", "ObjectIsNew",