207 lines
6.2 KiB
Plaintext
207 lines
6.2 KiB
Plaintext
<%- include("partials/header") %>
|
|
|
|
<div class="row">
|
|
<!-- ======================= -->
|
|
<!-- QUEUED -->
|
|
<!-- ======================= -->
|
|
<div class="col-md-3">
|
|
<h3>Queued</h3>
|
|
<ul class="list-group" id="queuedList">
|
|
<% queued.forEach(job => { %>
|
|
<li class="list-group-item">
|
|
<strong><%= job.filename %></strong><br />
|
|
<small><%= job.url %></small><br />
|
|
<small><%= new Date(job.created_at).toLocaleString() %></small>
|
|
</li>
|
|
<% }) %> <% if (queued.length === 0) { %>
|
|
<li class="list-group-item">No queued jobs</li>
|
|
<% } %>
|
|
</ul>
|
|
</div>
|
|
|
|
<!-- ======================= -->
|
|
<!-- PROCESSING -->
|
|
<!-- ======================= -->
|
|
<div class="col-md-3">
|
|
<h3 style="color: #58a6ff">Processing</h3>
|
|
<ul class="list-group" id="processingList">
|
|
<% processing.forEach(job => { %>
|
|
<li class="list-group-item">
|
|
<strong style="color: #58a6ff"><%= job.filename %></strong>
|
|
<span
|
|
class="spinner-border spinner-border-sm ms-2"
|
|
style="color: #58a6ff"
|
|
></span>
|
|
<br />
|
|
<small><%= job.url %></small><br />
|
|
<small>Started: <%= new Date(job.created_at).toLocaleString() %></small>
|
|
|
|
<% if (job.output_log) { %>
|
|
<details class="mt-2">
|
|
<summary class="text-light">Live Log</summary>
|
|
<pre
|
|
style="
|
|
background: #001122;
|
|
color: #9cf;
|
|
padding: 10px;
|
|
border-radius: 5px;
|
|
white-space: pre-wrap;
|
|
"
|
|
>
|
|
<%= job.output_log %>
|
|
</pre
|
|
>
|
|
</details>
|
|
<% } %>
|
|
</li>
|
|
<% }) %> <% if (processing.length === 0) { %>
|
|
<li class="list-group-item">Nothing processing</li>
|
|
<% } %>
|
|
</ul>
|
|
</div>
|
|
|
|
<!-- ======================= -->
|
|
<!-- DONE -->
|
|
<!-- ======================= -->
|
|
<div class="col-md-3">
|
|
<h3 class="text-success">Done</h3>
|
|
<ul class="list-group" id="doneList">
|
|
<% finished.forEach(job => { %>
|
|
<li class="list-group-item">
|
|
<strong class="text-success"><%= job.filename %></strong><br />
|
|
<small><%= new Date(job.finished_at).toLocaleString() %></small><br />
|
|
|
|
<% if (job.output_log) { %>
|
|
<details class="mt-2">
|
|
<summary class="text-light">Show Log</summary>
|
|
<pre
|
|
style="
|
|
background: #222;
|
|
color: #e0e0e0;
|
|
padding: 10px;
|
|
border-radius: 5px;
|
|
white-space: pre-wrap;
|
|
"
|
|
>
|
|
<%= job.output_log %>
|
|
</pre
|
|
>
|
|
</details>
|
|
<% } %>
|
|
</li>
|
|
<% }) %> <% if (finished.length === 0) { %>
|
|
<li class="list-group-item">No completed jobs</li>
|
|
<% } %>
|
|
</ul>
|
|
</div>
|
|
|
|
<!-- ======================= -->
|
|
<!-- FAILED -->
|
|
<!-- ======================= -->
|
|
<div class="col-md-3">
|
|
<h3 class="text-danger">Failed</h3>
|
|
<ul class="list-group" id="failedList">
|
|
<% failed.forEach(job => { %>
|
|
<li class="list-group-item">
|
|
<strong class="text-danger"><%= job.filename %></strong><br />
|
|
<small><%= new Date(job.failed_at).toLocaleString() %></small><br />
|
|
|
|
<% if (job.output_log) { %>
|
|
<details class="mt-2">
|
|
<summary class="text-danger">Show Error Log</summary>
|
|
<pre
|
|
style="
|
|
background: #330000;
|
|
color: #ffb3b3;
|
|
padding: 10px;
|
|
border-radius: 5px;
|
|
white-space: pre-wrap;
|
|
"
|
|
>
|
|
<%= job.output_log %>
|
|
</pre
|
|
>
|
|
</details>
|
|
<% } %>
|
|
</li>
|
|
<% }) %> <% if (failed.length === 0) { %>
|
|
<li class="list-group-item">No failed jobs</li>
|
|
<% } %>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ======================= -->
|
|
<!-- AUTO-REFRESH SCRIPT -->
|
|
<!-- ======================= -->
|
|
<script>
|
|
async function refreshStatus() {
|
|
try {
|
|
const res = await fetch("/status-data");
|
|
const data = await res.json();
|
|
|
|
// Helper for templates
|
|
function renderQueued(job) {
|
|
return `
|
|
<li class="list-group-item">
|
|
<strong>${job.filename}</strong><br>
|
|
<small>${job.url}</small><br>
|
|
<small>${new Date(job.created_at).toLocaleString()}</small>
|
|
</li>`;
|
|
}
|
|
|
|
function renderProcessing(job) {
|
|
return `
|
|
<li class="list-group-item">
|
|
<strong style="color:#58a6ff">${job.filename}</strong>
|
|
<span class="spinner-border spinner-border-sm ms-2" style="color:#58a6ff"></span><br>
|
|
<small>${job.url}</small><br>
|
|
<small>Started: ${new Date(job.created_at).toLocaleString()}</small><br>
|
|
<small>Downloaded: ${formatBytes(job.fileSize)}</small>
|
|
</li>`;
|
|
}
|
|
|
|
function renderDone(job) {
|
|
return `
|
|
<li class="list-group-item">
|
|
<strong class="text-success">${job.filename}</strong><br>
|
|
<small>${new Date(job.finished_at).toLocaleString()}</small>
|
|
</li>`;
|
|
}
|
|
|
|
function renderFailed(job) {
|
|
return `
|
|
<li class="list-group-item">
|
|
<strong class="text-danger">${job.filename}</strong><br>
|
|
<small>${new Date(job.failed_at).toLocaleString()}</small>
|
|
</li>`;
|
|
}
|
|
|
|
// Update UI lists
|
|
document.getElementById("queuedList").innerHTML = data.queued.length
|
|
? data.queued.map(renderQueued).join("")
|
|
: `<li class="list-group-item ">No queued jobs</li>`;
|
|
|
|
document.getElementById("processingList").innerHTML = data.processing
|
|
.length
|
|
? data.processing.map(renderProcessing).join("")
|
|
: `<li class="list-group-item ">Nothing processing</li>`;
|
|
|
|
document.getElementById("doneList").innerHTML = data.done.length
|
|
? data.done.map(renderDone).join("")
|
|
: `<li class="list-group-item ">No completed jobs</li>`;
|
|
|
|
document.getElementById("failedList").innerHTML = data.failed.length
|
|
? data.failed.map(renderFailed).join("")
|
|
: `<li class="list-group-item ">No failed jobs</li>`;
|
|
} catch (err) {
|
|
console.error("Status refresh error:", err);
|
|
}
|
|
}
|
|
|
|
// Auto-refresh every 3 seconds
|
|
setInterval(refreshStatus, 3000);
|
|
</script>
|
|
|
|
<%- include("partials/footer") %>
|