From 508a2d67b9d5a1d6a40d9cfe4e4d002c5d05a7bf Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Tue, 6 Feb 2024 09:01:55 +1100 Subject: [PATCH] =?UTF-8?q?New=20Devices=20Columns=20#556=20=F0=9F=9A=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/devices.php | 74 +++++++++++++++++-------- front/php/templates/language/en_us.json | 3 +- front/plugins/README.md | 3 +- 3 files changed, 55 insertions(+), 25 deletions(-) diff --git a/front/devices.php b/front/devices.php index d38824e6..fb0364ba 100755 --- a/front/devices.php +++ b/front/devices.php @@ -203,25 +203,27 @@ 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') - ]; + 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'), + getString('Device_TableHead_Port') + ]; // Read parameters & Initialize components main(); @@ -425,7 +427,7 @@ function initializeDatatable (status) { formatIPlong(item.dev_LastIP) || "", // IP orderable item.rowid || "", item.dev_Network_Node_MAC_ADDR || "", - item.connected_devices || 0, + getNumberOfChildren(item.dev_MAC, result.data) || 0, item.dev_Location || "", item.dev_Vendor || "", item.dev_Network_Node_port || 0 @@ -471,9 +473,9 @@ function initializeDatatable (status) { 'columnDefs' : [ {visible: false, targets: tableColumnHide }, - {className: 'text-center', targets: [mapIndx(3), mapIndx(4), mapIndx(9), mapIndx(10), mapIndx(15)] }, + {className: 'text-center', targets: [mapIndx(3), mapIndx(4), mapIndx(9), mapIndx(10), mapIndx(15), mapIndx(18)] }, {width: '80px', targets: [mapIndx(6), mapIndx(7), mapIndx(15)] }, - {width: '30px', targets: [mapIndx(10), mapIndx(13)] }, + {width: '30px', targets: [mapIndx(10), mapIndx(13), mapIndx(18)] }, {orderData: [mapIndx(12)], targets: mapIndx(8) }, // Device Name @@ -486,8 +488,17 @@ function initializeDatatable (status) { // Connected Devices {targets: [mapIndx(15)], - 'createdCell': function (td, cellData, rowData, row, col) { + 'createdCell': function (td, cellData, rowData, row, col) { + // check if this is a network device + if(getSetting("NETWORK_DEVICE_TYPES").includes(`'${rowData[mapIndx(2)]}'`) ) + { $(td).html (''+ cellData +''); + } + else + { + $(td).html (``) + } + } }, // Icon @@ -648,6 +659,23 @@ function getDevicesTotals () { } ); } +// ----------------------------------------------------------------------------- +function getNumberOfChildren(mac, devices) +{ + childrenCount = 0; + + $.each(devices, function(index, dev) { + + if(dev.dev_Network_Node_MAC_ADDR.trim() == mac.trim()) + { + childrenCount++; + } + + }); + + return childrenCount; +} + // ----------------------------------------------------------------------------- function handleLoadingDialog() { diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index 68ae1577..aefb99c6 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -83,7 +83,7 @@ "Device_TableHead_RowID" : "Row ID", "Device_TableHead_Rowid" : "Row ID", "Device_TableHead_Parent_MAC" : "Parent node MAC", - "Device_TableHead_Connected_Devices" : "Connected Devices", + "Device_TableHead_Connected_Devices" : "Connections", "Device_TableHead_Location" : "Location", "Device_TableHead_Vendor" : "Vendor", "Device_TableHead_Port" : "Port", @@ -102,6 +102,7 @@ "Device_Table_info" : "Showing _START_ to _END_ of _TOTAL_ entries", "Device_Table_nav_next" : "Next", "Device_Table_nav_prev" : "Previous", + "Device_Table_Not_Network_Device" : "Not configured as a network device", "Presence_Title" : "Presence by Device", "Presence_Loading" : "Loading...", "Loading" : "Loading...", diff --git a/front/plugins/README.md b/front/plugins/README.md index 63c14184..879746ea 100755 --- a/front/plugins/README.md +++ b/front/plugins/README.md @@ -559,10 +559,11 @@ You can have any `"function": "my_custom_name"` custom name, however, the ones l | ------- | ----------- | | `RUN` | (required) Specifies when the service is executed. | | | Supported Options: | -| | - "disabled" - not run | +| | - "disabled" - do not run | | | - "once" - run on app start or on settings saved | | | - "schedule" - if included, then a `RUN_SCHD` setting needs to be specified to determine the schedule | | | - "always_after_scan" - run always after a scan is finished | +| | - "before_name_updates" - run before device names are updated (for name discovery plugins) | | | - "on_new_device" - run when a new device is detected | | | - "before_config_save" - run before the config is marked as saved. Useful if your plugin needs to modify the `pialert.conf` file. | | `RUN_SCHD` | (required if you include "schedule" in the above `RUN` function) Cron-like scheduling is used if the `RUN` setting is set to `schedule`. |