Fix result addition

This commit is contained in:
Patrick Jentsch 2020-02-03 15:58:46 +01:00
parent 6b77fdaa37
commit 14cf2c55f9

View File

@ -206,7 +206,7 @@
switch(operation.op) { switch(operation.op) {
case "add": case "add":
if (pathArray[1] === "results") { if (pathArray[1] === "results") {
this.setResult(operation.value); this.setResults([operation.value]);
} }
break; break;
case "delete": case "delete":
@ -238,30 +238,20 @@
} }
setResults(results) { setResults(results) {
let resultElement, resultsElement, resultDownloadElement, let resultsElement;
resultDownloadButtonElement, resultDownloadButtonIconElement,
resultTitleElement;
resultsElement = document.getElementById("results"); resultsElement = document.getElementById("results");
for (let result of results) { for (let result of results) {
resultElement = document.createElement("tr"); resultsElement.insertAdjacentHTML("beforeend", `
resultTitleElement = document.createElement("td"); <tr>
resultTitleElement.innerText = result.filename; <td>${result.filename}</td>
resultElement.append(resultTitleElement); <td>
resultDownloadElement = document.createElement("td"); <a class="btn-small waves-effect waves-light" download href="/jobs/${result.job_id}/results/${result.id}/download">
resultDownloadButtonElement = document.createElement("a"); <i class="material-icons">file_download</i>
resultDownloadButtonElement.classList.add("waves-effect", "waves-light", </a>
"btn-small"); </td>
resultDownloadButtonElement.href = `/jobs/${result.job_id}/results/${result.id}/download`; </tr>`);
resultDownloadButtonElement.setAttribute("download", "");
resultDownloadButtonIconElement = document.createElement("i");
resultDownloadButtonIconElement.classList.add("material-icons");
resultDownloadButtonIconElement.innerText = "file_download";
resultDownloadButtonElement.append(resultDownloadButtonIconElement);
resultDownloadElement.append(resultDownloadButtonElement)
resultElement.append(resultDownloadElement);
resultsElement.append(resultElement);
} }
} }