34 lines
3.3 KiB
Plaintext
34 lines
3.3 KiB
Plaintext
<%- include('partials/header', { title: 'Dashboard', activePage: 'dashboard' }) %>
|
|
<%
|
|
const overview = {
|
|
queued: ['Waiting', 'Ready for a worker'], processing: ['Active', 'Claimed downloads'],
|
|
done: ['Completed', 'Successful downloads'], failed: ['Failed attempts', 'Review attempt history']
|
|
};
|
|
const recentRows = typeof recent === 'object' && recent ? recent : { done: [], failed: [] };
|
|
%>
|
|
<div class="page-heading">
|
|
<div><p class="eyebrow">DOWNLOAD OVERVIEW</p><h1 class="page-title">Dashboard</h1><p class="page-description">Your workers, current downloads and latest results in one place.</p></div>
|
|
<div class="button-group"><button type="button" class="button button-secondary" id="dashboard-refresh">Refresh</button><a class="button button-primary" href="/download">New download <span aria-hidden="true">→</span></a></div>
|
|
</div>
|
|
<%- include('partials/active-downloads') %>
|
|
<nav class="queue-overview dashboard-overview" aria-label="Open queue or history">
|
|
<% Object.entries(overview).forEach(([state, info]) => { %>
|
|
<a class="queue-stat" href="/status?state=<%= state %>"><span class="queue-stat-label"><%= info[0] %></span><strong class="queue-stat-count" data-dashboard-count="<%= state %>"><%= counts[state].toLocaleString('en') %></strong><span class="queue-stat-note"><%= info[1] %> <span aria-hidden="true">↗</span></span></a>
|
|
<% }) %>
|
|
</nav>
|
|
<p class="dashboard-feedback field-hint" id="dashboard-feedback" role="status" aria-live="polite">Updates every 10 seconds while this page is visible.</p>
|
|
<div class="dashboard-history">
|
|
<% ['done', 'failed'].forEach(state => { %>
|
|
<section class="panel" aria-labelledby="recent-<%= state %>-title">
|
|
<div class="panel-header"><div><h2 id="recent-<%= state %>-title"><%= state === 'done' ? 'Recently completed' : 'Recent failed attempts' %></h2><p class="field-hint">Latest five records</p></div><a class="text-link" href="/status?state=<%= state %>">View history <span aria-hidden="true">↗</span></a></div>
|
|
<ul class="recent-list" id="recent-<%= state %>"><% recentRows[state].forEach(job => { const stamp = job[state === 'done' ? 'finished_at' : 'failed_at'] || job.created_at; %>
|
|
<li class="recent-job" data-recent-id="<%= job._id %>"><div class="recent-primary"><strong class="recent-name"><%= job.filename %></strong><time class="muted"<% if (stamp) { %> datetime="<%= stamp %>"<% } %>><%= stamp ? new Date(stamp).toLocaleString('en-GB', { dateStyle: 'medium', timeStyle: 'short' }) : 'Time not recorded' %></time></div><span class="badge <%= state === 'done' ? 'badge-success' : 'badge-danger' %>"><%= state === 'done' ? 'Completed' : job.error_category || 'Failed' %></span></li>
|
|
<% }) %></ul>
|
|
<div class="empty-state recent-empty" id="recent-<%= state %>-empty"<%- recentRows[state].length ? ' hidden' : '' %>><strong><%= state === 'done' ? 'No completed downloads yet' : 'No failed attempts recorded' %></strong><p><%= state === 'done' ? 'Completed episodes will appear here.' : 'Any failed attempts will appear here for review.' %></p></div>
|
|
<% if (state === 'failed') { %><p class="history-footnote field-hint">An earlier failed attempt may belong to an episode that later completed.</p><% } %>
|
|
</section>
|
|
<% }) %>
|
|
</div>
|
|
<script src="/dashboard.js" defer></script>
|
|
<%- include('partials/footer') %>
|