From 257e46df55bd65a1459b35873397e3422589c028 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Fri, 13 Oct 2023 20:53:04 +1100 Subject: [PATCH] =?UTF-8?q?Docs=20+=20Device=20list=20rework=20v0.3=20+=20?= =?UTF-8?q?#479=20work=20=F0=9F=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/SUBNETS.md | 2 +- front/devices.php | 65 ++++++++++++++------------- front/php/server/devices.php | 4 +- front/plugins/pihole_scan/config.json | 2 +- 4 files changed, 40 insertions(+), 33 deletions(-) diff --git a/docs/SUBNETS.md b/docs/SUBNETS.md index 04f5068e1..0c5a9a9a7 100755 --- a/docs/SUBNETS.md +++ b/docs/SUBNETS.md @@ -25,7 +25,7 @@ Specify the network filter (which **significantly** speeds up the scan process). **Example value: `--interface=eth0`** -The adapter will probably be `eth0` or `eth1`. (Run `iwconfig` in the container to find your interface name(s)) +The adapter will probably be `eth0` or `eth1`. (Check `System info` > `Network Hardware` or run `iwconfig` in the container to find your interface name(s)) > Run `iwconfig` in your container to find your interface name(s) (e.g.: `eth0`, `eth1`). diff --git a/front/devices.php b/front/devices.php index 07ed2e512..84eb57668 100755 --- a/front/devices.php +++ b/front/devices.php @@ -198,9 +198,30 @@ var tableRows = 10; var tableOrder = [[3,'desc'], [0,'asc']]; + var tableColumnHide = []; var columnsStr = '[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]'; var tableColumnOrder = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]; var tableColumnVisible = tableColumnOrder; + //initialize the table headers in the correct order + var headersDefaultOrder = [ getString('Device_TableHead_Name'), + getString('Device_TableHead_Owner'), + getString('Device_TableHead_Type'), + getString('Device_TableHead_Icon'), + getString('Device_TableHead_Favorite'), + getString('Device_TableHead_Group'), + getString('Device_TableHead_FirstSession'), + getString('Device_TableHead_LastSession'), + getString('Device_TableHead_LastIP'), + getString('Device_TableHead_MAC'), + getString('Device_TableHead_Status'), + getString('Device_TableHead_MAC_full'), + getString('Device_TableHead_LastIPOrder'), + getString('Device_TableHead_Rowid'), + getString('Device_TableHead_Parent_MAC'), + getString('Device_TableHead_Connected_Devices'), + getString('Device_TableHead_Location'), + getString('Device_TableHead_Vendor') + ]; // Read parameters & Initialize components main(); @@ -233,29 +254,6 @@ function main () { // save the columns order in the Devices page tableColumnOrder = numberArrayFromString(data); - - - //initialize the table headers in the correct order - var headersDefaultOrder = [ getString('Device_TableHead_Name'), - getString('Device_TableHead_Owner'), - getString('Device_TableHead_Type'), - getString('Device_TableHead_Icon'), - getString('Device_TableHead_Favorite'), - getString('Device_TableHead_Group'), - getString('Device_TableHead_FirstSession'), - getString('Device_TableHead_LastSession'), - getString('Device_TableHead_LastIP'), - getString('Device_TableHead_MAC'), - getString('Device_TableHead_Status'), - getString('Device_TableHead_MAC_full'), - getString('Device_TableHead_LastIPOrder'), - getString('Device_TableHead_Rowid'), - getString('Device_TableHead_Parent_MAC'), - getString('Device_TableHead_Connected_Devices'), - getString('Device_TableHead_Location'), - getString('Device_TableHead_Vendor') - ]; - html = ''; for(index = 0; index < tableColumnOrder.length; index++) @@ -298,8 +296,6 @@ function main () { } // ----------------------------------------------------------------------------- -var tableColumnHide = []; - // mapping the default order to the user specified one function mapIndx(oldIndex) { @@ -368,9 +364,13 @@ function initializeDatatable (status) { } } + console.log("tableColumnOrder") console.log(tableColumnOrder) + console.log("tableColumnVisible") console.log(tableColumnVisible) + console.log("tableColumnHide") console.log(tableColumnHide) + console.log(headersDefaultOrder) $.get('api/table_devices.json', function(result) { @@ -387,13 +387,13 @@ function initializeDatatable (status) { item.dev_Icon || "", item.dev_Favorite || "", item.dev_Group || "", + // --- item.dev_FirstConnection || "", item.dev_LastConnection || "", item.dev_LastIP || "", item.dev_MAC || "", // TODO handle internet node mac "status", - item.dev_MAC || "", // hidden - item.dev_StaticIP || 0, + item.dev_MAC || "", // hidden item.dev_LastIP || "", // IP orderable item.rowid || "", item.dev_Network_Node_MAC_ADDR || "", @@ -401,9 +401,14 @@ function initializeDatatable (status) { item.dev_Location || "", item.dev_Vendor || "", item.dev_Network_Node_port || 0 - ]; + ].map(function(value, oldIndex, arr) { + const newIndex = mapIndx(oldIndex); // Get the new index for this column + return arr[newIndex]; // Reorder the values based on the new index + }); }) }; + + console.log(dataArray["data"]) // TODO displayed columns @@ -442,7 +447,7 @@ function initializeDatatable (status) { {targets: [mapIndx(0)], 'createdCell': function (td, cellData, rowData, row, col) { - console.log(cellData) + // console.log(cellData) $(td).html (''+ cellData +''); } }, @@ -512,7 +517,7 @@ function initializeDatatable (status) { {targets: [mapIndx(10)], 'createdCell': function (td, cellData, rowData, row, col) { - console.log(cellData) + // console.log(cellData) switch (cellData) { case 'Down': color='red'; break; case 'New': color='yellow'; break; diff --git a/front/php/server/devices.php b/front/php/server/devices.php index 7b7c3419c..8a87c0f08 100755 --- a/front/php/server/devices.php +++ b/front/php/server/devices.php @@ -646,12 +646,14 @@ function getDevicesList() { $tableData = array(); while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { - $defaultOrder = array ($row['dev_Name'], + $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'], diff --git a/front/plugins/pihole_scan/config.json b/front/plugins/pihole_scan/config.json index 80a03d1d8..eeb84b3eb 100755 --- a/front/plugins/pihole_scan/config.json +++ b/front/plugins/pihole_scan/config.json @@ -82,7 +82,7 @@ { "function": "CMD", "type": "text", - "default_value":"SELECT n.hwaddr AS Object_PrimaryID, {s-quote}null{s-quote} AS Object_SecondaryID, datetime() AS DateTime, na.ip AS Watched_Value1, n.lastQuery AS Watched_Value2, na.name AS Watched_Value3, n.macVendor AS Watched_Value4, {s-quote}null{s-quote} AS Extra, n.hwaddr AS ForeignKey FROM EXTERNAL_PIHOLE.Network AS n LEFT JOIN EXTERNAL_PIHOLE.Network_Addresses AS na ON na.network_id = n.id WHERE n.hwaddr NOT LIKE {s-quote}ip-%{s-quote} AND n.hwaddr <> {s-quote}00:00:00:00:00:00{s-quote};", + "default_value":"SELECT n.hwaddr AS Object_PrimaryID, {s-quote}null{s-quote} AS Object_SecondaryID, datetime() AS DateTime, na.ip AS Watched_Value1, n.lastQuery AS Watched_Value2, na.name AS Watched_Value3, n.macVendor AS Watched_Value4, {s-quote}null{s-quote} AS Extra, n.hwaddr AS ForeignKey FROM EXTERNAL_PIHOLE.Network AS n LEFT JOIN EXTERNAL_PIHOLE.Network_Addresses AS na ON na.network_id = n.id WHERE n.hwaddr NOT LIKE {s-quote}ip-%{s-quote} AND n.hwaddr <> {s-quote}00:00:00:00:00:00{s-quote} AND na.ip <> null;", "options": [], "localized": ["name", "description"], "name" : [{