diff --git a/front/deviceDetails.php b/front/deviceDetails.php index ecc2d72b..2b775997 100755 --- a/front/deviceDetails.php +++ b/front/deviceDetails.php @@ -497,7 +497,7 @@ function updateDevicePageName(mac) { let owner = getDevDataByMac(mac, "devOwner"); // If data is missing, re-cache and retry once - if (mac != 'new' && (name === "Unknown" || owner === "Unknown")) { + if (mac != 'new' && (name === null|| owner === null)) { console.warn("Device not found in cache, retrying after re-cache:", mac); showSpinner(); cacheDevices().then(() => { diff --git a/front/js/common.js b/front/js/common.js index 3dc4cf15..a4b57e57 100755 --- a/front/js/common.js +++ b/front/js/common.js @@ -609,7 +609,7 @@ function createDeviceLink(input) { if(checkMacOrInternet(input)) { - return `${getNameByMacAddress(input)}` + return `${getDevDataByMac(input, "devName")}` } return input; @@ -813,7 +813,6 @@ function forceLoadUrl(relativeUrl) { } - // ----------------------------------------------------------------------------- function navigateToDeviceWithIp (ip) { @@ -836,11 +835,6 @@ function navigateToDeviceWithIp (ip) { }); } -// ----------------------------------------------------------------------------- -function getNameByMacAddress(macAddress) { - return getDevDataByMac(macAddress, "devName") -} - // ----------------------------------------------------------------------------- // Check if MAC or Internet function checkMacOrInternet(inputStr) { @@ -1013,7 +1007,7 @@ function getDevDataByMac(macAddress, dbColumn) { if (!devicesCache || devicesCache == "") { console.error(`Session variable "${sessionDataKey}" not found.`); - return "Unknown"; + return null; } const devices = JSON.parse(devicesCache); @@ -1033,7 +1027,7 @@ function getDevDataByMac(macAddress, dbColumn) { } console.error("⚠ Device with MAC not found:" + macAddress) - return "Unknown"; // Return a default value if MAC address is not found + return null; // Return a default value if MAC address is not found } // ----------------------------------------------------------------------------- diff --git a/front/js/ui_components.js b/front/js/ui_components.js index e9f7b9e7..33dd7929 100755 --- a/front/js/ui_components.js +++ b/front/js/ui_components.js @@ -782,15 +782,15 @@ function initSelect2() { // ------------------------------------------ // Render a device link with hover-over functionality function renderDeviceLink(data, container, useName = false) { - if (!data.id || !isValidMac(data.id)) return data.text; // default placeholder etc. + // If no valid MAC, return placeholder text + if (!data.id || !isValidMac(data.id)) { + return data.text; + } const device = getDevDataByMac(data.id); - - const badge = getStatusBadgeParts( - device.devPresentLastScan, - device.devAlertDown, - device.devMac - ); + if (!device) { + return data.text; + } // badge class and hover-info class to container $(container) diff --git a/front/network.php b/front/network.php index 0fe3355a..61a58815 100755 --- a/front/network.php +++ b/front/network.php @@ -197,7 +197,7 @@