From 1dd365537e8f310bd3e2e9502c6b120d5358c889 Mon Sep 17 00:00:00 2001 From: cglatot Date: Thu, 25 Jun 2020 15:24:25 +0100 Subject: fixed progress bug --- js/main.js | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/js/main.js b/js/main.js index 47f0326..383d864 100644 --- a/js/main.js +++ b/js/main.js @@ -643,8 +643,18 @@ async function setAudioStream(partsId, streamId, row) { } } + // Set the progress bar to have a certain length + maxProgress = episodeList.length; + $('#progressBar').attr('aria-valuemax', maxProgress); // We have the episodes in episodeList, now we need to go through each one and see what streams are available for (let i = 0; i < episodeList.length; i++) { + // Update the progressbar + currentProgress++; + const calculatedWidth = (currentProgress / maxProgress) * 100; + console.log(calculatedWidth); + $('#progressBar').width(`${calculatedWidth}%`); + $('#progressBar').attr('aria-valuenow', currentProgress); + let episodeData = await $.ajax({ "url": `${plexUrl}/library/metadata/${episodeList[i]}`, "method": "GET", @@ -799,9 +809,11 @@ async function setAudioStream(partsId, streamId, row) { } } - // Update the progress bar + // Reset the progress bar and modal text + $("#modalBodyText #modalTitleText").text("Updating matches... Please do not close this tab or refresh until the process is complete."); maxProgress = promiseConstructors.length; $('#progressBar').attr('aria-valuemax', maxProgress); + $('#progressBar').attr('aria-valuenow', 0); function futurePromise(data) { return axios({ @@ -834,7 +846,7 @@ async function setAudioStream(partsId, streamId, row) { try { Promise.allSettled(matchPromises).then(() => { $('#modalBodyText .alert').removeClass("alert-warning").addClass("alert-success"); - $("#modalBodyText #modalTitleText").text("Processing Complete!"); + $("#modalBodyText #modalTitleText").text("Processing Complete! You can now close this popup."); $('#modalBodyText #progressBarContainer').hide(); }); } @@ -879,9 +891,9 @@ async function setSubtitleStream(partsId, streamId, row) { $('#progressModal #modalBodyText').empty(); $('#progressModal #modalBodyText').append(`