run-status.php
- Pfad:
src/View/content-pipeline/run-status.php
- Namespace: -
- Zeilen: 382 | Größe: 11,531 Bytes
- Geändert: 2025-12-28 01:20:47 | Gescannt: 2025-12-31 10:22:15
Code Hygiene Score: 85
- Dependencies: 100 (25%)
- LOC: 39 (20%)
- Methods: 100 (20%)
- Secrets: 100 (15%)
- Classes: 100 (10%)
- Magic Numbers: 70 (10%)
Issues 3
| Zeile |
Typ |
Beschreibung |
| 126 |
magic_number |
Magic Number gefunden: 100 |
| 140 |
magic_number |
Magic Number gefunden: 100 |
| 177 |
magic_number |
Magic Number gefunden: 100 |
Versionen 19
-
v19
2025-12-28 01:20 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v18
2025-12-27 12:21 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v17
2025-12-27 12:21 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v16
2025-12-23 15:25 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v15
2025-12-23 05:13 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v14
2025-12-23 05:08 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v13
2025-12-23 05:08 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v12
2025-12-23 05:07 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v11
2025-12-23 05:07 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v10
2025-12-23 05:04 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v9
2025-12-23 05:04 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v8
2025-12-23 04:59 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v7
2025-12-23 04:59 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v6
2025-12-23 04:59 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v5
2025-12-23 04:59 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v4
2025-12-23 04:57 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v3
2025-12-23 04:52 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v2
2025-12-23 04:52 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
-
v1
2025-12-23 04:52 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
Code
<?php
declare(strict_types=1);
// @responsibility: View für Pipeline-Run-Status mit HTMX-Cancel und JS-Polling
ob_start();
?>
<h1>Pipeline Status</h1>
<p class="subtitle"><?= htmlspecialchars($pipeline['name']) ?> → Run #<?= $run['id'] ?></p>
<div class="status-page"
id="status-container"
data-poll-url="/content-pipeline/<?= $pipeline['id'] ?>/run/<?= $run['id'] ?>/poll">
<!-- Status Badge + Cancel -->
<div class="status-header">
<span class="badge badge--large" id="status-badge" data-status="<?= $run['status'] ?>">
<?= $run['status'] ?>
</span>
<span id="cancel-container" class="status-header__cancel">
<button type="button"
class="btn btn--danger btn--small"
id="cancel-btn"
hx-post="/content-pipeline/<?= $pipeline['id'] ?>/run/<?= $run['id'] ?>/cancel"
hx-headers='{"X-CSRF-TOKEN": "<?= $csrfToken ?>"}'
hx-target="#cancel-container"
hx-swap="innerHTML"
hx-disabled-elt="this"
hx-confirm="Pipeline-Run wirklich abbrechen?"
<?= $run['status'] !== 'running' ? 'disabled' : '' ?>>
Abbrechen
</button>
</span>
<span class="stall-warning" id="stall-warning" style="display: none;">
Keine Aktivitaet seit 60s
</span>
</div>
<!-- Progress Bar -->
<?php
$total = (int) ($run['documents_total'] ?? 0);
$processed = (int) ($run['documents_processed'] ?? 0);
$progress = $total > 0 ? round(($processed / $total) * \Domain\Constants::PERCENT_FULL) : 0;
?>
<div class="progress-bar">
<div class="progress-bar__fill" id="progress-fill" style="width: <?= $progress ?>%"></div>
</div>
<div class="progress-label">
<span><span id="docs-processed"><?= $processed ?></span>/<span id="docs-total"><?= $total ?></span> Dateien</span>
<span id="progress-percent"><?= $progress ?>%</span>
</div>
<!-- Status Info -->
<ul class="status-info">
<li><span class="status-info__label">Schritt:</span> <span class="status-info__value" id="current-step"><?= htmlspecialchars($run['current_step'] ?? 'Initialisierung') ?></span></li>
<li><span class="status-info__label">Dokument:</span> <span class="status-info__value" id="current-document"><?= htmlspecialchars($run['current_document'] ?? '-') ?></span></li>
<li><span class="status-info__label">Zeit:</span> <span class="status-info__value" id="elapsed-time">00:00</span></li>
<li><span class="status-info__label">ETA:</span> <span class="status-info__value" id="eta-time">-</span></li>
<li><span class="status-info__label">Chunks:</span> <span class="status-info__value" id="chunks-count"><?= (int) ($run['chunks_created'] ?? 0) ?></span></li>
<li><span class="status-info__label">Embeddings:</span> <span class="status-info__value" id="embeddings-count"><?= (int) ($run['embeddings_created'] ?? 0) ?></span></li>
<li><span class="status-info__label">Fehler:</span> <span class="status-info__value status-info__value--danger" id="failed-count"><?= (int) ($run['documents_failed'] ?? 0) ?></span></li>
</ul>
<!-- Live Log -->
<div class="log-section">
<h3>Live Log</h3>
<pre class="log-output" id="log-output"><?= htmlspecialchars($run['log_tail'] ?? 'Warte auf Ausgabe...') ?></pre>
</div>
<!-- Error Display -->
<div class="error-section" id="error-section" style="display: <?= $run['error_log'] ? 'block' : 'none' ?>;">
<h3>Fehler</h3>
<pre class="error-output" id="error-output"><?= htmlspecialchars($run['error_log'] ?? '') ?></pre>
</div>
</div>
<style>
.subtitle {
color: var(--text-muted, #666);
margin-top: -0.5rem;
margin-bottom: 1.5rem;
}
.status-page {
max-width: 800px;
}
.status-header {
display: flex;
align-items: center;
gap: 1rem;
margin-bottom: 1.5rem;
}
.badge--large {
font-size: 1rem;
padding: 0.5rem 1rem;
text-transform: uppercase;
}
.badge[data-status="running"] {
background: var(--info-color, #0066cc);
color: white;
animation: pulse 2s infinite;
}
.badge[data-status="completed"] {
background: var(--success-color, #28a745);
color: white;
}
.badge[data-status="failed"] {
background: var(--danger-color, #dc3545);
color: white;
}
.badge[data-status="cancelled"] {
background: var(--warning-color, #ffc107);
color: #333;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.7; }
}
.stall-warning {
background: var(--warning-bg, #fff3cd);
color: var(--warning-color, #856404);
padding: 0.25rem 0.5rem;
border-radius: 4px;
font-size: 0.85rem;
animation: blink 1s infinite;
}
@keyframes blink {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
.status-info {
list-style: none;
padding: 0;
margin: 0 0 1.5rem 0;
}
.status-info li {
display: flex;
padding: 0.25rem 0;
}
.status-info__label {
color: var(--text-muted, #666);
min-width: 100px;
}
.status-info__value {
font-family: monospace;
}
.status-info__value--danger {
color: var(--danger-color, #dc3545);
}
.progress-bar {
height: 20px;
background: var(--bg-muted, #e9ecef);
border-radius: 10px;
overflow: hidden;
margin-bottom: 0.5rem;
}
.progress-bar__fill {
height: 100%;
background: var(--primary-color, #007bff);
transition: width 0.3s ease;
}
.progress-label {
display: flex;
justify-content: space-between;
font-size: 0.9rem;
color: var(--text-muted, #666);
margin-bottom: 1rem;
}
.log-section, .error-section {
margin-bottom: 1.5rem;
}
.log-section h3, .error-section h3 {
margin-bottom: 0.5rem;
font-size: 1rem;
}
.log-output {
background: var(--bg-dark, #1e1e1e);
color: var(--text-light, #d4d4d4);
padding: 1rem;
border-radius: 6px;
font-family: monospace;
font-size: 0.8rem;
max-height: 600px;
min-height: 200px;
overflow-y: auto;
white-space: pre-wrap;
word-break: break-word;
}
.error-output {
background: var(--danger-bg, #f8d7da);
color: var(--danger-color, #721c24);
padding: 1rem;
border-radius: 6px;
font-family: monospace;
font-size: 0.8rem;
max-height: 200px;
overflow-y: auto;
white-space: pre-wrap;
}
.status-header__cancel {
margin: 0;
}
@media (max-width: 600px) {
.status-cards, .stats-row {
grid-template-columns: 1fr;
}
}
</style>
<script>
(function() {
const container = document.getElementById('status-container');
const pollUrl = container.dataset.pollUrl;
let pollInterval = null;
let isTerminal = false;
// ETA calculation state
let progressHistory = [];
function calculateETA(data) {
// Calculate progress based on documents processed
const total = data.documents_total || 1;
const processed = data.documents_processed || 0;
const progress = processed / total;
// Track progress changes for rate calculation
const now = Date.now();
progressHistory.push({ time: now, progress: progress });
// Keep only last 10 data points
if (progressHistory.length > 10) {
progressHistory.shift();
}
// Need at least 2 points and some progress
if (progressHistory.length < 2 || progress <= 0) {
return '-';
}
// Calculate average rate over recent history
const oldest = progressHistory[0];
const newest = progressHistory[progressHistory.length - 1];
const timeDiff = (newest.time - oldest.time) / 1000; // seconds
const progressDiff = newest.progress - oldest.progress;
if (timeDiff <= 0 || progressDiff <= 0) {
return '-';
}
const rate = progressDiff / timeDiff; // progress per second
const remaining = 1 - progress;
const etaSeconds = Math.round(remaining / rate);
const hours = Math.floor(etaSeconds / 3600);
const minutes = Math.floor((etaSeconds % 3600) / 60);
const seconds = etaSeconds % 60;
return String(hours).padStart(2, '0') + ':' +
String(minutes).padStart(2, '0') + ':' +
String(seconds).padStart(2, '0');
}
function updateUI(data) {
// Status Badge
const badge = document.getElementById('status-badge');
badge.textContent = data.status;
badge.dataset.status = data.status;
// Stall Warning
document.getElementById('stall-warning').style.display = data.is_stalled ? 'inline' : 'none';
// Current Step & Document
document.getElementById('current-step').textContent = data.current_step || 'Warte...';
document.getElementById('current-document').textContent = data.current_document || '-';
// Time
document.getElementById('elapsed-time').textContent = data.elapsed_formatted || '00:00';
// ETA calculation
const eta = calculateETA(data);
document.getElementById('eta-time').textContent = eta;
// Progress Bar
document.getElementById('docs-processed').textContent = data.documents_processed;
document.getElementById('docs-total').textContent = data.documents_total;
document.getElementById('progress-percent').textContent = data.progress + '%';
document.getElementById('progress-fill').style.width = data.progress + '%';
// Stats
document.getElementById('chunks-count').textContent = data.chunks_created;
document.getElementById('embeddings-count').textContent = data.embeddings_created;
document.getElementById('failed-count').textContent = data.documents_failed;
// Log
if (data.log_tail) {
const logEl = document.getElementById('log-output');
logEl.textContent = data.log_tail;
logEl.scrollTop = logEl.scrollHeight;
}
// Error
if (data.error_log) {
document.getElementById('error-section').style.display = 'block';
document.getElementById('error-output').textContent = data.error_log;
}
// Cancel Button
document.getElementById('cancel-btn').disabled = data.is_terminal;
// Stop polling if terminal
if (data.is_terminal && !isTerminal) {
isTerminal = true;
stopPolling();
}
}
function poll() {
fetch(pollUrl)
.then(response => response.json())
.then(data => {
updateUI(data);
})
.catch(error => {
console.error('Polling error:', error);
});
}
function startPolling() {
poll(); // Initial poll
pollInterval = setInterval(poll, 2000); // Poll every 2s
}
function stopPolling() {
if (pollInterval) {
clearInterval(pollInterval);
pollInterval = null;
}
}
// Start polling on page load
startPolling();
// Stop polling when page is hidden
document.addEventListener('visibilitychange', function() {
if (document.hidden) {
stopPolling();
} else if (!isTerminal) {
startPolling();
}
});
})();
</script>
<?php $content = ob_get_clean(); ?>
<?php require VIEW_PATH . '/layout.php'; ?>