feat: Implement floors, locations, and racks management

- 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.
This commit is contained in:
2026-02-11 14:34:07 +01:00
parent 2f341bff9f
commit 0d3c6e1ae7
26 changed files with 3753 additions and 1045 deletions

View File

@@ -1,53 +1,72 @@
<?php
/**
* save.php
* app/modules/connections/save.php
*
* Zentrale Save-Logik für:
* - SVG-Positionen (Geräte, Ports)
* - Netzwerk-Layouts
* - Rack-/Floor-Positionen
* - Sonstige UI-Zustände
*
* Erwartet JSON per POST
* Speichert / aktualisiert eine Netzwerkverbindung
* (Basis-Implementierung - kann erweitert werden)
*/
// TODO: bootstrap laden
// require_once __DIR__ . '/bootstrap.php';
// TODO: Auth erzwingen
// requireAuth();
// =========================
// Request validieren
// =========================
// Nur POST
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
header('Location: ?module=connections&action=list');
exit;
}
// TODO: Content-Type prüfen (application/json)
// =========================
// 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'] ?? '');
// =========================
// Payload lesen
// Validierung (einfach)
// =========================
$errors = [];
$raw = file_get_contents('php://input');
if ($portAId <= 0 || $portBId <= 0) {
$errors[] = "Beide Ports sind erforderlich";
}
// TODO: Fehlerbehandlung bei leerem Body
$data = json_decode($raw, true);
// TODO: JSON-Fehler prüfen
// if (json_last_error() !== JSON_ERROR_NONE) { ... }
if (!empty($errors)) {
$_SESSION['error'] = implode(', ', $errors);
$redirectUrl = $connId ? "?module=connections&action=edit&id=$connId" : "?module=connections&action=list";
header("Location: $redirectUrl");
exit;
}
// =========================
// Basisfelder prüfen
// In DB speichern
// =========================
$vlanJson = $vlanConfig ? json_encode(explode(',', $vlanConfig)) : null;
// Erwartete Struktur (Beispiel):
/*
{
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": { ... }