- Added list, edit, and save functionalities for floors, locations, and racks. - Enhanced UI with search and filter options for better usability. - Implemented SVG upload for floor plans in the floors module. - Added validation for required fields in the save processes. - Improved navigation in the header to reflect new modules. - Styled forms and tables for a consistent look and feel across modules.
123 lines
3.1 KiB
PHP
123 lines
3.1 KiB
PHP
<?php
|
|
/**
|
|
* app/modules/connections/save.php
|
|
*
|
|
* Speichert / aktualisiert eine Netzwerkverbindung
|
|
* (Basis-Implementierung - kann erweitert werden)
|
|
*/
|
|
|
|
// Nur POST
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
header('Location: ?module=connections&action=list');
|
|
exit;
|
|
}
|
|
|
|
// =========================
|
|
// Daten einlesen
|
|
// =========================
|
|
$connId = (int)($_POST['id'] ?? 0);
|
|
$portAType = $_POST['port_a_type'] ?? 'device';
|
|
$portAId = (int)($_POST['port_a_id'] ?? 0);
|
|
$portBType = $_POST['port_b_type'] ?? 'device';
|
|
$portBId = (int)($_POST['port_b_id'] ?? 0);
|
|
$vlanConfig = $_POST['vlan_config'] ?? '';
|
|
$comment = trim($_POST['comment'] ?? '');
|
|
|
|
// =========================
|
|
// Validierung (einfach)
|
|
// =========================
|
|
$errors = [];
|
|
|
|
if ($portAId <= 0 || $portBId <= 0) {
|
|
$errors[] = "Beide Ports sind erforderlich";
|
|
}
|
|
|
|
if (!empty($errors)) {
|
|
$_SESSION['error'] = implode(', ', $errors);
|
|
$redirectUrl = $connId ? "?module=connections&action=edit&id=$connId" : "?module=connections&action=list";
|
|
header("Location: $redirectUrl");
|
|
exit;
|
|
}
|
|
|
|
// =========================
|
|
// In DB speichern
|
|
// =========================
|
|
$vlanJson = $vlanConfig ? json_encode(explode(',', $vlanConfig)) : null;
|
|
|
|
if ($connId > 0) {
|
|
// UPDATE
|
|
$sql->set(
|
|
"UPDATE connections SET port_a_type = ?, port_a_id = ?, port_b_type = ?, port_b_id = ?, vlan_config = ?, comment = ? WHERE id = ?",
|
|
"siisisi",
|
|
[$portAType, $portAId, $portBType, $portBId, $vlanJson, $comment, $connId]
|
|
);
|
|
} else {
|
|
// INSERT
|
|
$sql->set(
|
|
"INSERT INTO connections (port_a_type, port_a_id, port_b_type, port_b_id, vlan_config, comment) VALUES (?, ?, ?, ?, ?, ?)",
|
|
"siisis",
|
|
[$portAType, $portAId, $portBType, $portBId, $vlanJson, $comment]
|
|
);
|
|
}
|
|
|
|
$_SESSION['success'] = "Verbindung gespeichert";
|
|
|
|
// =========================
|
|
// Redirect
|
|
// =========================
|
|
header('Location: ?module=connections&action=list');
|
|
exit;
|
|
"type": "device_position" | "port_position" | "network_layout" | ...
|
|
"entity_id": 123,
|
|
"payload": { ... }
|
|
}
|
|
*/
|
|
|
|
// TODO: Pflichtfelder prüfen
|
|
// $type = $data['type'] ?? null;
|
|
// $entityId = $data['entity_id'] ?? null;
|
|
// $payload = $data['payload'] ?? null;
|
|
|
|
// =========================
|
|
// Routing nach Typ
|
|
// =========================
|
|
|
|
switch ($type ?? null) {
|
|
|
|
case 'device_position':
|
|
// TODO:
|
|
// - Gerät-ID validieren
|
|
// - SVG-Koordinaten speichern
|
|
// - ggf. Zoom / Rotation
|
|
break;
|
|
|
|
case 'port_position':
|
|
// TODO:
|
|
// - Device-Type-Port-ID
|
|
// - Koordinaten relativ zum SVG
|
|
break;
|
|
|
|
case 'network_layout':
|
|
// TODO:
|
|
// - Kontext (Standort / Rack)
|
|
// - Gerätepositionen
|
|
// - Verbindungskurven
|
|
break;
|
|
|
|
default:
|
|
http_response_code(400);
|
|
echo json_encode([
|
|
'error' => 'Unknown save type'
|
|
]);
|
|
exit;
|
|
}
|
|
|
|
// =========================
|
|
// Antwort
|
|
// =========================
|
|
|
|
// TODO: Erfolg / Fehler zurückgeben
|
|
echo json_encode([
|
|
'status' => 'ok'
|
|
]);
|