Skip to content

Commit

Permalink
Docs + Device list rework v0.3 + #479 work 🔨
Browse files Browse the repository at this point in the history
  • Loading branch information
jokob-sk committed Oct 13, 2023
1 parent 3c856c0 commit 257e46d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 33 deletions.
2 changes: 1 addition & 1 deletion docs/SUBNETS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`).
Expand Down
65 changes: 35 additions & 30 deletions front/devices.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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++)
Expand Down Expand Up @@ -298,8 +296,6 @@ function main () {
}

// -----------------------------------------------------------------------------
var tableColumnHide = [];

// mapping the default order to the user specified one
function mapIndx(oldIndex)
{
Expand Down Expand Up @@ -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) {

Expand All @@ -387,23 +387,28 @@ 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 || "",
item.connected_devices || 0,
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

Expand Down Expand Up @@ -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 ('<b class="anonymizeDev"><a href="deviceDetails.php?mac='+ rowData[mapIndx(11)] +'" class="">'+ cellData +'</a></b>');
} },

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion front/php/server/devices.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion front/plugins/pihole_scan/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" : [{
Expand Down

0 comments on commit 257e46d

Please sign in to comment.