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