frankenbot/templates/tasks.html

114 lines
5 KiB
HTML

{% extends "base.html" %}
{% block title %}Tasks{% endblock %}
{% block content %}
<div class="page-header">
<h1>Task-Verwaltung</h1>
<p>Manuelle, orchestrierte und Agent-Tasks</p>
</div>
<div class="row g-4">
<div class="col-12">
<div class="card">
<div class="card-header bg-primary d-flex justify-content-between align-items-center">
<h5 class="mb-0">Alle Tasks</h5>
<span class="badge bg-secondary">{{ tasks|length }}</span>
</div>
<div class="card-body p-0">
{% if tasks %}
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead>
<tr>
<th>#</th>
<th>Titel</th>
<th>Agent</th>
<th>Status</th>
<th>Erstellt</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
{% for task in tasks %}
<tr class="agent-border-{{ task.agent_key or 'default' }}">
<td style="color:var(--text-muted);">{{ task.id }}</td>
<td>
<strong>{{ task.title }}</strong>
{% if task.type == 'email' %}
<span class="badge bg-info ms-1">📧 Email</span>
{% elif task.type == 'telegram' %}
<span class="badge ms-1" style="background-color:#229ed9;">✈ Telegram</span>
{% elif task.type == 'action_email' %}
<span class="badge bg-info ms-1">📤 Email gesendet</span>
{% elif task.type == 'action_telegram' %}
<span class="badge ms-1" style="background-color:#229ed9;">📤 Telegram gesendet</span>
{% elif task.type == 'action_team' %}
<span class="badge bg-secondary ms-1">👤 Team</span>
{% elif task.type == 'orchestrated' %}
<span class="badge ms-1" style="background-color:#9333ea;">Orchestriert</span>
{% elif task.type == 'agent_created' or task.type == 'agent_subtask' %}
<span class="badge bg-warning ms-1">Agent</span>
{% elif task.type == 'agent_question' %}
<span class="badge bg-warning ms-1">❓ Frage</span>
{% endif %}
{% if task.parent_task_id %}
<span class="badge bg-dark ms-1" title="Sub-Task von #{{ task.parent_task_id }}">↳ #{{ task.parent_task_id }}</span>
{% endif %}
{% if task.description %}
<div style="font-size:.75rem;color:var(--text-muted);">
{{ task.description[:60] }}{% if task.description|length > 60 %}…{% endif %}
</div>
{% endif %}
</td>
<td style="font-size:.8rem;" class="agent-{{ task.agent_key or 'default' }}">
<strong>{{ task.assigned_agent }}</strong>
</td>
<td>
{% if task.status == 'pending' %}
<span class="badge bg-warning">Pending</span>
{% elif task.status == 'in_progress' %}
<span class="badge bg-primary">In Progress</span>
{% elif task.status == 'completed' %}
<span class="badge bg-success">Done</span>
{% elif task.status == 'error' %}
<span class="badge bg-danger">Fehler</span>
{% else %}
<span class="badge bg-secondary">{{ task.status }}</span>
{% endif %}
</td>
<td style="color:var(--text-muted);font-size:.75rem;">{{ task.created_at }}</td>
<td class="d-flex gap-2 align-items-center flex-wrap">
<a href="{{ url_for('task_detail', task_id=task.id) }}" class="btn btn-sm btn-outline-secondary" title="Details">Details</a>
<form method="POST" action="{{ url_for('delete_task', task_id=task.id) }}" onsubmit="return confirm('Task #{{ task.id }} wirklich löschen?')" style="display:inline;">
<button type="submit" class="btn btn-sm btn-outline-danger" title="Löschen">Löschen</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="text-center py-5" style="color:var(--text-muted);">
<p style="font-size:2rem;">📋</p>
<p>Noch keine Tasks. Erstellen Sie den ersten Task!</p>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
// Auto-Refresh alle 15 Sekunden wenn Tasks pending/in_progress sind
const hasPendingTasks = {{ 'true' if tasks|selectattr('status', 'in', ['pending', 'in_progress'])|list else 'false' }};
if (hasPendingTasks) {
setInterval(() => {
location.reload();
}, 15000); // 15 Sekunden
}
</script>
{% endblock %}