index.php

Code Hygiene Score: 100

Keine Issues gefunden.

Versionen 2

Code

<?php ob_start(); ?>

<h1>Content-Konfiguration</h1>

<div class="stats-grid">
    <div class="stat-card">
        <span class="stat-card__value"><?= $stats['total'] ?? 0 ?></span>
        <span class="stat-card__label">Gesamt</span>
    </div>
    <?php foreach ($types as $type): ?>
    <div class="stat-card stat-card--<?= $type === 'rule' ? 'muted' : ($type === 'organization' ? 'warning' : 'default') ?>">
        <span class="stat-card__value"><?= $stats['by_type'][$type] ?? 0 ?></span>
        <span class="stat-card__label"><?= $typeLabels[$type] ?? $type ?></span>
    </div>
    <?php endforeach; ?>
</div>

<div class="page-actions">
    <a href="/config/new" class="btn btn--primary">Neue Konfiguration</a>
</div>


<h2>Konfigurationen</h2>
<div class="filters">
    <input type="search" id="config-search" class="form-input" placeholder="Durchsuchen...">
    <select id="filter-type" class="form-select--inline" onchange="applyFilters()">
        <option value="">Alle Typen</option>
        <?php foreach ($types as $type): ?>
        <option value="<?= $type ?>" <?= $currentType === $type ? 'selected' : '' ?>><?= $typeLabels[$type] ?? $type ?></option>
        <?php endforeach; ?>
    </select>
    <select id="filter-status" class="form-select--inline" onchange="applyFilters()">
        <option value="">Alle Status</option>
        <option value="active" <?= $currentStatus === 'active' ? 'selected' : '' ?>>Aktiv</option>
        <option value="draft" <?= $currentStatus === 'draft' ? 'selected' : '' ?>>Entwurf</option>
        <option value="deprecated" <?= $currentStatus === 'deprecated' ? 'selected' : '' ?>>Deprecated</option>
    </select>
</div>

<table id="config-table" data-sortable>
    <thead>
        <tr>
            <th data-sort="id">ID</th>
            <th data-sort="type">Typ</th>
            <th data-sort="name">Name</th>
            <th data-sort="version">Version</th>
            <th data-sort="status">Status</th>
            <th data-sort="parent">Parent</th>
            <th data-sort="updated_at">Aktualisiert</th>
        </tr>
    </thead>
    <tbody>
        <?php if (!empty($configs)): ?>
        <?php foreach ($configs as $config): ?>
        <tr>
            <td><a href="/config/<?= $config['id'] ?>"><?= $config['id'] ?></a></td>
            <td><span class="badge badge--type-<?= $config['type'] ?>"><?= $typeLabels[$config['type']] ?? $config['type'] ?></span></td>
            <td><a href="/config/<?= $config['id'] ?>"><?= htmlspecialchars($config['name']) ?></a></td>
            <td><?= htmlspecialchars($config['version']) ?></td>
            <td><span class="badge badge--<?= $config['status'] ?>"><?= $config['status'] ?></span></td>
            <td><?= $config['parent_name'] ? htmlspecialchars($config['parent_name']) : '-' ?></td>
            <td><?= substr($config['updated_at'], 0, 16) ?></td>
        </tr>
        <?php endforeach; ?>
        <?php else: ?>
        <tr><td colspan="7" class="empty-state empty-state--small">Keine Konfigurationen vorhanden</td></tr>
        <?php endif; ?>
    </tbody>
</table>

<script>
function applyFilters() {
    const type = document.getElementById('filter-type').value;
    const status = document.getElementById('filter-status').value;
    let url = '/config';
    const params = [];
    if (type) params.push('type=' + type);
    if (status) params.push('status=' + status);
    if (params.length > 0) url += '?' + params.join('&');
    window.location.href = url;
}
</script>

<script type="module">
import { init } from '/js/components/data-table.js';

const dataTable = init({
    clock: { now_epoch_ms_utc: () => Date.now() },
    logger: console,
    ui: {
        showMessage: (msg) => { console.log(msg.type + ': ' + msg.text); },
        disableFeature: (key) => { console.warn('Feature disabled: ' + key); },
        offerRetry: () => Promise.resolve(false)
    },
    runId: crypto.randomUUID()
});

dataTable.create('config-table', {
    searchInput: 'config-search',
    pageSize: 20
});
</script>

<style>
.badge--type-author_profile { background: #6366f1; color: white; }
.badge--type-structure { background: #0ea5e9; color: white; }
.badge--type-organization { background: #f59e0b; color: white; }
.badge--type-contract { background: #10b981; color: white; }
.badge--type-rule { background: #6b7280; color: white; }
.badge--type-system_prompt { background: #ec4899; color: white; }
</style>

<?php $content = ob_get_clean(); ?>
<?php require VIEW_PATH . '/layout.php'; ?>
← Übersicht