Direktverbindung fuer unverbundene Ports zum Patchfeld anbieten

closes #25
This commit is contained in:
2026-02-19 11:09:36 +01:00
parent dbe977f62c
commit 96f885efde
3 changed files with 41 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
# NEXT_STEPS
## Aktive Aufgaben (priorisiert)
- [x] [#25] bei unverbundenen ports direkt eine verbindung zu einem patchfeld anbieten und das formular vorausfuellen
- [x] [#26] patchfelder haben natürlich auf den gleichen port eine feste verdrahtung und dann ein patchkabel zum switch, bei wand buchsen muss das auch erlaubt sein
- [x] [#24] infrastruktur stockerkkarte zoomen wird die grundrisskarten overlay nicht mitgezoomt
- [x] [#23] netzwerkdosen haben nur port 1 und brauche in den auswahlen nicht mit port 1 angezeigt zu werden

View File

@@ -39,6 +39,18 @@ $portBType = $normalizePortType((string)($connection['port_b_type'] ?? 'device')
$portAId = (int)($connection['port_a_id'] ?? 0);
$portBId = (int)($connection['port_b_id'] ?? 0);
if ($connectionId <= 0) {
$requestedPortAType = $normalizePortType((string)($_GET['port_a_type'] ?? $portAType));
$requestedPortBType = $normalizePortType((string)($_GET['port_b_type'] ?? $portBType));
$requestedPortAId = (int)($_GET['port_a_id'] ?? $portAId);
$requestedPortBId = (int)($_GET['port_b_id'] ?? $portBId);
$portAType = $requestedPortAType;
$portBType = $requestedPortBType;
$portAId = $requestedPortAId > 0 ? $requestedPortAId : 0;
$portBId = $requestedPortBId > 0 ? $requestedPortBId : 0;
}
$endpointOptions = [
'device' => [],
'module' => [],

View File

@@ -79,6 +79,26 @@ foreach ($sql->get(
}
$devicePortPreviewByDevice = [];
$connectedDevicePorts = [];
foreach ($sql->get(
"SELECT port_a_type, port_a_id, port_b_type, port_b_id
FROM connections",
"",
[]
) as $row) {
$portAType = strtolower(trim((string)($row['port_a_type'] ?? '')));
$portBType = strtolower(trim((string)($row['port_b_type'] ?? '')));
$portAId = (int)($row['port_a_id'] ?? 0);
$portBId = (int)($row['port_b_id'] ?? 0);
if (($portAType === 'device' || $portAType === 'device_ports') && $portAId > 0) {
$connectedDevicePorts[$portAId] = true;
}
if (($portBType === 'device' || $portBType === 'device_ports') && $portBId > 0) {
$connectedDevicePorts[$portBId] = true;
}
}
foreach ($sql->get(
"SELECT id, device_id, name
FROM device_ports
@@ -98,7 +118,8 @@ foreach ($sql->get(
}
$devicePortPreviewByDevice[$deviceId][] = [
'id' => (int)($row['id'] ?? 0),
'name' => (string)($row['name'] ?? '')
'name' => (string)($row['name'] ?? ''),
'is_connected' => isset($connectedDevicePorts[(int)($row['id'] ?? 0)]),
];
}
@@ -658,7 +679,11 @@ foreach ($rackLinksByKey as $entry) {
overlayMeta.textContent = `Geraet: ${item.device_name} | Rack: ${item.rack_name} | Stockwerk: ${item.floor_name}`;
if (item.device_id > 0) {
overlayRackLink.innerHTML = `<a href="?module=devices&action=edit&id=${item.device_id}">Geraet bearbeiten</a>`;
overlayDeviceLink.innerHTML = `<a href="?module=connections&action=edit">Verbindung fuer Port erstellen</a>`;
if (item.port_id > 0 && !item.is_connected) {
overlayDeviceLink.innerHTML = `<a href="?module=connections&action=edit&port_a_type=device&port_a_id=${item.port_id}&port_b_type=patchpanel">Mit Patchfeld verbinden</a>`;
} else {
overlayDeviceLink.textContent = 'Port ist bereits verbunden';
}
}
if (item.port_id > 0) {
overlayActions.innerHTML = `<a class="button button-small" href="?module=devices&action=edit&id=${item.device_id}">Port im Geraet aendern</a>`;
@@ -853,6 +878,7 @@ foreach ($rackLinksByKey as $entry) {
kind: 'port',
port_id: Number(port.id || 0),
port_name: port.name || `Port ${portIndex + 1}`,
is_connected: !!port.is_connected,
device_id: entry.device_id,
device_name: entry.device_name,
rack_name: entry.rack_name,