feat: Erweiterung der Module für Geräte, Stockwerke und Racks mit grundlegenden Funktionen und Strukturen

This commit is contained in:
Troy Grunt
2026-02-06 18:47:25 +01:00
parent 3ec3ad7fa5
commit 98a3f4d5b6
8 changed files with 943 additions and 8 deletions

View File

@@ -1,2 +1,104 @@
<?php
// Gerät speichern (Rack-Position, Typ, Name)
/**
* app/devices/save.php
*
* Speichert:
* - Basisdaten (Name, Beschreibung)
* - Gerätetyp-Zuordnung
* - Standort (Floor, Rack, Rack-Position)
* - Ports (vom Device-Type übernommen)
* - SVG-Positionen
*
* POST JSON oder multipart/form-data
*/
// TODO: bootstrap laden
// require_once __DIR__ . '/../../bootstrap.php';
// TODO: Auth erzwingen
// requireAuth();
// =========================
// Request prüfen
// =========================
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
exit;
}
// =========================
// Daten aus POST / JSON
// =========================
// TODO: Prüfen, ob multipart/form-data oder JSON
// $data = json_decode(file_get_contents('php://input'), true);
// Basisfelder
// $deviceId = $data['id'] ?? null;
// $name = $data['name'] ?? '';
// $description = $data['description'] ?? '';
// $deviceTypeId = $data['device_type_id'] ?? null;
// $floorId = $data['floor_id'] ?? null;
// $rackId = $data['rack_id'] ?? null;
// $rackPosition = $data['rack_position'] ?? null;
// $svgPositions = $data['svg_positions'] ?? [];
// $portsData = $data['ports'] ?? [];
// =========================
// Validierung
// =========================
// TODO:
// - Name nicht leer
// - Device-Type existiert
// - Floor / Rack gültig
// - Ports valide
// =========================
// Bild / SVG Upload (optional)
// =========================
// TODO: $_FILES['image'] prüfen
// - Upload in /uploads/devices
// - SVG prüfen / sanitizen
// - Pfad speichern
// =========================
// Device speichern
// =========================
if (!empty($deviceId)) {
// TODO: UPDATE devices SET ...
// $rows = $sql->set("UPDATE ...", "???", [...]);
} else {
// TODO: INSERT INTO devices ...
// $deviceId = $sql->set("INSERT ...", "???", [...], true);
}
// =========================
// Ports speichern / übernehmen vom Device-Type
// =========================
// TODO:
// - $portsData iterieren
// - Positionen aus SVG übernehmen
// - port_type_id, name, VLAN, Modus speichern
// =========================
// SVG-Positionen speichern
// =========================
// TODO:
// - device_positions Tabelle?
// - x/y Koordinaten
// - Rotation / Zoom (optional)
// =========================
// Antwort
// =========================
echo json_encode([
'status' => 'ok',
'id' => $deviceId
]);