diff --git a/NEXT.md b/NEXT.md
index 8c64061..ee3d1ff 100644
--- a/NEXT.md
+++ b/NEXT.md
@@ -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
diff --git a/app/modules/connections/edit.php b/app/modules/connections/edit.php
index 84a14a3..294dcf6 100644
--- a/app/modules/connections/edit.php
+++ b/app/modules/connections/edit.php
@@ -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' => [],
diff --git a/app/modules/dashboard/list.php b/app/modules/dashboard/list.php
index 525f72f..52935d5 100644
--- a/app/modules/dashboard/list.php
+++ b/app/modules/dashboard/list.php
@@ -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 = `Geraet bearbeiten`;
- overlayDeviceLink.innerHTML = `Verbindung fuer Port erstellen`;
+ if (item.port_id > 0 && !item.is_connected) {
+ overlayDeviceLink.innerHTML = `Mit Patchfeld verbinden`;
+ } else {
+ overlayDeviceLink.textContent = 'Port ist bereits verbunden';
+ }
}
if (item.port_id > 0) {
overlayActions.innerHTML = `Port im Geraet aendern`;
@@ -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,