Skip to content

Commit 88a30f7

Browse files
author
Datanoise
committed
feat: implement perfectly smooth progress bars and non-blocking library additions
1 parent 4c3a87f commit 88a30f7

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

server/templates/admin.html

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,6 @@ <h2>Edit AutoDJ</h2>
738738
text.textContent = 'Processing...';
739739
lucide.createIcons();
740740

741-
// For actions that take longer than 2 seconds, update the text
742741
const longActionTimeout = setTimeout(() => {
743742
if (form.dataset.submitting === 'true') {
744743
text.textContent = 'Still working...';
@@ -797,10 +796,10 @@ <h2>Edit AutoDJ</h2>
797796

798797
function updateAutoDJProgress() {
799798
const bars = document.querySelectorAll('.progress-bar-adj');
800-
const now = Math.floor(Date.now() / 1000);
799+
const now = Date.now() / 1000;
801800

802801
bars.forEach(bar => {
803-
const startTime = parseInt(bar.dataset.start);
802+
const startTime = parseFloat(bar.dataset.start);
804803
const duration = parseFloat(bar.dataset.duration);
805804
const card = bar.closest('.card');
806805

@@ -816,15 +815,14 @@ <h2>Edit AutoDJ</h2>
816815
if (progressBox) progressBox.style.opacity = '1';
817816

818817
const elapsed = Math.max(0, now - startTime);
819-
// Cap at 100% to prevent the 5:23/3:00 issue before SSE syncs
820818
const progress = Math.min(100, (elapsed / duration) * 100);
821819
bar.style.width = progress + '%';
822820

823821
const currentEl = card.querySelector('.progress-time-current');
824822
const totalEl = card.querySelector('.progress-time-total');
825823

826824
if (currentEl) {
827-
const displayElapsed = Math.min(elapsed, Math.floor(duration));
825+
const displayElapsed = Math.max(0, Math.min(elapsed, duration));
828826
const m = Math.floor(displayElapsed / 60).toString().padStart(2, '0');
829827
const s = Math.floor(displayElapsed % 60).toString().padStart(2, '0');
830828
currentEl.textContent = `${m}:${s}`;
@@ -836,7 +834,7 @@ <h2>Edit AutoDJ</h2>
836834
}
837835
});
838836
}
839-
setInterval(updateAutoDJProgress, 1000);
837+
setInterval(updateAutoDJProgress, 50);
840838

841839
function showEditAutoDJ(data) {
842840
document.getElementById('edit-old-mount').value = data.Mount;
@@ -917,7 +915,7 @@ <h2>Edit AutoDJ</h2>
917915
<input type="hidden" name="path" value="${e.abs_path}">
918916
<button type="submit" class="btn btn-outline btn-sm" style="padding:0.1rem 0.3rem; font-size:0.7rem;" title="Queue Next">QUEUE</button>
919917
</form>` : ''}
920-
<form action="${actionURL}" method="POST" onsubmit="${confirmMsg ? `if(confirm('${confirmMsg}')) ` : ''}return submitForm(event, true)" style="margin:0;">
918+
<form action="${actionURL}" method="POST" onsubmit="${confirmMsg ? `if(confirm('${confirmMsg}')) ` : ''}return submitForm(event, e.is_dir, true)" style="margin:0;">
921919
<input type="hidden" name="csrf" value="${csrfToken}">
922920
<input type="hidden" name="mount" value="${mount}">
923921
<input type="hidden" name="action" value="add">

0 commit comments

Comments
 (0)