New Devices Columns #556 🚑

This commit is contained in:
Jokob-sk
2024-02-06 09:01:55 +11:00
parent 6b39a29838
commit 508a2d67b9
3 changed files with 55 additions and 25 deletions

View File

@@ -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 ('<b><a href="./network.php?mac='+ rowData[mapIndx(11)] +'" class="">'+ cellData +'</a></b>');
}
else
{
$(td).html (`<i class="fa-solid fa-xmark" title="${getString("Device_Table_Not_Network_Device")}"></i>`)
}
} },
// 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()
{

View File

@@ -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...",

View File

@@ -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`. |