Initial commit
This commit is contained in:
parent
387bc056b9
commit
df8c2313a9
275 changed files with 12939 additions and 263 deletions
|
|
@ -15,20 +15,38 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{% for job in jobs %}
|
||||
<tr>
|
||||
<tr id="job-row-{{ job.id }}">
|
||||
<td>{{ job.filename }}</td>
|
||||
<td class="job-status">{{ job.status }}</td>
|
||||
<td id="status-{{ job.id }}" class="job-status">
|
||||
{{ job.status }}
|
||||
</td>
|
||||
<td>{{ job.created_at.strftime('%Y-%m-%d %H:%M:%S') }}</td>
|
||||
<td>
|
||||
{% if job.status == "Completed" %}
|
||||
<a href="{{ url_for('auth.download_result', job_id=job.id) }}">Download</a>
|
||||
<td id="result-{{ job.id }}">
|
||||
{% if job.result_filename and 'Failed' not in job.status %}
|
||||
<a href="{{ url_for('auth.download_result', job_id=job.id) }}" class="dl-btn">
|
||||
🎯 Gefiltert
|
||||
</a>
|
||||
{% if job.result_filename_raw %}
|
||||
|
||||
<a href="{{ url_for('auth.download_result_raw', job_id=job.id) }}" class="dl-btn dl-btn-raw">
|
||||
📋 Alle
|
||||
</a>
|
||||
{% endif %}
|
||||
{% elif 'Failed' in job.status %}
|
||||
<span class="status-failed">❌ {{ job.result_filename or 'Fehler' }}</span>
|
||||
{% else %}
|
||||
Noch nicht verfügbar
|
||||
<span class="status-pending">⏳ Noch nicht verfügbar</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if 'Failed' in job.status %}
|
||||
<!-- 🆕 Resume Button -->
|
||||
<form action="{{ url_for('auth.resume_job', job_id=job.id) }}" method="POST" style="display:inline;">
|
||||
<button type="submit" class="btn-resume">▶️ Resume</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
<form action="{{ url_for('auth.delete_job', job_id=job.id) }}" method="POST" style="display:inline;">
|
||||
<button type="submit" class="delete-btn">Löschen</button>
|
||||
<button type="submit" class="delete-btn">🗑️ Löschen</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -37,25 +55,101 @@
|
|||
</table>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.job-status { font-weight: bold; }
|
||||
.status-failed { color: #e74c3c; font-weight: bold; }
|
||||
.status-pending { color: #888; }
|
||||
|
||||
.eta-badge { display: inline-block; background: #eaf4ff; color: #1a6fa8;
|
||||
border-radius: 10px; padding: 2px 8px; font-size: 0.82em;
|
||||
font-weight: bold; margin-left: 6px; }
|
||||
|
||||
.dl-btn { display: inline-block; padding: 4px 10px; border-radius: 4px;
|
||||
text-decoration: none; font-size: 0.85em; font-weight: bold;
|
||||
background: #27ae60; color: #fff; margin: 2px 1px; transition: background 0.2s; }
|
||||
.dl-btn:hover { background: #1e8449; }
|
||||
.dl-btn-raw { background: #2980b9; }
|
||||
.dl-btn-raw:hover { background: #1a5e8a; }
|
||||
|
||||
.btn-resume { background: #e67e22; color: white; border: none;
|
||||
padding: 4px 10px; border-radius: 4px; cursor: pointer;
|
||||
font-size: 0.85em; font-weight: bold; margin-right: 4px; }
|
||||
.btn-resume:hover { background: #ca6f1e; }
|
||||
</style>
|
||||
|
||||
<script>
|
||||
// Periodische Aktualisierung des Jobstatus
|
||||
setInterval(function() {
|
||||
fetch('{{ url_for("auth.job_status") }}')
|
||||
.then(response => response.text())
|
||||
.then(html => {
|
||||
const parser = new DOMParser();
|
||||
const doc = parser.parseFromString(html, 'text/html');
|
||||
const newRows = doc.querySelectorAll('#jobs-table tbody tr');
|
||||
const currentRows = document.querySelectorAll('#jobs-table tbody tr');
|
||||
// ETA Badge aus Status-String parsen
|
||||
function parseStatus(status) {
|
||||
const parts = status.split('|');
|
||||
if (parts.length === 2) {
|
||||
return `<span>${parts[0].trim()}</span>
|
||||
<span class="eta-badge">${parts[1].trim()}</span>`;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
newRows.forEach((newRow, index) => {
|
||||
const newStatus = newRow.querySelector('.job-status').textContent;
|
||||
currentRows[index].querySelector('.job-status').textContent = newStatus;
|
||||
function renderResult(resultCell, data) {
|
||||
const hasFailed = data.status.includes('Failed') || data.status.includes('❌');
|
||||
const hasFiltered = data.result_filename && !hasFailed;
|
||||
const hasRaw = data.result_filename_raw && !hasFailed;
|
||||
|
||||
const newResult = newRow.querySelector('td:nth-child(4)').innerHTML;
|
||||
currentRows[index].querySelector('td:nth-child(4)').innerHTML = newResult;
|
||||
});
|
||||
});
|
||||
}, 5000); // Aktualisierung alle 5 Sekunden
|
||||
if (hasFiltered) {
|
||||
let html = `<a href="/download/${data.id}" class="dl-btn">🎯 Gefiltert</a>`;
|
||||
if (hasRaw) {
|
||||
html += ` <a href="/download_raw/${data.id}" class="dl-btn dl-btn-raw">📋 Alle</a>`;
|
||||
}
|
||||
resultCell.innerHTML = html;
|
||||
} else if (hasFailed) {
|
||||
resultCell.innerHTML = `<span class="status-failed">❌ ${data.result_filename || 'Fehler'}</span>`;
|
||||
} else {
|
||||
resultCell.innerHTML = `<span class="status-pending">⏳ Noch nicht verfügbar</span>`;
|
||||
}
|
||||
}
|
||||
|
||||
function renderActions(row, data) {
|
||||
const actionsCell = row.querySelector('td:last-child');
|
||||
const hasFailed = data.status.includes('Failed');
|
||||
let html = '';
|
||||
if (hasFailed) {
|
||||
html += `<form action="/resume_job/${data.id}" method="POST" style="display:inline;">
|
||||
<button type="submit" class="btn-resume">▶️ Resume</button>
|
||||
</form>`;
|
||||
}
|
||||
html += `<form action="/delete_job/${data.id}" method="POST" style="display:inline;">
|
||||
<button type="submit" class="delete-btn">🗑️ Löschen</button>
|
||||
</form>`;
|
||||
actionsCell.innerHTML = html;
|
||||
}
|
||||
|
||||
function pollJob(jobId) {
|
||||
fetch(`/job_status/${jobId}`)
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
const statusCell = document.getElementById(`status-${jobId}`);
|
||||
const resultCell = document.getElementById(`result-${jobId}`);
|
||||
const row = document.getElementById(`job-row-${jobId}`);
|
||||
|
||||
statusCell.innerHTML = parseStatus(data.status);
|
||||
renderResult(resultCell, data);
|
||||
renderActions(row, data);
|
||||
|
||||
const done = data.status.includes('✅') || data.status.includes('Failed') || data.status.includes('❌');
|
||||
if (!done) {
|
||||
setTimeout(() => pollJob(jobId), 5000);
|
||||
}
|
||||
})
|
||||
.catch(() => setTimeout(() => pollJob(jobId), 10000));
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
document.querySelectorAll('.job-status').forEach(function (cell) {
|
||||
const jobId = cell.id.split('-')[1];
|
||||
const status = cell.textContent.trim();
|
||||
cell.innerHTML = parseStatus(status);
|
||||
if (!status.includes('✅') && !status.includes('Failed') && !status.includes('❌')) {
|
||||
pollJob(jobId);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue