Files
encoder/templates/reports.html
T
2025-07-08 19:25:16 +00:00

185 lines
12 KiB
HTML

{% extends "base.html" %}
{% block title %}{{ encoder_type.title() }} Reports - Encoder{% endblock %}
{% block content %}
<div class="px-4 sm:px-0">
<div class="mb-8">
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-white mb-2">{{ encoder_type.title() }} Encoder Reports</h1>
<p class="text-gray-300">Job history and statistics for {{ encoder_type }} encoding</p>
</div>
<a href="{{ url_for('index') }}" class="bg-gray-700 hover:bg-gray-600 text-white px-4 py-2 rounded-lg text-sm">
← Back to Dashboard
</a>
</div>
</div>
<div class="bg-gray-800 rounded-lg shadow-lg overflow-hidden">
<div class="px-6 py-4 border-b border-gray-700">
<h2 class="text-lg font-semibold text-white">Job Reports</h2>
<p class="text-sm text-gray-400">Total: {{ total }} jobs</p>
</div>
{% if reports %}
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-700">
<thead class="bg-gray-700">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">File</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Status</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Original Size</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Encoded Size</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Space Saved</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Format</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Processing Time</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Date</th>
</tr>
</thead>
<tbody class="bg-gray-800 divide-y divide-gray-700">
{% for report in reports %}
<tr class="hover:bg-gray-700">
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-white">{{ 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-medium 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-medium 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>
{% else %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium 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-sm text-gray-300">
{{ report.original_size|format_bytes }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300">
{{ report.encoded_size|format_bytes }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">
{% if report.size_saved > 0 %}
<span class="text-green-400">{{ report.size_saved|format_bytes }}</span>
{% elif report.size_saved < 0 %}
<span class="text-red-400">{{ report.size_saved|format_bytes }}</span>
{% else %}
<span class="text-gray-400">{{ report.size_saved|format_bytes }}</span>
{% endif %}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm 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-sm text-gray-300">
{{ report.processing_time|format_duration }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm 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>
</tr>
{% if report.status == 'failed' and report.error_message %}
<tr class="bg-red-900 bg-opacity-20">
<td colspan="8" class="px-6 py-2">
<div class="text-sm text-red-300">
<span class="font-medium">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-blue-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>
{% endblock %}