|
|
|
@ -107,8 +107,17 @@
|
|
|
|
|
<span aria-hidden="true"><i class="fa fa-times"/></span>
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-10">
|
|
|
|
|
<div th:text="*{files[__${rowStat.index}__].name}"></div>
|
|
|
|
|
<div class="col-10" th:if="${file.id==null}">
|
|
|
|
|
<a th:onclick="|downloadFile('${file.tmpFileName}',null,'${file.name}') |"
|
|
|
|
|
href="javascript:void(0)"
|
|
|
|
|
th:text="*{files[__${rowStat.index}__].name}">
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-10" th:unless="${file.id==null}">
|
|
|
|
|
<a th:onclick="|downloadFile(null,${file.id},'${file.name}') |"
|
|
|
|
|
href="javascript:void(0)"
|
|
|
|
|
th:text="*{files[__${rowStat.index}__].name}">
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</th:block>
|
|
|
|
@ -251,12 +260,43 @@
|
|
|
|
|
|
|
|
|
|
var nameDiv = $("<div/>")
|
|
|
|
|
.addClass("col-10")
|
|
|
|
|
.append($("<div/>").text(fileNames[1]));
|
|
|
|
|
.append($("<a/>").text(fileNames[1])
|
|
|
|
|
.attr("href", 'javascript:void(0)')
|
|
|
|
|
.attr("onclick", "downloadFile('" + fileNames[0] + "',null,'" + fileNames[1] + "')"));
|
|
|
|
|
newFileRow.append(nameDiv);
|
|
|
|
|
|
|
|
|
|
$("#files-list").append(newFileRow);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function downloadFile(tmpName, fileId, downloadName) {
|
|
|
|
|
let xhr = new XMLHttpRequest();
|
|
|
|
|
if (fileId != null) xhr.open('GET', urlFileDownload + fileId);
|
|
|
|
|
if (tmpName != null) xhr.open('GET', urlFileDownloadTmp + tmpName);
|
|
|
|
|
xhr.responseType = 'blob';
|
|
|
|
|
|
|
|
|
|
var formData = new FormData();
|
|
|
|
|
if (fileId != null) formData.append("file-id", fileId);
|
|
|
|
|
if (tmpName != null) formData.append("tmp-file-name", tmpName);
|
|
|
|
|
|
|
|
|
|
xhr.send(formData);
|
|
|
|
|
|
|
|
|
|
xhr.onload = function () {
|
|
|
|
|
if (this.status == 200) {
|
|
|
|
|
console.debug(this.response);
|
|
|
|
|
var blob = new Blob([this.response], {type: '*'});
|
|
|
|
|
let a = document.createElement("a");
|
|
|
|
|
a.style = "display: none";
|
|
|
|
|
document.body.appendChild(a);
|
|
|
|
|
let url = window.URL.createObjectURL(blob);
|
|
|
|
|
a.href = url;
|
|
|
|
|
a.download = downloadName;
|
|
|
|
|
a.click();
|
|
|
|
|
window.URL.revokeObjectURL(url);
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|