mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-06 17:15:38 -08:00
network and other small enhancements
This commit is contained in:
@@ -263,7 +263,8 @@ if ($_REQUEST['mac'] == 'Internet') { $DevDetail_Tap_temp = "Tools"; } else { $D
|
||||
<textarea class="form-control" rows="3" id="txtComments"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Network -->
|
||||
<h4 class="bottom-border-aqua"><?php echo $pia_lang['DevDetail_MainInfo_Network_Title'];?></h4>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-6 control-label"><?php echo $pia_lang['DevDetail_MainInfo_Network'];?></label>
|
||||
<div class="col-sm-6">
|
||||
|
||||
@@ -10,11 +10,16 @@
|
||||
require 'php/server/db.php';
|
||||
require 'php/server/util.php';
|
||||
|
||||
global $pia_lang;
|
||||
// online / offline badges HTML snippets
|
||||
define('badge_online', '<div class="badge bg-green text-white" style="width: 60px;">Online</div>');
|
||||
define('badge_offline', '<div class="badge bg-red text-white" style="width: 60px;">Offline</div>');
|
||||
define('circle_online', '<div class="badge bg-green text-white" style="width: 10px; height: 10px; padding:2px; margin-top: -25px;"> </div>');
|
||||
define('circle_offline', '<div class="badge bg-red text-white" style="width: 10px; height: 10px; padding:2px; margin-top: -25px;"> </div>');
|
||||
|
||||
|
||||
$DBFILE = '../db/pialert.db';
|
||||
$NETWORKTYPES = getNetworkTypes();
|
||||
|
||||
OpenDB();
|
||||
|
||||
// #####################################
|
||||
@@ -46,7 +51,8 @@
|
||||
<?php
|
||||
|
||||
// Create top-level node (network devices) tabs
|
||||
function createDeviceTabs($node_mac, $node_name, $node_type, $node_ports_count, $activetab) {
|
||||
function createDeviceTabs($node_mac, $node_name, $node_status, $node_type, $node_ports_count, $activetab) {
|
||||
global $pia_lang; //language strings
|
||||
|
||||
// prepare string with port number in brackets if available
|
||||
$str_port = "";
|
||||
@@ -54,11 +60,20 @@
|
||||
$str_port = ' ('.$node_ports_count.')';
|
||||
}
|
||||
|
||||
// online/offline status circle (red/green)
|
||||
$node_badge = "";
|
||||
if($node_status == 1) // 1 means online, 0 offline
|
||||
{
|
||||
$node_badge = circle_online;
|
||||
} else
|
||||
{
|
||||
$node_badge = circle_offline;
|
||||
}
|
||||
|
||||
|
||||
$str_tab_header = '<li class="'.$activetab.'">
|
||||
<a href="#'.str_replace(":", "_", $node_mac).'" data-toggle="tab">'
|
||||
.$node_name.' / '.$node_type. ' ' .$str_port.
|
||||
.$node_name.' ' .$str_port.$node_badge.
|
||||
'</a>
|
||||
</li>';
|
||||
|
||||
@@ -66,16 +81,58 @@
|
||||
|
||||
}
|
||||
|
||||
function createPane($node_mac, $node_name, $node_type, $node_ports_count, $activetab){
|
||||
// Create pane content (displayed inside of the tabs)
|
||||
function createPane($node_mac, $node_name, $node_status, $node_type, $node_ports_count, $activetab){
|
||||
global $pia_lang; //language strings
|
||||
|
||||
// online/offline status circle (red/green)
|
||||
$node_badge = "";
|
||||
if($node_status == 1) // 1 means online, 0 offline
|
||||
{
|
||||
$node_badge = badge_online;
|
||||
} else
|
||||
{
|
||||
$node_badge = badge_offline;
|
||||
}
|
||||
|
||||
$str_tab_pane = '<div class="tab-pane '.$activetab.'" id="'.str_replace(":", "_", $node_mac).'">
|
||||
<h4>'.$node_name.' (ID: '.str_replace(":", "_", $node_mac).')</h4>
|
||||
<a href="./deviceDetails.php?mac='.$node_mac.'">
|
||||
<h4>'.$node_name.'</h4>
|
||||
</a>
|
||||
<table class="table table-striped" style="width:200px;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<b>MAC:</b>
|
||||
</td>
|
||||
<td>'
|
||||
.$node_mac.
|
||||
'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<b>'.$pia_lang['Device_TableHead_Type'].'</b>
|
||||
</td>
|
||||
<td>
|
||||
' .$node_type. '
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<b>'.$pia_lang['Network_Table_State'].':</b>
|
||||
</td>
|
||||
<td> '
|
||||
.$node_badge.
|
||||
'</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<div class="box-body no-padding">';
|
||||
|
||||
|
||||
|
||||
|
||||
$str_table = '
|
||||
$str_table = ' <h4>
|
||||
'.$pia_lang['Device_Title'].'
|
||||
</h4>
|
||||
<table class="table table-striped">
|
||||
<tbody>
|
||||
<tr>
|
||||
@@ -97,8 +154,9 @@
|
||||
dev_PresentLastScan as online,
|
||||
dev_Name as name,
|
||||
dev_DeviceType as type,
|
||||
dev_LastIP as last_ip
|
||||
FROM "Devices" WHERE "dev_Network_Node_MAC" = "'.$node_mac.'"';
|
||||
dev_LastIP as last_ip,
|
||||
(select dev_DeviceType from Devices a where dev_MAC = "'.$node_mac.'") as node_type
|
||||
FROM Devices WHERE dev_Network_Node_MAC = "'.$node_mac.'" order by port asc';
|
||||
|
||||
global $db;
|
||||
$func_result = $db->query($func_sql);
|
||||
@@ -112,7 +170,8 @@
|
||||
'online' => $row['online'],
|
||||
'name' => $row['name'],
|
||||
'type' => $row['type'],
|
||||
'last_ip' => $row['last_ip']);
|
||||
'last_ip' => $row['last_ip'],
|
||||
'node_type' => $row['node_type']);
|
||||
}
|
||||
|
||||
// Control no rows
|
||||
@@ -125,18 +184,17 @@
|
||||
foreach ($tableData as $row) {
|
||||
|
||||
if ($row['online'] == 1) {
|
||||
$port_state = '<div class="badge bg-green text-white" style="width: 60px;">Online</div>';
|
||||
$port_state = badge_online;
|
||||
} else {
|
||||
$port_state = '<div class="badge bg-red text-white" style="width: 60px;">Offline</div>';
|
||||
$port_state = badge_offline;
|
||||
}
|
||||
|
||||
// BUG: TODO fix icons - I'll need to fix the SQL query to add the type of the node on line 95
|
||||
|
||||
// prepare HTML for the port table column cell
|
||||
$port_content = "N/A";
|
||||
|
||||
if ($row['type'] == "WLAN" || $row['type'] == "AP" ) {
|
||||
if ($row['node_type'] == "WLAN" || $row['node_type'] == "AP" ) {
|
||||
$port_content = '<i class="fa fa-wifi"></i>';
|
||||
} elseif ($row['type'] == "Powerline")
|
||||
} elseif ($row['node_type'] == "Powerline")
|
||||
{
|
||||
$port_content = '<i class="fa fa-flash"></i>';
|
||||
} elseif ($row['port'] != NULL && $row['port'] != "")
|
||||
@@ -167,16 +225,23 @@
|
||||
$str_table_close = '</tbody>
|
||||
</table>';
|
||||
|
||||
// no connected device - don't render table
|
||||
// no connected device - don't render table, just dispaly some info
|
||||
if($str_table_rows == "")
|
||||
{
|
||||
$str_table = "";
|
||||
$str_table = "<div>
|
||||
<h4>
|
||||
".$pia_lang['Device_Title']."
|
||||
</h4>
|
||||
<div>
|
||||
This network device (node) doesn't have any assigned devices (leaf nodes).
|
||||
Go to <a href='./devices.php'><b>".$pia_lang['Device_Title']."</b></a>, select a device you want to attach to this node and assign it in the <b>Details</b> tab by selecting it in the <b>".$pia_lang['DevDetail_MainInfo_Network'] ."</b> dropdown.
|
||||
</div>
|
||||
</div>";
|
||||
$str_table_close = "";
|
||||
}
|
||||
|
||||
$str_close_pane = '</div>
|
||||
</div>
|
||||
<div class="aaaaaaa"></div>';
|
||||
</div>';
|
||||
|
||||
// write the HTML
|
||||
echo ''.$str_tab_header.
|
||||
@@ -197,23 +262,24 @@
|
||||
// \
|
||||
// PC (leaf)
|
||||
|
||||
$sql = "SELECT node_name, node_mac, node_type, node_ports_count
|
||||
FROM
|
||||
(
|
||||
SELECT a.dev_Name as node_name,
|
||||
a.dev_MAC as node_mac,
|
||||
a.dev_DeviceType as node_type
|
||||
FROM Devices a
|
||||
WHERE a.dev_DeviceType in ('AP', 'Gateway', 'Powerline', 'Switch', 'WLAN', 'PLC', 'Router','USB LAN Adapter', 'USB WIFI Adapter', 'Internet')
|
||||
) t1
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT b.dev_Network_Node_MAC as node_mac_2,
|
||||
count() as node_ports_count
|
||||
FROM Devices b
|
||||
WHERE b.dev_Network_Node_MAC NOT NULL group by b.dev_Network_Node_MAC
|
||||
) t2
|
||||
ON (t1.node_mac = t2.node_mac_2);
|
||||
$sql = "SELECT node_name, node_mac, online, node_type, node_ports_count
|
||||
FROM
|
||||
(
|
||||
SELECT a.dev_Name as node_name,
|
||||
a.dev_MAC as node_mac,
|
||||
a.dev_PresentLastScan as online,
|
||||
a.dev_DeviceType as node_type
|
||||
FROM Devices a
|
||||
WHERE a.dev_DeviceType in ('AP', 'Gateway', 'Powerline', 'Switch', 'WLAN', 'PLC', 'Router','USB LAN Adapter', 'USB WIFI Adapter', 'Internet')
|
||||
) t1
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT b.dev_Network_Node_MAC as node_mac_2,
|
||||
count() as node_ports_count
|
||||
FROM Devices b
|
||||
WHERE b.dev_Network_Node_MAC NOT NULL group by b.dev_Network_Node_MAC
|
||||
) t2
|
||||
ON (t1.node_mac = t2.node_mac_2);
|
||||
";
|
||||
|
||||
$result = $db->query($sql);
|
||||
@@ -224,6 +290,7 @@
|
||||
// Push row data
|
||||
$tableData[] = array( 'node_mac' => $row['node_mac'],
|
||||
'node_name' => $row['node_name'],
|
||||
'online' => $row['online'],
|
||||
'node_type' => $row['node_type'],
|
||||
'node_ports_count' => $row['node_ports_count']);
|
||||
}
|
||||
@@ -238,8 +305,9 @@
|
||||
|
||||
$activetab='active';
|
||||
foreach ($tableData as $row) {
|
||||
createDeviceTabs($row['node_mac'],
|
||||
createDeviceTabs( $row['node_mac'],
|
||||
$row['node_name'],
|
||||
$row['online'],
|
||||
$row['node_type'],
|
||||
$row['node_ports_count'],
|
||||
$activetab);
|
||||
@@ -253,16 +321,18 @@
|
||||
|
||||
foreach ($tableData as $row) {
|
||||
createPane($row['node_mac'],
|
||||
$row['node_name'],
|
||||
$row['node_name'],
|
||||
$row['online'],
|
||||
$row['node_type'],
|
||||
$row['node_ports_count'],
|
||||
$activetab);
|
||||
|
||||
$activetab = ""; // reset active tab indicator, only the first tab is active
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
?>
|
||||
<!-- /.tab-pane -->
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
<?php
|
||||
|
||||
require 'php/server/db.php';
|
||||
$DBFILE = '../db/pialert.db';
|
||||
OpenDB();
|
||||
|
||||
$Pia_Graph_Device_Time = array();
|
||||
$Pia_Graph_Device_All = array();
|
||||
$Pia_Graph_Device_Online = array();
|
||||
$Pia_Graph_Device_Down = array();
|
||||
$Pia_Graph_Device_Arch = array();
|
||||
$db = new SQLite3('../db/pialert.db');
|
||||
|
||||
//$db = new SQLite3('../db/pialert.db');
|
||||
$results = $db->query('SELECT * FROM Online_History ORDER BY Scan_Date DESC LIMIT 144');
|
||||
while ($row = $results->fetchArray()) {
|
||||
$time_raw = explode(' ', $row['Scan_Date']);
|
||||
|
||||
@@ -133,6 +133,7 @@ $pia_lang['DevDetail_MainInfo_Favorite'] = 'Favorite';
|
||||
$pia_lang['DevDetail_MainInfo_Group'] = 'Group';
|
||||
$pia_lang['DevDetail_MainInfo_Location'] = 'Location';
|
||||
$pia_lang['DevDetail_MainInfo_Comments'] = 'Comments';
|
||||
$pia_lang['DevDetail_MainInfo_Network_Title'] = 'Network';
|
||||
$pia_lang['DevDetail_MainInfo_Network'] = 'Network Node (MAC)';
|
||||
$pia_lang['DevDetail_MainInfo_Network_Port'] = 'Connected to Port';
|
||||
$pia_lang['DevDetail_SessionInfo_Title'] = 'Session Info';
|
||||
|
||||
Reference in New Issue
Block a user