div TODOs

This commit is contained in:
2026-02-16 13:56:01 +01:00
parent 12141485ae
commit 510a248edb
36 changed files with 1500 additions and 1533 deletions

View File

@@ -0,0 +1,36 @@
<?php
/**
* app/modules/racks/delete.php
*/
header('Content-Type: application/json; charset=utf-8');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
echo json_encode(['success' => false, 'message' => 'Methode nicht erlaubt']);
exit;
}
$id = (int)($_POST['id'] ?? $_GET['id'] ?? 0);
if ($id <= 0) {
http_response_code(400);
echo json_encode(['success' => false, 'message' => 'ID fehlt']);
exit;
}
$exists = $sql->single("SELECT id FROM racks WHERE id = ?", "i", [$id]);
if (!$exists) {
http_response_code(404);
echo json_encode(['success' => false, 'message' => 'Rack nicht gefunden']);
exit;
}
$rows = $sql->set("DELETE FROM racks WHERE id = ?", "i", [$id]);
if ($rows === false) {
http_response_code(500);
echo json_encode(['success' => false, 'message' => 'Loeschen fehlgeschlagen']);
exit;
}
echo json_encode(['success' => true, 'message' => 'Rack geloescht']);

View File

@@ -1,16 +1,8 @@
<?php
/**
* app/modules/racks/edit.php
*
* Rack anlegen oder bearbeiten
* - Name, Beschreibung
* - Zugehöriges Stockwerk (Floor)
* - Höhe in Höheneinheiten (HE)
*/
// =========================
// Kontext bestimmen
// =========================
$rackId = (int)($_GET['id'] ?? 0);
$rack = null;
@@ -23,83 +15,61 @@ if ($rackId > 0) {
}
$isEdit = !empty($rack);
$pageTitle = $isEdit ? "Rack bearbeiten: " . htmlspecialchars($rack['name']) : "Neues Rack";
// =========================
// Floors laden
// =========================
$floors = $sql->get("SELECT id, name FROM floors ORDER BY name", "", []);
$pageTitle = $isEdit ? 'Rack bearbeiten: ' . htmlspecialchars((string)$rack['name']) : 'Neues Rack';
$floors = $sql->get("SELECT id, name FROM floors ORDER BY name", '', []);
?>
<div class="rack-edit">
<h1><?php echo $pageTitle; ?></h1>
<form method="post" action="?module=racks&action=save" class="edit-form">
<?php if ($isEdit): ?>
<input type="hidden" name="id" value="<?php echo $rackId; ?>">
<input type="hidden" name="id" value="<?php echo (int)$rackId; ?>">
<?php endif; ?>
<!-- =========================
Basisdaten
========================= -->
<fieldset>
<legend>Allgemein</legend>
<div class="form-group">
<label for="name">Name <span class="required">*</span></label>
<input type="text" id="name" name="name" required
value="<?php echo htmlspecialchars($rack['name'] ?? ''); ?>"
placeholder="z.B. Rack A1">
<input type="text" id="name" name="name" required value="<?php echo htmlspecialchars((string)($rack['name'] ?? '')); ?>" placeholder="z.B. Rack A1">
</div>
<div class="form-group">
<label for="comment">Beschreibung</label>
<textarea id="comment" name="comment" rows="3"
placeholder="z.B. Standort, Besonderheiten"><?php echo htmlspecialchars($rack['comment'] ?? ''); ?></textarea>
<textarea id="comment" name="comment" rows="3" placeholder="z.B. Standort, Besonderheiten"><?php echo htmlspecialchars((string)($rack['comment'] ?? '')); ?></textarea>
</div>
</fieldset>
<!-- =========================
Standort & Höhe
========================= -->
<fieldset>
<legend>Standort & Größe</legend>
<legend>Standort und Groesse</legend>
<div class="form-group">
<label for="floor_id">Stockwerk <span class="required">*</span></label>
<select id="floor_id" name="floor_id" required>
<option value="">- Wählen -</option>
<option value="">- Waehlen -</option>
<?php foreach ($floors as $floor): ?>
<option value="<?php echo $floor['id']; ?>"
<?php echo ($rack['floor_id'] ?? 0) == $floor['id'] ? 'selected' : ''; ?>>
<?php echo htmlspecialchars($floor['name']); ?>
</option>
<option value="<?php echo (int)$floor['id']; ?>" <?php echo ((int)($rack['floor_id'] ?? 0) === (int)$floor['id']) ? 'selected' : ''; ?>>
<?php echo htmlspecialchars((string)$floor['name']); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="height_he">Höhe in Höheneinheiten (HE) <span class="required">*</span></label>
<input type="number" id="height_he" name="height_he" required min="1" max="100"
value="<?php echo htmlspecialchars($rack['height_he'] ?? '42'); ?>"
placeholder="z.B. 42">
<small>Standard: 42 HE (ca. 2 Meter)</small>
<label for="height_he">Hoehe in Hoeheneinheiten (HE) <span class="required">*</span></label>
<input type="number" id="height_he" name="height_he" required min="1" max="100" value="<?php echo (int)($rack['height_he'] ?? 42); ?>">
<small>Standard: 42 HE</small>
</div>
</fieldset>
<!-- =========================
Aktionen
========================= -->
<fieldset class="form-actions">
<button type="submit" class="button button-primary">Speichern</button>
<a href="?module=racks&action=list" class="button">Abbrechen</a>
<?php if ($isEdit): ?>
<a href="#" class="button button-danger" onclick="confirmDelete(<?php echo $rackId; ?>)">Löschen</a>
<a href="#" class="button button-danger" onclick="return confirmDelete(<?php echo (int)$rackId; ?>)">Loeschen</a>
<?php endif; ?>
</fieldset>
</form>
</div>
@@ -197,60 +167,25 @@ $floors = $sql->get("SELECT id, name FROM floors ORDER BY name", "", []);
<script>
function confirmDelete(id) {
if (confirm('Dieses Rack wirklich löschen? Alle Geräte werden aus dem Rack entfernt.')) {
// TODO: AJAX-Delete implementieren
alert('Löschen noch nicht implementiert');
if (!confirm('Dieses Rack wirklich loeschen? Alle Geraete werden aus dem Rack entfernt.')) {
return false;
}
fetch('?module=racks&action=delete', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
body: 'id=' + encodeURIComponent(id)
})
.then((response) => response.json())
.then((data) => {
if (data && data.success) {
window.location.href = '?module=racks&action=list';
return;
}
alert((data && data.message) ? data.message : 'Loeschen fehlgeschlagen');
})
.catch(() => alert('Loeschen fehlgeschlagen'));
return false;
}
</script>
<!-- =========================
Rack-SVG / Gerätepositionen
========================= -->
<fieldset>
<legend>Rack-Layout</legend>
<div class="svg-editor-container">
<svg
id="rack-svg"
viewBox="0 0 200 1000"
width="100%"
height="600"
>
<!-- TODO: Rack-SVG laden -->
</svg>
</div>
<p class="hint">
Geräte per Drag & Drop im Rack positionieren.
</p>
</fieldset>
<!-- =========================
Aktionen
========================= -->
<fieldset>
<button type="submit">Speichern</button>
<button type="button" onclick="history.back()">Abbrechen</button>
<!-- TODO: Löschen, falls edit -->
</fieldset>
</form>
<!-- =========================
JS-Konfiguration
========================= -->
<script>
/**
* Konfiguration für Rack-SVG-Editor
*/
// TODO: Rack-ID aus PHP setzen
// window.RACK_ID = <?= (int)$rackId ?>;
// TODO: Gerätepositionen an JS übergeben
// window.RACK_DEVICES = <?= json_encode($rackDevices ?? []) ?>;
</script>

View File

@@ -2,44 +2,30 @@
/**
* app/modules/racks/list.php
*
* Übersicht aller Racks
* - Anzeigen, Bearbeiten, Löschen
* - Zugehöriges Stockwerk anzeigen
* - Gerätecount
* Uebersicht aller Racks.
*/
// =========================
// Filter einlesen
// =========================
$search = trim($_GET['search'] ?? '');
$search = trim((string)($_GET['search'] ?? ''));
$floorId = (int)($_GET['floor_id'] ?? 0);
//TODO racks beim editieren auf der stockwerkkarte platzieren und verschieben können
// =========================
// WHERE-Clause bauen
// =========================
$where = [];
$types = '';
$params = [];
if ($search !== '') {
$where[] = "r.name LIKE ?";
$types .= "s";
$where[] = 'r.name LIKE ?';
$types .= 's';
$params[] = "%$search%";
}
if ($floorId > 0) {
$where[] = "r.floor_id = ?";
$types .= "i";
$where[] = 'r.floor_id = ?';
$types .= 'i';
$params[] = $floorId;
}
$whereSql = $where ? "WHERE " . implode(" AND ", $where) : "";
$whereSql = $where ? ('WHERE ' . implode(' AND ', $where)) : '';
// =========================
// Racks laden
// =========================
$racks = $sql->get(
"SELECT r.*, f.name AS floor_name, COUNT(d.id) AS device_count
FROM racks r
@@ -52,212 +38,111 @@ $racks = $sql->get(
$params
);
// =========================
// Filter-Daten laden
// =========================
$floors = $sql->get("SELECT id, name FROM floors ORDER BY name", "", []);
$floors = $sql->get('SELECT id, name FROM floors ORDER BY name', '', []);
?>
<div class="racks-container">
<h1>Racks</h1>
<!-- =========================
Toolbar
========================= -->
<div class="filter-form">
<form method="GET" style="display: flex; gap: 10px; flex-wrap: wrap; align-items: center;">
<form method="GET" style="display:flex;gap:10px;flex-wrap:wrap;align-items:center;">
<input type="hidden" name="module" value="racks">
<input type="hidden" name="action" value="list">
<input type="text" name="search" placeholder="Suche nach Name…"
value="<?php echo htmlspecialchars($search); ?>" class="search-input">
<input type="text" name="search" placeholder="Suche nach Name..." value="<?php echo htmlspecialchars($search); ?>" class="search-input">
<select name="floor_id">
<option value="">- Alle Stockwerke -</option>
<?php foreach ($floors as $floor): ?>
<option value="<?php echo $floor['id']; ?>"
<?php echo $floor['id'] === $floorId ? 'selected' : ''; ?>>
<?php echo htmlspecialchars($floor['name']); ?>
</option>
<option value="<?php echo (int)$floor['id']; ?>" <?php echo ((int)$floor['id'] === $floorId) ? 'selected' : ''; ?>>
<?php echo htmlspecialchars((string)$floor['name']); ?>
</option>
<?php endforeach; ?>
</select>
<button type="submit" class="button">Filter</button>
<a href="?module=racks&action=list" class="button">Reset</a>
<a href="?module=racks&action=edit" class="button button-primary" style="margin-left: auto;">+ Neues Rack</a>
<a href="?module=racks&action=edit" class="button button-primary" style="margin-left:auto;">+ Neues Rack</a>
</form>
</div>
<!-- =========================
Racks-Tabelle
========================= -->
<?php if (!empty($racks)): ?>
<table class="rack-list">
<thead>
<tr>
<th>Name</th>
<th>Stockwerk</th>
<th>Höhe (HE)</th>
<th>Geräte</th>
<th>Beschreibung</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
<?php foreach ($racks as $rack): ?>
<tr>
<td>
<strong><?php echo htmlspecialchars($rack['name']); ?></strong>
</td>
<td>
<?php echo htmlspecialchars($rack['floor_name'] ?? '—'); ?>
</td>
<td>
<?php echo $rack['height_he']; ?> HE
</td>
<td>
<?php echo $rack['device_count']; ?>
</td>
<td>
<small><?php echo htmlspecialchars($rack['comment'] ?? ''); ?></small>
</td>
<td class="actions">
<a href="?module=racks&action=edit&id=<?php echo $rack['id']; ?>" class="button button-small">Bearbeiten</a>
<a href="#" class="button button-small button-danger" onclick="confirmDelete(<?php echo $rack['id']; ?>)">Löschen</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<table class="rack-list">
<thead>
<tr>
<th>Name</th>
<th>Stockwerk</th>
<th>Hoehe (HE)</th>
<th>Geraete</th>
<th>Beschreibung</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
<?php foreach ($racks as $rack): ?>
<tr>
<td><strong><?php echo htmlspecialchars((string)$rack['name']); ?></strong></td>
<td><?php echo htmlspecialchars((string)($rack['floor_name'] ?? '-')); ?></td>
<td><?php echo (int)$rack['height_he']; ?> HE</td>
<td><?php echo (int)$rack['device_count']; ?></td>
<td><small><?php echo htmlspecialchars((string)($rack['comment'] ?? '')); ?></small></td>
<td class="actions">
<a href="?module=racks&action=edit&id=<?php echo (int)$rack['id']; ?>" class="button button-small">Bearbeiten</a>
<a href="#" class="button button-small button-danger" onclick="return confirmDelete(<?php echo (int)$rack['id']; ?>)">Loeschen</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<div class="empty-state">
<p>Keine Racks gefunden.</p>
<p>
<a href="?module=racks&action=edit" class="button button-primary">
Erstes Rack anlegen
</a>
</p>
</div>
<div class="empty-state">
<p>Keine Racks gefunden.</p>
<p><a href="?module=racks&action=edit" class="button button-primary">Erstes Rack anlegen</a></p>
</div>
<?php endif; ?>
</div>
<style>
.racks-container {
padding: 20px;
max-width: 1000px;
margin: 0 auto;
}
.filter-form {
margin: 20px 0;
}
.filter-form form {
display: flex;
gap: 10px;
flex-wrap: wrap;
align-items: center;
}
.filter-form input,
.filter-form select {
padding: 8px 12px;
border: 1px solid #ddd;
border-radius: 4px;
}
.search-input {
flex: 1;
min-width: 250px;
}
.rack-list {
width: 100%;
border-collapse: collapse;
margin: 15px 0;
}
.rack-list th {
background: #f5f5f5;
padding: 12px;
text-align: left;
border-bottom: 2px solid #ddd;
font-weight: bold;
}
.rack-list td {
padding: 12px;
border-bottom: 1px solid #ddd;
}
.rack-list tr:hover {
background: #f9f9f9;
}
.actions {
white-space: nowrap;
}
.button {
display: inline-block;
padding: 8px 12px;
background: #007bff;
color: white;
text-decoration: none;
border-radius: 4px;
border: none;
cursor: pointer;
font-size: 0.9em;
}
.button:hover {
background: #0056b3;
}
.button-primary {
background: #28a745;
}
.button-primary:hover {
background: #218838;
}
.button-small {
padding: 4px 8px;
font-size: 0.85em;
}
.button-danger {
background: #dc3545;
}
.button-danger:hover {
background: #c82333;
}
.empty-state {
text-align: center;
padding: 40px 20px;
background: #f9f9f9;
border: 1px solid #eee;
border-radius: 8px;
}
.racks-container { padding: 20px; max-width: 1000px; margin: 0 auto; }
.filter-form { margin: 20px 0; }
.filter-form input, .filter-form select { padding: 8px 12px; border: 1px solid #ddd; border-radius: 4px; }
.search-input { flex: 1; min-width: 250px; }
.rack-list { width: 100%; border-collapse: collapse; margin: 15px 0; }
.rack-list th { background: #f5f5f5; padding: 12px; text-align: left; border-bottom: 2px solid #ddd; font-weight: bold; }
.rack-list td { padding: 12px; border-bottom: 1px solid #ddd; }
.rack-list tr:hover { background: #f9f9f9; }
.actions { white-space: nowrap; }
.button { display: inline-block; padding: 8px 12px; background: #007bff; color: #fff; text-decoration: none; border-radius: 4px; border: none; cursor: pointer; font-size: 0.9em; }
.button:hover { background: #0056b3; }
.button-primary { background: #28a745; }
.button-primary:hover { background: #218838; }
.button-small { padding: 4px 8px; font-size: 0.85em; }
.button-danger { background: #dc3545; }
.button-danger:hover { background: #c82333; }
.empty-state { text-align: center; padding: 40px 20px; background: #f9f9f9; border: 1px solid #eee; border-radius: 8px; }
</style>
<script>
function confirmDelete(id) {
if (confirm('Dieses Rack wirklich löschen?')) {
// TODO: AJAX-Delete implementieren
alert('Löschen noch nicht implementiert');
if (!confirm('Dieses Rack wirklich loeschen?')) {
return false;
}
fetch('?module=racks&action=delete', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
body: 'id=' + encodeURIComponent(id)
})
.then((res) => res.json())
.then((data) => {
if (data && data.success) {
window.location.reload();
return;
}
alert((data && data.message) ? data.message : 'Loeschen fehlgeschlagen');
})
.catch(() => alert('Loeschen fehlgeschlagen'));
return false;
}
</script>
</div>
<?php /* endif; */ ?>