@@ -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 = '
';
+ $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();
+
?>