feat: Erweiterung der Module für Geräte, Stockwerke und Racks mit grundlegenden Funktionen und Strukturen
This commit is contained in:
@@ -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
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user