2
0

Moved update interval for task-progress to own interval, progress gets continually updated.

This commit is contained in:
glax 2023-06-09 23:58:04 +02:00
parent b3321ff030
commit 2aec884009

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,33 +360,31 @@ function FilterResults(){
} }
function ShowTasksQueue(){ function ShowTasksQueue(){
downloadTasksPopup.style.display = "flex";
var outputDom = downloadTasksPopup.querySelector("popup-content");
outputDom.replaceChildren();
GetRunningTasks().then((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()
json.forEach(task => { .then(json => {
if(task.chapter != undefined){ tagTasksRunning.innerText = json.length;
document.querySelector(`#progress${task.publication.internalId}-${task.chapter.sortNumber}`).value = task.progress; json.forEach(task => {
document.querySelector(`#progressStr${task.publication.internalId}-${task.chapter.sortNumber}`).innerText = task.progress.toLocaleString(undefined,{style: 'percent', minimumFractionDigits:2}); downloadTasksOutput.appendChild(CreateProgressChild(task));
}else{ });
document.querySelector(`#progress${task.publication.internalId}`).value = task.progress; if(task.chapter != undefined){
document.querySelector(`#progressStr${task.publication.internalId}`).innerText = task.progress.toLocaleString(undefined,{style: 'percent', minimumFractionDigits:2}); 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);
GetQueue()
.then(json => {
tagTasksQueued.innerText = json.length;
json.forEach(task => {
downloadTasksOutput.appendChild(CreateProgressChild(task));
});
});
downloadTasksPopup.style.display = "flex";
} }
function CreateProgressChild(task){ function CreateProgressChild(task){
@ -433,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 => {
@ -445,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(() => {
@ -482,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);