Compare commits

...

2 Commits

View File

@ -40,6 +40,7 @@ const settingApiUri = document.querySelector("#settingApiUri");
const tagTasksRunning = document.querySelector("#tasksRunningTag"); const tagTasksRunning = document.querySelector("#tasksRunningTag");
const tagTasksQueued = document.querySelector("#tasksQueuedTag"); const tagTasksQueued = document.querySelector("#tasksQueuedTag");
const downloadTasksPopup = document.querySelector("#downloadTasksPopup"); const downloadTasksPopup = document.querySelector("#downloadTasksPopup");
const downloadTasksOutput = downloadTasksPopup.querySelector("popup-content");
searchbox.addEventListener("keyup", (event) => FilterResults()); searchbox.addEventListener("keyup", (event) => FilterResults());
settingsCog.addEventListener("click", () => OpenSettings()); settingsCog.addEventListener("click", () => OpenSettings());
@ -359,24 +360,14 @@ function FilterResults(){
} }
function ShowTasksQueue(){ function ShowTasksQueue(){
downloadTasksPopup.style.display = "flex";
var outputDom = downloadTasksPopup.querySelector("popup-content");
outputDom.replaceChildren();
GetRunningTasks().then((taskJson) => {
console.log(taskJson);
taskJson.forEach(task => {
outputDom.appendChild(CreateProgressChild(task));
});
});
GetQueue().then((taskJson) => {
taskJson.forEach(task => {
outputDom.appendChild(CreateProgressChild(task));
});
});
setInterval(() => { downloadTasksOutput.replaceChildren();
GetRunningTasks().then((json) => { GetRunningTasks()
.then(json => {
tagTasksRunning.innerText = json.length;
json.forEach(task => { json.forEach(task => {
downloadTasksOutput.appendChild(CreateProgressChild(task));
});
if(task.chapter != undefined){ if(task.chapter != undefined){
document.querySelector(`#progress${task.publication.internalId}-${task.chapter.sortNumber}`).value = task.progress; document.querySelector(`#progress${task.publication.internalId}-${task.chapter.sortNumber}`).value = task.progress;
document.querySelector(`#progressStr${task.publication.internalId}-${task.chapter.sortNumber}`).innerText = task.progress.toLocaleString(undefined,{style: 'percent', minimumFractionDigits:2}); document.querySelector(`#progressStr${task.publication.internalId}-${task.chapter.sortNumber}`).innerText = task.progress.toLocaleString(undefined,{style: 'percent', minimumFractionDigits:2});
@ -385,8 +376,15 @@ function ShowTasksQueue(){
document.querySelector(`#progressStr${task.publication.internalId}`).innerText = task.progress.toLocaleString(undefined,{style: 'percent', minimumFractionDigits:2}); document.querySelector(`#progressStr${task.publication.internalId}`).innerText = task.progress.toLocaleString(undefined,{style: 'percent', minimumFractionDigits:2});
} }
}); });
GetQueue()
.then(json => {
tagTasksQueued.innerText = json.length;
json.forEach(task => {
downloadTasksOutput.appendChild(CreateProgressChild(task));
}); });
},500); });
downloadTasksPopup.style.display = "flex";
} }
function CreateProgressChild(task){ function CreateProgressChild(task){
@ -434,6 +432,7 @@ function CreateProgressChild(task){
//Resets the tasks shown //Resets the tasks shown
ResetContent(); ResetContent();
downloadTasksOutput.replaceChildren();
//Get Tasks and show them //Get Tasks and show them
GetDownloadTasks() GetDownloadTasks()
.then(json => json.forEach(task => { .then(json => json.forEach(task => {
@ -446,11 +445,17 @@ GetDownloadTasks()
GetRunningTasks() GetRunningTasks()
.then(json => { .then(json => {
tagTasksRunning.innerText = json.length; tagTasksRunning.innerText = json.length;
json.forEach(task => {
downloadTasksOutput.appendChild(CreateProgressChild(task));
});
}); });
GetQueue() GetQueue()
.then(json => { .then(json => {
tagTasksQueued.innerText = json.length; tagTasksQueued.innerText = json.length;
json.forEach(task => {
downloadTasksOutput.appendChild(CreateProgressChild(task));
});
}) })
setInterval(() => { setInterval(() => {
@ -483,6 +488,19 @@ setInterval(() => {
GetQueue() GetQueue()
.then(json => { .then(json => {
tagTasksQueued.innerText = json.length; tagTasksQueued.innerText = json.length;
}) });
}, 1000); }, 1000);
setInterval(() => {
GetRunningTasks().then((json) => {
json.forEach(task => {
if(task.chapter != undefined){
document.querySelector(`#progress${task.publication.internalId}-${task.chapter.sortNumber}`).value = task.progress;
document.querySelector(`#progressStr${task.publication.internalId}-${task.chapter.sortNumber}`).innerText = task.progress.toLocaleString(undefined,{style: 'percent', minimumFractionDigits:2});
}else{
document.querySelector(`#progress${task.publication.internalId}`).value = task.progress;
document.querySelector(`#progressStr${task.publication.internalId}`).innerText = task.progress.toLocaleString(undefined,{style: 'percent', minimumFractionDigits:2});
}
});
});
},500);