0) { $where[] = "(e1.owner_device_id = ? OR e2.owner_device_id = ?)"; $types .= 'ii'; $params[] = $deviceId; $params[] = $deviceId; } $whereSql = $where ? 'WHERE ' . implode(' AND ', $where) : ''; $connections = $sql->get( "SELECT c.id, c.port_a_type, c.port_a_id, c.port_b_type, c.port_b_id, e1.owner_name AS endpoint_a_name, e2.owner_name AS endpoint_b_name, e1.port_name AS port_a_name, e2.port_name AS port_b_name, c.vlan_config, c.comment FROM connections c LEFT JOIN ($endpointUnionSql) e1 ON c.port_a_id = e1.endpoint_id AND ( c.port_a_type = e1.endpoint_type OR (c.port_a_type = 'device_ports' AND e1.endpoint_type = 'device') OR (c.port_a_type = 'module_ports' AND e1.endpoint_type = 'module') OR (c.port_a_type = 'network_outlet_ports' AND e1.endpoint_type = 'outlet') OR (c.port_a_type = 'floor_patchpanel_ports' AND e1.endpoint_type = 'floor_patchpanel') OR (c.port_a_type = 'patchpanel' AND e1.endpoint_type = 'floor_patchpanel') ) LEFT JOIN ($endpointUnionSql) e2 ON c.port_b_id = e2.endpoint_id AND ( c.port_b_type = e2.endpoint_type OR (c.port_b_type = 'device_ports' AND e2.endpoint_type = 'device') OR (c.port_b_type = 'module_ports' AND e2.endpoint_type = 'module') OR (c.port_b_type = 'network_outlet_ports' AND e2.endpoint_type = 'outlet') OR (c.port_b_type = 'floor_patchpanel_ports' AND e2.endpoint_type = 'floor_patchpanel') OR (c.port_b_type = 'patchpanel' AND e2.endpoint_type = 'floor_patchpanel') ) $whereSql ORDER BY e1.owner_name, e2.owner_name", $types, $params ); $devices = $sql->get('SELECT id, name FROM devices ORDER BY name', '', []); $selectedConnection = null; if ($selectedConnectionId > 0) { foreach ((array)$connections as $entry) { if ((int)($entry['id'] ?? 0) === $selectedConnectionId) { $selectedConnection = $entry; break; } } } if ($selectedConnection === null && !empty($connections)) { $selectedConnection = $connections[0]; $selectedConnectionId = (int)($selectedConnection['id'] ?? 0); } $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 ( SELECT dp.id FROM device_ports dp WHERE dp.device_id = ? UNION ALL SELECT DISTINCT mp.id FROM module_ports mp JOIN modules m ON m.id = mp.module_id JOIN device_port_modules dpm ON dpm.module_id = m.id JOIN device_ports dp ON dp.id = dpm.device_port_id WHERE dp.device_id = ? ) p", 'ii', [$deviceId, $deviceId] )['cnt'] ?? 0); $selectedDevice['connection_count'] = (int)($sql->single( "SELECT COUNT(DISTINCT c.id) AS cnt FROM connections c LEFT JOIN ($endpointUnionSql) e1 ON c.port_a_id = e1.endpoint_id AND ( c.port_a_type = e1.endpoint_type OR (c.port_a_type = 'device_ports' AND e1.endpoint_type = 'device') OR (c.port_a_type = 'module_ports' AND e1.endpoint_type = 'module') OR (c.port_a_type = 'network_outlet_ports' AND e1.endpoint_type = 'outlet') OR (c.port_a_type = 'floor_patchpanel_ports' AND e1.endpoint_type = 'floor_patchpanel') OR (c.port_a_type = 'patchpanel' AND e1.endpoint_type = 'floor_patchpanel') ) LEFT JOIN ($endpointUnionSql) e2 ON c.port_b_id = e2.endpoint_id AND ( c.port_b_type = e2.endpoint_type OR (c.port_b_type = 'device_ports' AND e2.endpoint_type = 'device') OR (c.port_b_type = 'module_ports' AND e2.endpoint_type = 'module') OR (c.port_b_type = 'network_outlet_ports' AND e2.endpoint_type = 'outlet') OR (c.port_b_type = 'floor_patchpanel_ports' AND e2.endpoint_type = 'floor_patchpanel') OR (c.port_b_type = 'patchpanel' AND e2.endpoint_type = 'floor_patchpanel') ) WHERE e1.owner_device_id = ? OR e2.owner_device_id = ?", 'ii', [$deviceId, $deviceId] )['cnt'] ?? 0); $selectedDevicePorts = $sql->get( "SELECT name, vlan_config FROM ( SELECT dp.name, dp.vlan_config, dp.id AS sort_id FROM device_ports dp WHERE dp.device_id = ? UNION ALL SELECT DISTINCT CONCAT(m.name, ' / ', mp.name) AS name, NULL AS vlan_config, (1000000 + mp.id) AS sort_id FROM module_ports mp JOIN modules m ON m.id = mp.module_id JOIN device_port_modules dpm ON dpm.module_id = m.id JOIN device_ports dp ON dp.id = dpm.device_port_id WHERE dp.device_id = ? ) p ORDER BY sort_id LIMIT 12", 'ii', [$deviceId, $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); } } $buildListUrl = static function (array $extra = []) use ($search, $deviceId): string { $query = ['module' => 'connections', 'action' => 'list']; if ($search !== '') { $query['search'] = $search; } if ($deviceId > 0) { $query['device_id'] = $deviceId; } foreach ($extra as $key => $value) { if ($value === null || $value === '') { continue; } $query[$key] = $value; } return '?' . http_build_query($query); }; ?>

Netzwerkverbindungen

Reset + Neue Verbindung
Von (Geraet -> Port) Nach (Geraet -> Port) VLANs Beschreibung Status Aktionen


Warnung OK Details Bearbeiten Von/Nach tauschen

Keine Verbindungen gefunden.

Erste Verbindung anlegen