250 lines
16 KiB
HTML
250 lines
16 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}{{ encoder_type.title() }} Reports - Encoder{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="px-4 sm:px-0 max-w-full mx-auto">
|
|
<div class="mb-8">
|
|
<div class="flex items-center justify-between">
|
|
<div>
|
|
<h1 class="text-4xl font-extrabold text-transparent bg-clip-text bg-gradient-to-r from-fuchsia-400 via-sky-400 to-cyan-400 mb-2 tracking-tight">{{ encoder_type.title() }} Encoder Reports</h1>
|
|
<p class="text-gray-300 text-lg">Job history and statistics for {{ encoder_type }} encoding</p>
|
|
</div>
|
|
<a href="{{ url_for('index') }}" class="bg-gradient-to-r from-sky-600 to-fuchsia-600 hover:from-sky-500 hover:to-fuchsia-500 text-white px-6 py-2 rounded-full text-base shadow-lg font-semibold transition-all">
|
|
← Back to Dashboard
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="bg-gray-900 rounded-2xl modern-shadow overflow-hidden px-2 sm:px-6 md:px-12">
|
|
<div class="px-8 py-6 border-b border-gray-800">
|
|
<div class="flex items-center justify-between mb-4">
|
|
<div>
|
|
<h2 class="text-2xl font-bold text-white">Job Reports</h2>
|
|
<p class="text-base text-gray-400">Total: {{ total }} jobs</p>
|
|
</div>
|
|
</div>
|
|
<!-- Search Form -->
|
|
<form method="GET" class="mb-4">
|
|
<div class="flex space-x-2">
|
|
<input type="text" name="search" value="{{ search_term or '' }}" placeholder="Search files or error messages..."
|
|
class="flex-1 bg-gray-800 border border-gray-700 rounded-lg px-3 py-2 text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-sky-500 focus:border-transparent">
|
|
<button type="submit" class="bg-sky-600 hover:bg-sky-700 text-white px-4 py-2 rounded-lg text-base font-semibold transition-all">
|
|
Search
|
|
</button>
|
|
{% if search_term %}
|
|
<a href="{{ url_for('reports', encoder_type=encoder_type) }}" class="bg-gray-700 hover:bg-gray-800 text-white px-4 py-2 rounded-lg text-base font-semibold transition-all">
|
|
Clear
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
</form>
|
|
</div>
|
|
{% if reports %}
|
|
<div class="overflow-x-auto">
|
|
<table class="w-full min-w-full divide-y divide-gray-800 rounded-xl modern-shadow">
|
|
<thead class="bg-gray-800">
|
|
<tr>
|
|
<th class="px-6 py-3 text-left text-xs font-bold text-sky-300 uppercase tracking-wider">File</th>
|
|
<th class="px-6 py-3 text-left text-xs font-bold text-sky-300 uppercase tracking-wider">Status</th>
|
|
<th class="px-6 py-3 text-left text-xs font-bold text-sky-300 uppercase tracking-wider">Original Size</th>
|
|
<th class="px-6 py-3 text-left text-xs font-bold text-sky-300 uppercase tracking-wider">Encoded Size</th>
|
|
<th class="px-6 py-3 text-left text-xs font-bold text-sky-300 uppercase tracking-wider">Space Saved</th>
|
|
<th class="px-6 py-3 text-left text-xs font-bold text-sky-300 uppercase tracking-wider">Format</th>
|
|
<th class="px-6 py-3 text-left text-xs font-bold text-sky-300 uppercase tracking-wider">Processing Time</th>
|
|
<th class="px-6 py-3 text-left text-xs font-bold text-sky-300 uppercase tracking-wider">Date</th>
|
|
<th class="px-6 py-3 text-left text-xs font-bold text-sky-300 uppercase tracking-wider">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="bg-gray-900 divide-y divide-gray-800">
|
|
{% for report in reports %}
|
|
<tr class="hover:bg-gray-800 transition-all">
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
<div class="text-base text-white font-semibold">{{ report.file_path.split('/')[-1] }}</div>
|
|
<div class="text-xs text-gray-400">{{ report.file_path }}</div>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
{% if report.status == 'success' %}
|
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold bg-green-900 text-green-200">
|
|
<svg class="w-3 h-3 mr-1" fill="currentColor" viewBox="0 0 20 20">
|
|
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"/>
|
|
</svg>
|
|
Success
|
|
</span>
|
|
{% elif report.status == 'failed' %}
|
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold bg-red-900 text-red-200">
|
|
<svg class="w-3 h-3 mr-1" fill="currentColor" viewBox="0 0 20 20">
|
|
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z"/>
|
|
</svg>
|
|
Failed
|
|
</span>
|
|
{% elif report.status == 'skipped' %}
|
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold bg-sky-900 text-sky-200">
|
|
<svg class="w-3 h-3 mr-1" fill="currentColor" viewBox="0 0 20 20">
|
|
<circle cx="10" cy="10" r="8" stroke="currentColor" stroke-width="2" fill="none" />
|
|
<path fill-rule="evenodd" d="M6 10a4 4 0 118 0 4 4 0 01-8 0z" fill="currentColor" />
|
|
</svg>
|
|
Skipped
|
|
</span>
|
|
{% else %}
|
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold bg-yellow-900 text-yellow-200">
|
|
<svg class="w-3 h-3 mr-1 animate-spin" fill="none" viewBox="0 0 24 24">
|
|
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
|
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
</svg>
|
|
Processing
|
|
</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-base text-gray-300">
|
|
{{ report.original_size|format_bytes }}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-base text-gray-300">
|
|
{{ report.encoded_size|format_bytes }}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-base">
|
|
{% if report.size_saved > 0 %}
|
|
<span class="text-green-400 font-semibold">{{ report.size_saved|format_bytes }}</span>
|
|
{% elif report.size_saved < 0 %}
|
|
<span class="text-red-400 font-semibold">{{ report.size_saved|format_bytes }}</span>
|
|
{% else %}
|
|
<span class="text-gray-400 font-semibold">{{ report.size_saved|format_bytes }}</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-base text-gray-300">
|
|
<span class="text-gray-400">{{ report.original_format }}</span>
|
|
<span class="text-gray-500">→</span>
|
|
<span class="text-white">{{ report.encoded_format }}</span>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-base text-gray-300">
|
|
{{ report.processing_time|format_duration }}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-base text-gray-300">
|
|
<div>{{ report.created_at.strftime('%Y-%m-%d') }}</div>
|
|
<div class="text-xs text-gray-400">{{ report.created_at.strftime('%H:%M:%S') }}</div>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-base text-gray-300">
|
|
{% if report.status == 'failed' %}
|
|
<button onclick="requeueJob({{ report.id }})" class="bg-gradient-to-r from-yellow-500 to-yellow-700 hover:from-yellow-400 hover:to-yellow-600 text-white px-3 py-1 rounded-full text-xs font-semibold transition-all">
|
|
Requeue
|
|
</button>
|
|
{% else %}
|
|
<span class="text-gray-500">-</span>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% if report.status == 'failed' and report.error_message %}
|
|
<tr class="bg-red-900 bg-opacity-20">
|
|
<td colspan="9" class="px-6 py-2">
|
|
<div class="text-base text-red-300">
|
|
<span class="font-semibold">Error:</span> {{ report.error_message }}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- Pagination -->
|
|
{% if total_pages > 1 %}
|
|
<div class="bg-gray-700 px-4 py-3 flex items-center justify-between border-t border-gray-600 sm:px-6">
|
|
<div class="flex-1 flex justify-between sm:hidden">
|
|
{% if page > 1 %}
|
|
<a href="{{ url_for('reports', encoder_type=encoder_type, page=page-1) }}" class="relative inline-flex items-center px-4 py-2 border border-gray-600 text-sm font-medium rounded-md text-gray-300 bg-gray-800 hover:bg-gray-700">
|
|
Previous
|
|
</a>
|
|
{% endif %}
|
|
{% if page < total_pages %}
|
|
<a href="{{ url_for('reports', encoder_type=encoder_type, page=page+1) }}" class="ml-3 relative inline-flex items-center px-4 py-2 border border-gray-600 text-sm font-medium rounded-md text-gray-300 bg-gray-800 hover:bg-gray-700">
|
|
Next
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
<div class="hidden sm:flex-1 sm:flex sm:items-center sm:justify-between">
|
|
<div>
|
|
<p class="text-sm text-gray-300">
|
|
Showing <span class="font-medium">{{ (page-1)*20 + 1 }}</span> to <span class="font-medium">{{ min(page*20, total) }}</span> of <span class="font-medium">{{ total }}</span> results
|
|
</p>
|
|
</div>
|
|
<div>
|
|
<nav class="relative z-0 inline-flex rounded-md shadow-sm -space-x-px">
|
|
{% if page > 1 %}
|
|
<a href="{{ url_for('reports', encoder_type=encoder_type, page=page-1) }}" class="relative inline-flex items-center px-2 py-2 rounded-l-md border border-gray-600 bg-gray-800 text-sm font-medium text-gray-300 hover:bg-gray-700">
|
|
<svg class="h-5 w-5" fill="currentColor" viewBox="0 0 20 20">
|
|
<path fill-rule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"/>
|
|
</svg>
|
|
</a>
|
|
{% endif %}
|
|
|
|
{% set start_page = max(1, page - 2) %}
|
|
{% set end_page = min(total_pages, page + 2) %}
|
|
|
|
{% for p in range(start_page, end_page + 1) %}
|
|
{% if p == page %}
|
|
<span class="relative inline-flex items-center px-4 py-2 border border-gray-600 bg-gray-600 text-sm font-medium text-white">
|
|
{{ p }}
|
|
</span>
|
|
{% else %}
|
|
<a href="{{ url_for('reports', encoder_type=encoder_type, page=p) }}" class="relative inline-flex items-center px-4 py-2 border border-gray-600 bg-gray-800 text-sm font-medium text-gray-300 hover:bg-gray-700">
|
|
{{ p }}
|
|
</a>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% if page < total_pages %}
|
|
<a href="{{ url_for('reports', encoder_type=encoder_type, page=page+1) }}" class="relative inline-flex items-center px-2 py-2 rounded-r-md border border-gray-600 bg-gray-800 text-sm font-medium text-gray-300 hover:bg-gray-700">
|
|
<svg class="h-5 w-5" fill="currentColor" viewBox="0 0 20 20">
|
|
<path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"/>
|
|
</svg>
|
|
</a>
|
|
{% endif %}
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% else %}
|
|
<div class="px-6 py-12 text-center">
|
|
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
|
|
</svg>
|
|
<h3 class="mt-2 text-sm font-medium text-gray-300">No reports found</h3>
|
|
<p class="mt-1 text-sm text-gray-400">No encoding jobs have been completed yet.</p>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function requeueJob(jobId) {
|
|
if (!confirm('Are you sure you want to requeue this job? It will be added back to the processing queue.')) {
|
|
return;
|
|
}
|
|
|
|
fetch(`/requeue/${jobId}`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
}
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showNotification('Job requeued successfully! It will be processed again.', 'success');
|
|
// Reload the page after a short delay
|
|
setTimeout(() => {
|
|
location.reload();
|
|
}, 2000);
|
|
} else {
|
|
showNotification('Failed to requeue job: ' + data.message, 'error');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
showNotification('An error occurred while requeuing the job.', 'error');
|
|
});
|
|
}
|
|
</script>
|
|
|
|
{% endblock %}
|