From 2b95daa2488d3235d823378ee1ff86f9eb848353 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Mon, 10 Apr 2023 17:00:29 +1000 Subject: [PATCH] Fix MAC not passed - #205 --- front/devices.php | 6 ++- front/maintenance.php | 12 +++--- front/php/server/devices.php | 76 ++++-------------------------------- 3 files changed, 18 insertions(+), 76 deletions(-) diff --git a/front/devices.php b/front/devices.php index c37e7199..b0b04342 100755 --- a/front/devices.php +++ b/front/devices.php @@ -225,6 +225,8 @@ function main () { // save the columns order in the Devices page tableColumnOrder = numberArrayFromString(data); + + //initialize the table headers in the correct order var headersDefaultOrder = [ '', '', @@ -308,7 +310,7 @@ function mapIndx(oldIndex) function initializeDatatable () { for(i = 0; i < tableColumnOrder.length; i++) { - // hide this column if not in the tableColumnVisible variable + // hide this column if not in the tableColumnVisible variable (we need to keep the MAC address (index 11) for functionality reasons) if(tableColumnVisible.includes(tableColumnOrder[i]) == false) { tableColumnHide.push(mapIndx(tableColumnOrder[i])); @@ -348,7 +350,7 @@ function initializeDatatable () { // Device Name {targets: [mapIndx(0)], - 'createdCell': function (td, cellData, rowData, row, col) { + 'createdCell': function (td, cellData, rowData, row, col) { $(td).html (''+ cellData +''); } }, diff --git a/front/maintenance.php b/front/maintenance.php index bbfdc4f7..fe6f9a9f 100755 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -707,7 +707,11 @@ function scrollDown() for (let i = 0; i < areaIDs.length; i++) { var tempArea = $('#' + areaIDs[i]); - $(tempArea[0]).scrollTop(tempArea[0].scrollHeight); + + if (tempArea.length > 0) + { + $(tempArea[0]).scrollTop(tempArea[0].scrollHeight); + } } } @@ -715,8 +719,8 @@ function scrollDown() // -------------------------------------------------------- // Manage displayed columns // -------------------------------------------------------- -colDefaultOrder = ['0','1','2','3','4','5','6','7','8','9','10','12','13','14','15','16','17']; -colDefaultOrderTxt = '[0,1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17]'; +colDefaultOrder = ['0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17']; +colDefaultOrderTxt = '[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]'; function saveSelectedColumns () { @@ -724,9 +728,7 @@ function saveSelectedColumns () { // save full order of all columns to simplify mapping later on colDisplayed = $('#columnsSelect').val(); - - colNewOrder = colDisplayed; // append the remaining columns in the previous order diff --git a/front/php/server/devices.php b/front/php/server/devices.php index 64060e78..67b4e805 100755 --- a/front/php/server/devices.php +++ b/front/php/server/devices.php @@ -570,72 +570,6 @@ function getDevicesTotals() { } -//------------------------------------------------------------------------------ -// Query the List of devices in a determined Status -//------------------------------------------------------------------------------ -// function getDevicesListForNetworkTree() { -// global $db; - -// $sql = 'SELECT *, CASE -// WHEN t1.dev_AlertDeviceDown=1 AND t1.dev_PresentLastScan=0 THEN "Down" -// WHEN t1.dev_NewDevice=1 THEN "New" -// WHEN t1.dev_PresentLastScan=1 THEN "On-line" -// ELSE "Off-line" END AS dev_Status -// FROM (Devices ) t1 -// LEFT JOIN -// ( -// SELECT *, -// count() as connected_devices -// FROM Devices b -// WHERE b.dev_Network_Node_MAC_ADDR NOT NULL group by b.dev_Network_Node_MAC_ADDR -// ) t2 -// ON (t1.dev_MAC = t2.dev_MAC); '; - -// $result = $db->query($sql); - -// // arrays of rows -// $tableData = array(); -// while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { - -// $defaultOrder = array ($row['dev_Name'], -// $row['dev_Owner'], -// handleNull($row['dev_DeviceType']), -// handleNull($row['dev_Icon'], "laptop"), -// $row['dev_Favorite'], -// $row['dev_Group'], -// formatDate ($row['dev_FirstConnection']), -// formatDate ($row['dev_LastConnection']), -// $row['dev_LastIP'], -// ( in_array($row['dev_MAC'][1], array("2","6","A","E","a","e")) ? 1 : 0), -// $row['dev_Status'], -// $row['dev_MAC'], // MAC (hidden) -// formatIPlong ($row['dev_LastIP']), // IP orderable -// $row['rowid'], // Rowid (hidden) -// handleNull($row['dev_Network_Node_MAC_ADDR']), // -// handleNull($row['connected_devices']) // -// ); - -// $newOrder = array(); - -// // reorder columns based on user settings -// for($index = 0; $index < count($columnOrderMapping); $index++) -// { -// array_push($newOrder, $defaultOrder[$columnOrderMapping[$index][2]]); -// } - -// $tableData['data'][] = $newOrder; -// } - -// // Control no rows -// if (empty($tableData['data'])) { -// $tableData['data'] = ''; -// } - -// // Return json -// echo (json_encode ($tableData)); - -// } - //------------------------------------------------------------------------------ // Query the List of devices in a determined Status //------------------------------------------------------------------------------ @@ -649,7 +583,7 @@ function getDevicesList() { $forceDefaultOrder = TRUE; } - // This object is used to map from the old order ( second parameter, first number) to the 3rd parameter (Second number (here initialized to -1)) + // This object is used to map from the old order ( second parameter, first number) to the new mapping, that is represented by the 3rd parameter (Second number) $columnOrderMapping = array( array("dev_Name", 0, 0), array("dev_Owner", 1, 1), @@ -684,9 +618,13 @@ function getDevicesList() { $orderedColumns = createArray($row[0]); // init ordered columns - for($i = 0; $i < count($orderedColumns); $i++) { - $columnOrderMapping[$i][2] = $orderedColumns[$i]; + for($i = 0; $i < count($orderedColumns); $i++) { + + $oldVal = $columnOrderMapping[$i][2]; + + $columnOrderMapping[$i][2] = $orderedColumns[$i]; } + } }