import.php

Code Hygiene Score: 98

Keine Issues gefunden.

Versionen 2

Code

<?php ob_start(); ?>

<h1>Import Pipeline</h1>

<?php if ($pipeline): ?>
<div class="pipeline-card">
    <div class="pipeline-header">
        <h2><?= htmlspecialchars($pipeline['name']) ?></h2>
        <div class="pipeline-actions">
            <a href="/content-pipeline/<?= $pipeline['id'] ?>/edit" class="btn btn--small">Bearbeiten</a>
            <form action="/content-pipeline/<?= $pipeline['id'] ?>/run" method="POST" style="display:inline;">
                <input type="hidden" name="_csrf_token" value="<?= htmlspecialchars($csrfToken ?? '') ?>">
                <button type="submit" class="btn btn--primary">Pipeline starten</button>
            </form>
        </div>
    </div>

    <?php if ($pipeline['description']): ?>
    <p class="pipeline-description"><?= htmlspecialchars($pipeline['description']) ?></p>
    <?php endif; ?>

    <div class="pipeline-meta">
        <span><strong>Quelle:</strong> <?= htmlspecialchars($pipeline['source_path']) ?></span>
        <span><strong>Formate:</strong> <?= implode(', ', $pipeline['extensions'] ?? []) ?></span>
    </div>

    <h3>Pipeline-Schritte</h3>
    <div class="pipeline-steps">
        <?php
        $stepLabels = [
            'detect' => ['label' => 'Detect', 'icon' => 'search', 'desc' => 'Dateien scannen'],
            'extract' => ['label' => 'Extract', 'icon' => 'file-text', 'desc' => 'Text extrahieren'],
            'chunk' => ['label' => 'Chunk', 'icon' => 'scissors', 'desc' => 'Semantisch teilen'],
            'embed' => ['label' => 'Embed', 'icon' => 'cpu', 'desc' => 'Vektorisieren'],
            'analyze' => ['label' => 'Analyze', 'icon' => 'brain', 'desc' => 'Semantik analysieren'],
        ];
    $steps = $pipeline['steps'] ?? [];
    $totalSteps = count($steps);
    ?>
        <?php foreach ($steps as $index => $step): ?>
        <?php $meta = $stepLabels[$step['step_type']] ?? ['label' => $step['step_type'], 'icon' => 'box', 'desc' => '']; ?>
        <div class="pipeline-step <?= $step['enabled'] ? 'pipeline-step--enabled' : 'pipeline-step--disabled' ?>">
            <div class="pipeline-step__header">
                <span class="pipeline-step__icon" data-icon="<?= $meta['icon'] ?>"></span>
                <span class="pipeline-step__name"><?= $meta['label'] ?></span>
                <span class="pipeline-step__status"><?= $step['enabled'] ? 'Aktiv' : 'Inaktiv' ?></span>
            </div>
            <div class="pipeline-step__desc"><?= $meta['desc'] ?></div>
            <?php if ($step['config']): ?>
            <div class="pipeline-step__config">
                <?php foreach ($step['config'] as $key => $value): ?>
                <span class="config-item"><?= htmlspecialchars($key) ?>: <?= is_bool($value) ? ($value ? 'ja' : 'nein') : htmlspecialchars((string) $value) ?></span>
                <?php endforeach; ?>
            </div>
            <?php endif; ?>
            <form action="/content-pipeline/<?= $pipeline['id'] ?>/steps/<?= $step['id'] ?>/toggle" method="POST" class="pipeline-step__toggle">
                <input type="hidden" name="_csrf_token" value="<?= htmlspecialchars($csrfToken ?? '') ?>">
                <button type="submit" class="btn btn--small <?= $step['enabled'] ? 'btn--danger' : 'btn--success' ?>">
                    <?= $step['enabled'] ? 'Deaktivieren' : 'Aktivieren' ?>
                </button>
            </form>
        </div>
        <?php if ($index < $totalSteps - 1): ?>
        <div class="pipeline-arrow">&#8594;</div>
        <?php endif; ?>
        <?php endforeach; ?>
    </div>

    <?php if ($latestRun): ?>
    <h3>Letzter Run</h3>
    <div class="run-info">
        <div class="run-info__status">
            <span class="badge badge--<?= $latestRun['status'] === 'completed' ? 'success' : ($latestRun['status'] === 'failed' ? 'danger' : 'warning') ?>">
                <?= $latestRun['status'] ?>
            </span>
        </div>
        <div class="run-info__details">
            <span>Gestartet: <?= $latestRun['started_at'] ?? '-' ?></span>
            <?php if ($latestRun['completed_at']): ?>
            <span>Beendet: <?= $latestRun['completed_at'] ?></span>
            <?php endif; ?>
            <span>Dokumente: <?= $latestRun['documents_processed'] ?? 0 ?>/<?= $latestRun['documents_total'] ?? 0 ?></span>
            <span>Chunks: <?= $latestRun['chunks_created'] ?? 0 ?></span>
            <?php if ($latestRun['documents_failed'] > 0): ?>
            <span class="text-danger">Fehler: <?= $latestRun['documents_failed'] ?></span>
            <?php endif; ?>
        </div>
        <?php if ($latestRun['error_log']): ?>
        <details class="run-error">
            <summary>Fehlerlog</summary>
            <pre><?= htmlspecialchars($latestRun['error_log']) ?></pre>
        </details>
        <?php endif; ?>
    </div>
    <?php endif; ?>
</div>
<?php else: ?>
<div class="empty-state">
    <p>Keine Pipeline konfiguriert.</p>
    <a href="/content-pipeline/new" class="btn btn--primary">Neue Pipeline erstellen</a>
</div>
<?php endif; ?>

<p class="links-bar">
    <a href="/content-pipeline">Alle Pipelines</a>
    <a href="/docs/modul/content-pipeline">Dokumentation</a>
</p>

<style>
.pipeline-card {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.pipeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.pipeline-header h2 {
    margin: 0;
}
.pipeline-description {
    color: var(--text-muted, #666);
    margin-bottom: 1rem;
}
.pipeline-meta {
    display: flex;
    gap: 2rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}
.pipeline-steps {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.pipeline-step {
    border: 2px solid var(--border-color, #ddd);
    border-radius: 8px;
    padding: 1rem;
    min-width: 140px;
    text-align: center;
    background: var(--card-bg, #fff);
}
.pipeline-step--enabled {
    border-color: var(--success-color, #28a745);
    background: var(--success-bg, #d4edda);
}
.pipeline-step--disabled {
    border-color: var(--muted-color, #999);
    opacity: 0.6;
}
.pipeline-step__header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}
.pipeline-step__name {
    font-weight: bold;
}
.pipeline-step__status {
    font-size: 0.75rem;
    color: var(--text-muted, #666);
}
.pipeline-step__desc {
    font-size: 0.8rem;
    color: var(--text-muted, #666);
    margin: 0.5rem 0;
}
.pipeline-step__config {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    justify-content: center;
    margin-top: 0.5rem;
}
.config-item {
    font-size: 0.7rem;
    background: var(--bg-muted, #f5f5f5);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}
.pipeline-step__toggle {
    margin-top: 0.5rem;
}
.pipeline-arrow {
    font-size: 1.5rem;
    color: var(--text-muted, #666);
}
.run-info {
    background: var(--bg-muted, #f5f5f5);
    border-radius: 6px;
    padding: 1rem;
}
.run-info__details {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}
.run-error {
    margin-top: 1rem;
}
.run-error pre {
    background: var(--danger-bg, #f8d7da);
    padding: 0.5rem;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.8rem;
}
</style>

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