defekter floorplan
This commit is contained in:
@@ -68,6 +68,66 @@ $connections = $sql->get(
|
||||
// =========================
|
||||
$devices = $sql->get("SELECT id, name FROM devices ORDER BY name", "", []);
|
||||
|
||||
$selectedDevice = null;
|
||||
$selectedDevicePorts = [];
|
||||
$selectedDeviceVlans = [];
|
||||
|
||||
if ($deviceId > 0) {
|
||||
$selectedDevice = $sql->single(
|
||||
"SELECT d.id, d.name, dt.name AS type_name
|
||||
FROM devices d
|
||||
LEFT JOIN device_types dt ON d.device_type_id = dt.id
|
||||
WHERE d.id = ?",
|
||||
"i",
|
||||
[$deviceId]
|
||||
);
|
||||
|
||||
if ($selectedDevice) {
|
||||
$selectedDevice['port_count'] = (int)($sql->single(
|
||||
"SELECT COUNT(*) AS cnt FROM device_ports WHERE device_id = ?",
|
||||
"i",
|
||||
[$deviceId]
|
||||
)['cnt'] ?? 0);
|
||||
|
||||
$selectedDevice['connection_count'] = (int)($sql->single(
|
||||
"SELECT COUNT(DISTINCT c.id) AS cnt
|
||||
FROM connections c
|
||||
LEFT JOIN device_ports dpt1 ON c.port_a_type = 'device' AND c.port_a_id = dpt1.id
|
||||
LEFT JOIN device_ports dpt2 ON c.port_b_type = 'device' AND c.port_b_id = dpt2.id
|
||||
WHERE dpt1.device_id = ? OR dpt2.device_id = ?",
|
||||
"ii",
|
||||
[$deviceId, $deviceId]
|
||||
)['cnt'] ?? 0);
|
||||
|
||||
$selectedDevicePorts = $sql->get(
|
||||
"SELECT name, vlan_config
|
||||
FROM device_ports
|
||||
WHERE device_id = ?
|
||||
ORDER BY id
|
||||
LIMIT 12",
|
||||
"i",
|
||||
[$deviceId]
|
||||
);
|
||||
|
||||
foreach ($selectedDevicePorts as $port) {
|
||||
if (empty($port['vlan_config'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$vlans = json_decode($port['vlan_config'], true);
|
||||
foreach ((array)$vlans as $vlan) {
|
||||
$vlan = trim((string)$vlan);
|
||||
if ($vlan !== '') {
|
||||
$selectedDeviceVlans[$vlan] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$selectedDeviceVlans = array_keys($selectedDeviceVlans);
|
||||
natcasesort($selectedDeviceVlans);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="connections-container">
|
||||
@@ -195,14 +255,31 @@ $devices = $sql->get("SELECT id, name FROM devices ORDER BY name", "", []);
|
||||
========================= -->
|
||||
|
||||
<aside class="sidebar">
|
||||
<!-- TODO: Details zum ausgewählten Gerät anzeigen -->
|
||||
<!--
|
||||
- Gerätename
|
||||
- Gerätetyp
|
||||
- Ports
|
||||
- VLANs
|
||||
- Verbindungen
|
||||
-->
|
||||
<?php if ($selectedDevice): ?>
|
||||
<h3>Ausgewähltes Gerät</h3>
|
||||
<p><strong><?php echo htmlspecialchars($selectedDevice['name']); ?></strong></p>
|
||||
<p>Typ: <?php echo htmlspecialchars($selectedDevice['type_name'] ?? '—'); ?></p>
|
||||
<p>Ports: <?php echo (int)$selectedDevice['port_count']; ?></p>
|
||||
<p>Verbindungen: <?php echo (int)$selectedDevice['connection_count']; ?></p>
|
||||
<p>
|
||||
VLANs:
|
||||
<?php if (!empty($selectedDeviceVlans)): ?>
|
||||
<?php echo htmlspecialchars(implode(', ', $selectedDeviceVlans)); ?>
|
||||
<?php else: ?>
|
||||
—
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
<?php if (!empty($selectedDevicePorts)): ?>
|
||||
<h4>Ports (max. 12)</h4>
|
||||
<ul>
|
||||
<?php foreach ($selectedDevicePorts as $port): ?>
|
||||
<li><?php echo htmlspecialchars($port['name']); ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<p><em>Bitte ein Gerät im Filter auswählen.</em></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- TODO: Verbindung bearbeiten / löschen -->
|
||||
</aside>
|
||||
|
||||
Reference in New Issue
Block a user