Backup #1338

ID1338
Dateipfad/var/www/dev.campus.systemische-tools.de/src/View/docs/code.php
Version13
Typ modified
Größe8.0 KB
Hashe8a0c6e0e587144449c9e0e274760ecbe247d9e01dc77c7c26b62090567235d2
Datum2025-12-25 16:26:35
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?php

declare(strict_types=1);

// @responsibility: View für Code-Analyse-Übersicht

ob_start(); ?>

<h1>Code-Analyse</h1>

<div class="stats-grid">
    <div class="stat-card">
        <span class="stat-card__value"><?= $stats['total_files'] ?? 0 ?></span>
        <span class="stat-card__label">Dateien</span>
    </div>
    <div class="stat-card stat-card--info">
        <span class="stat-card__value"><?= $stats['total_classes'] ?? 0 ?></span>
        <span class="stat-card__label">Klassen</span>
    </div>
    <div class="stat-card stat-card--success">
        <span class="stat-card__value"><?= $stats['total_functions'] ?? 0 ?></span>
        <span class="stat-card__label">Funktionen</span>
    </div>
    <div class="stat-card stat-card--warning">
        <span class="stat-card__value"><?= number_format(($stats['total_lines'] ?? 0)) ?></span>
        <span class="stat-card__label">Zeilen</span>
    </div>
</div>

<div class="page-actions" style="margin: 1.5rem 0; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;">
    <button id="scan-btn"
            class="btn btn--primary"
            hx-post="/docs/code/scan"
            hx-headers='{"X-CSRF-TOKEN": "<?= $csrfToken ?>"}'
            hx-target="#scan-result"
            hx-swap="innerHTML"
            hx-indicator="#scan-spinner">
        Jetzt scannen
    </button>
    <a href="/docs/code/graph" class="btn btn--secondary">Projekt-Graph</a>
    <span id="scan-spinner" class="htmx-indicator">Scanning...</span>
    <span id="scan-result"></span>
    <?php if ($stats['last_scan']): ?>
    <small style="color: var(--text-muted);">
        Letzter Scan: <?= substr($stats['last_scan'], 0, 16) ?>
    </small>
    <?php endif; ?>
</div>

<h2>Dateien</h2>

<div class="filters" style="margin-bottom: 1rem; display: flex; gap: 0.5rem; flex-wrap: wrap;">
    <input type="search"
           id="file-search"
           class="form-input"
           placeholder="Suche..."
           value="<?= htmlspecialchars($currentFilters['search'] ?? '') ?>"
           style="max-width: 200px;">

    <select id="filter-directory" class="form-select--inline">
        <option value="">Alle Verzeichnisse</option>
        <?php foreach ($filterOptions['directories'] ?? [] as $dir): ?>
        <option value="<?= htmlspecialchars($dir) ?>" <?= ($currentFilters['directory'] ?? '') === $dir ? 'selected' : '' ?>>
            <?= htmlspecialchars(str_replace('/var/www/dev.campus.systemische-tools.de/', '', $dir)) ?>
        </option>
        <?php endforeach; ?>
    </select>

    <select id="filter-namespace" class="form-select--inline">
        <option value="">Alle Namespaces</option>
        <?php foreach ($filterOptions['namespaces'] ?? [] as $ns): ?>
        <option value="<?= htmlspecialchars($ns) ?>" <?= ($currentFilters['namespace'] ?? '') === $ns ? 'selected' : '' ?>>
            <?= htmlspecialchars($ns) ?>
        </option>
        <?php endforeach; ?>
    </select>

    <select id="filter-has-classes" class="form-select--inline">
        <option value="">Alle</option>
        <option value="1" <?= ($currentFilters['has_classes'] ?? '') === '1' ? 'selected' : '' ?>>Mit Klassen</option>
        <option value="0" <?= ($currentFilters['has_classes'] ?? '') === '0' ? 'selected' : '' ?>>Ohne Klassen</option>
    </select>

</div>

<?php if (empty($files)): ?>
<div class="empty-state" style="padding: 2rem; text-align: center; background: var(--bg-secondary); border-radius: 8px;">
    <p>Keine Dateien gefunden. Klicke auf "Jetzt scannen" um die Code-Analyse zu starten.</p>
</div>
<?php else: ?>
<table id="code-table" data-sortable class="data-table">
    <thead>
        <tr>
            <th data-sort="file_name">Datei</th>
            <th data-sort="namespace">Namespace</th>
            <th data-sort="directory">Verzeichnis</th>
            <th data-sort="classes_count" style="text-align: center;">Klassen</th>
            <th data-sort="functions_count" style="text-align: center;">Funktionen</th>
            <th data-sort="line_count" style="text-align: right;">Zeilen</th>
            <th data-sort="hygiene_score" style="text-align: center;">Score</th>
            <th data-sort="issues_count" style="text-align: center;">Issues</th>
        </tr>
    </thead>
    <tbody>
        <?php foreach ($files as $file):
            $classes = json_decode($file['classes'] ?? '[]', true);
            $functions = json_decode($file['functions'] ?? '[]', true);
            $shortDir = str_replace('/var/www/dev.campus.systemische-tools.de/', '', $file['directory']);
            $hygieneScore = $file['hygiene_score'] ?? null;
            ?>
        <tr>
            <td>
                <a href="/docs/code/<?= $file['id'] ?>">
                    <?= htmlspecialchars($file['file_name']) ?>
                </a>
                <?php if ($file['parse_error']): ?>
                <span class="badge badge--danger" title="<?= htmlspecialchars($file['parse_error']) ?>">!</span>
                <?php endif; ?>
            </td>
            <td><?= htmlspecialchars($file['namespace'] ?? '-') ?></td>
            <td title="<?= htmlspecialchars($file['directory']) ?>"><?= htmlspecialchars($shortDir) ?></td>
            <td style="text-align: center;">
                <?php if (count($classes) > 0): ?>
                <span class="badge badge--info"><?= count($classes) ?></span>
                <?php else: ?>
                -
                <?php endif; ?>
            </td>
            <td style="text-align: center;">
                <?php if (count($functions) > 0): ?>
                <span class="badge badge--success"><?= count($functions) ?></span>
                <?php else: ?>
                -
                <?php endif; ?>
            </td>
            <td style="text-align: right;"><?= number_format($file['line_count']) ?></td>
            <td style="text-align: center;">
                <?php if ($hygieneScore !== null): ?>
                <span class="text-muted"><?= $hygieneScore ?></span>
                <?php else: ?>
                -
                <?php endif; ?>
            </td>
            <td style="text-align: center;">
                <?php if ($hygieneStatus): ?>
                <span class="badge <?= $statusClass ?>"><?= $hygieneStatus ?></span>
                <?php else: ?>
                -
                <?php endif; ?>
            </td>
            <td style="text-align: center;">
                <?php if (($file['issues_count'] ?? 0) > 0): ?>
                <span class="badge badge--danger"><?= $file['issues_count'] ?></span>
                <?php else: ?>
                <span class="badge badge--success">0</span>
                <?php endif; ?>
            </td>
        </tr>
        <?php endforeach; ?>
    </tbody>
</table>
<?php endif; ?>

<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) }
});

dataTable.create('code-table', {
    searchInput: 'file-search',
    pageSize: 50,
    filters: {
        'filter-directory': 2,
        'filter-namespace': 1,
        'filter-has-classes': 3,
        'filter-hygiene': 7
    }
});

document.body.addEventListener('htmx:afterRequest', function(evt) {
    if (evt.detail.elt.id === 'scan-btn') {
        try {
            const response = JSON.parse(evt.detail.xhr.responseText);
            if (response.success) {
                document.getElementById('scan-result').innerHTML =
                    '<span class="badge badge--success">' +
                    response.files_scanned + ' Dateien, ' +
                    response.total_classes + ' Klassen, ' +
                    response.total_functions + ' Funktionen (' +
                    response.duration_ms + 'ms)</span>';
                setTimeout(() => location.reload(), 1500);
            }
        } catch (e) {
            document.getElementById('scan-result').innerHTML =
                '<span class="badge badge--danger">Fehler beim Scan</span>';
        }
    }
});
</script>

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

Vollständig herunterladen

Aktionen

Herunterladen

Andere Versionen dieser Datei

ID Version Typ Größe Datum
1354 19 modified 7.7 KB 2025-12-25 16:29
1353 18 modified 7.7 KB 2025-12-25 16:29
1344 17 modified 7.7 KB 2025-12-25 16:28
1343 16 modified 7.7 KB 2025-12-25 16:28
1342 15 modified 7.7 KB 2025-12-25 16:28
1339 14 modified 7.7 KB 2025-12-25 16:26
1338 13 modified 8.0 KB 2025-12-25 16:26
1337 12 modified 8.4 KB 2025-12-25 16:26
1336 11 modified 8.5 KB 2025-12-25 16:26
1335 10 modified 9.3 KB 2025-12-25 16:26
1319 9 modified 9.3 KB 2025-12-25 16:16
1318 8 modified 9.3 KB 2025-12-25 16:16
1317 7 modified 9.2 KB 2025-12-25 16:16
1316 6 modified 9.2 KB 2025-12-25 16:16
1315 5 modified 9.1 KB 2025-12-25 16:16
938 4 modified 9.1 KB 2025-12-23 21:47
937 3 modified 8.4 KB 2025-12-23 21:47
936 2 modified 6.9 KB 2025-12-23 21:47
895 1 modified 6.9 KB 2025-12-23 15:53

← Zurück zur Übersicht