diff --git a/front/deviceDetails.php b/front/deviceDetails.php index 8631c43c..74e9313a 100644 --- a/front/deviceDetails.php +++ b/front/deviceDetails.php @@ -263,7 +263,8 @@ if ($_REQUEST['mac'] == 'Internet') { $DevDetail_Tap_temp = "Tools"; } else { $D - + +

diff --git a/front/network.php b/front/network.php index 86b6f41b..fca75ab5 100644 --- a/front/network.php +++ b/front/network.php @@ -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', '
Online
'); + define('badge_offline', '
Offline
'); + define('circle_online', '
 
'); + define('circle_offline', '
 
'); $DBFILE = '../db/pialert.db'; $NETWORKTYPES = getNetworkTypes(); + OpenDB(); // ##################################### @@ -46,7 +51,8 @@ ' - .$node_name.' / '.$node_type. ' ' .$str_port. + .$node_name.' ' .$str_port.$node_badge. ' '; @@ -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 = '
-

'.$node_name.' (ID: '.str_replace(":", "_", $node_mac).')

+ +

'.$node_name.'

+
+ + + + + + + + + + + + + + + +
+ MAC: + ' + .$node_mac. + '
+ '.$pia_lang['Device_TableHead_Type'].' + + ' .$node_type. ' +
+ '.$pia_lang['Network_Table_State'].': + ' + .$node_badge. + '

'; - - - - $str_table = ' + $str_table = '

+ '.$pia_lang['Device_Title'].' +

@@ -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 = '
Online
'; + $port_state = badge_online; } else { - $port_state = '
Offline
'; + $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 = ''; - } elseif ($row['type'] == "Powerline") + } elseif ($row['node_type'] == "Powerline") { $port_content = ''; } elseif ($row['port'] != NULL && $row['port'] != "") @@ -167,16 +225,23 @@ $str_table_close = '
'; - // 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 = "
+

+ ".$pia_lang['Device_Title']." +

+
+ This network device (node) doesn't have any assigned devices (leaf nodes). + Go to ".$pia_lang['Device_Title'].", select a device you want to attach to this node and assign it in the Details tab by selecting it in the ".$pia_lang['DevDetail_MainInfo_Network'] ." dropdown. +
+
"; $str_table_close = ""; } $str_close_pane = '
-
-
'; +
'; // 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(); + ?>
diff --git a/front/php/templates/graph.php b/front/php/templates/graph.php index 3765820e..a2983aae 100644 --- a/front/php/templates/graph.php +++ b/front/php/templates/graph.php @@ -1,10 +1,16 @@ query('SELECT * FROM Online_History ORDER BY Scan_Date DESC LIMIT 144'); while ($row = $results->fetchArray()) { $time_raw = explode(' ', $row['Scan_Date']); diff --git a/front/php/templates/language/en_us.php b/front/php/templates/language/en_us.php index bca4bcb1..90e429c5 100644 --- a/front/php/templates/language/en_us.php +++ b/front/php/templates/language/en_us.php @@ -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';