diff --git a/front/css/dark-patch.css b/front/css/dark-patch.css index 9fea6749..5a1016e3 100755 --- a/front/css/dark-patch.css +++ b/front/css/dark-patch.css @@ -659,8 +659,14 @@ input[type="password"]::-webkit-caps-lock-indicator { border-color: #888888; } .table-hover tbody tr:hover td, .table-hover tbody tr:hover th { - background-color: rgb(189,192,198); - color: #444; + background-color: var(--datatable-bgcolor); + color: var(--fbc-white); +} + +table.dataTable tbody tr.selected, table.dataTable tbody tr .selected +{ + background-color: var(--datatable-bgcolor); + color: var(--fbc-white); } .db_info_table_cell:nth-child(1) {background: #272c30} diff --git a/front/css/system-dark-patch.css b/front/css/system-dark-patch.css index 43706116..ac5bb25f 100755 --- a/front/css/system-dark-patch.css +++ b/front/css/system-dark-patch.css @@ -20,7 +20,7 @@ --color-yellow: #f39c12; --color-red: #dd4b39; --color-gray: #8c8c8c; -} + } :root { --datatable-bgcolor: rgba(64, 76, 88, 0.8); diff --git a/front/deviceDetails.php b/front/deviceDetails.php index 512fee30..ca903795 100755 --- a/front/deviceDetails.php +++ b/front/deviceDetails.php @@ -225,13 +225,6 @@ switch ($UI_THEME) { var selectedTab = 'tabDetails'; var emptyArr = ['undefined', "", undefined, null]; - -// Call renderSmallBoxes, then main -(async () => { - await renderSmallBoxes(); - main(); -})(); - // ----------------------------------------------------------------------------- function main () { @@ -299,17 +292,32 @@ function recordSwitch(direction) { function updateChevrons(currentMac) { const devicesList = getDevicesList(); - // Find the index of the device by MAC - pos = devicesList.findIndex(item => item.devMac == currentMac); + pos = devicesList.findIndex(item => item.devMac === currentMac); - // If device not found, optionally add it or handle error if (pos === -1) { - // If you want to add a placeholder or handle missing device: - // devicesList.push({ mac: currentMac, name: 'Unknown', type: 'Unknown' }); - // pos = devicesList.length - 1; + console.warn('Device not found in cache. Re-caching devices...', currentMac); + + showSpinner(); + + cacheDevices().then(() => { + hideSpinner(); + + // Retry after re-caching + const refreshedList = getDevicesList(); + pos = refreshedList.findIndex(item => item.devMac === currentMac); + + if (pos === -1) { + console.error('Still not found after re-cache:', currentMac); + return; + } + + console.log('Device found after re-cache:', refreshedList[pos]); + // Proceed with using `refreshedList[pos]` + }).catch((err) => { + hideSpinner(); + console.error('Failed to cache devices:', err); + }); - // Or just return early if device not found - console.warn('Device with MAC not found:', currentMac); return; } @@ -345,7 +353,7 @@ function performSwitch(direction) // Update the global position in the devices list variable 'pos' if (direction === "next") { - console.log("direction" + direction); + console.log("direction:" + direction); if (pos < devicesList.length) { pos++; @@ -485,34 +493,58 @@ async function renderSmallBoxes() { } function updateDevicePageName(mac) { + let name = getDevDataByMac(mac, "devName"); + let owner = getDevDataByMac(mac, "devOwner"); - name = getDevDataByMac(mac, "devName") - owner = getDevDataByMac(mac, "devOwner") + // If data is missing, re-cache and retry once + if (name === "Unknown" || owner === "Unknown") { + console.warn("Device not found in cache, retrying after re-cache:", mac); + showSpinner(); + cacheDevices().then(() => { + hideSpinner(); + // Retry after successful cache + updateDevicePageName(mac); + }).catch((err) => { + hideSpinner(); + console.error("Failed to refresh devices:", err); + }); + return; // Exit early to avoid showing bad data + } // Page title - Name if (mac == "new") { - $('#pageTitle').html(` ` + getString("Gen_create_new_device")); - $('#devicePageInfoPlc .inner').html(` ` + getString("Gen_create_new_device_info")); - $('#devicePageInfoPlc').show(); - } else if (owner == null || owner == '' || - (name.toString()).indexOf(owner) != -1) { - $('#pageTitle').html(name); - $('#devicePageInfoPlc').hide(); + $('#pageTitle').html( + ` ` + getString("Gen_create_new_device") + ); + $('#devicePageInfoPlc .inner').html( + ` ` + getString("Gen_create_new_device_info") + ); + $('#devicePageInfoPlc').show(); + } else if (!owner || (name.toString()).indexOf(owner) !== -1) { + $('#pageTitle').html(name); + $('#devicePageInfoPlc').hide(); } else { - $('#pageTitle').html(name + ' (' + owner + ')'); - $('#devicePageInfoPlc').hide(); + $('#pageTitle').html(name + ' (' + owner + ')'); + $('#devicePageInfoPlc').hide(); } - } + //----------------------------------------------------------------------------------- +// Call renderSmallBoxes, then main +(async () => { + await renderSmallBoxes(); + main(); + })(); + window.onload = function async() { initializeTabs(); updateChevrons(mac); updateDevicePageName(mac); + } diff --git a/front/js/common.js b/front/js/common.js index a763fea2..0cf15b7b 100755 --- a/front/js/common.js +++ b/front/js/common.js @@ -1039,11 +1039,8 @@ function getDevDataByMac(macAddress, dbColumn) { // Cache the devices as one JSON function cacheDevices() { - return new Promise((resolve, reject) => { - // if(!getCache('completedCalls').includes('cacheDevices')) - // { $.get('php/server/query_json.php', { file: 'table_devices.json', nocache: Date.now() }, function(data) { // console.log(data) @@ -1067,8 +1064,7 @@ function cacheDevices() // console.log(getCache('devicesListAll_JSON')) }).then(() => handleSuccess('cacheDevices', resolve())).catch(() => handleFailure('cacheDevices', reject("cacheDevices already completed"))); // handle AJAX synchronization } - // } -); + ); } var devicesListAll_JSON = []; // this will contain a list off all devices diff --git a/front/php/templates/language/ar_ar.json b/front/php/templates/language/ar_ar.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/ca_ca.json b/front/php/templates/language/ca_ca.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/cs_cz.json b/front/php/templates/language/cs_cz.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/de_de.json b/front/php/templates/language/de_de.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/es_es.json b/front/php/templates/language/es_es.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/it_it.json b/front/php/templates/language/it_it.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/nb_no.json b/front/php/templates/language/nb_no.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/pl_pl.json b/front/php/templates/language/pl_pl.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/pt_br.json b/front/php/templates/language/pt_br.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/ru_ru.json b/front/php/templates/language/ru_ru.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/tr_tr.json b/front/php/templates/language/tr_tr.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/uk_ua.json b/front/php/templates/language/uk_ua.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/zh_cn.json b/front/php/templates/language/zh_cn.json old mode 100644 new mode 100755