diff --git a/src/main/resources/templates/grants/fragments/grantFilesListFragment.html b/src/main/resources/templates/grants/fragments/grantFilesListFragment.html
new file mode 100644
index 0000000..2547c80
--- /dev/null
+++ b/src/main/resources/templates/grants/fragments/grantFilesListFragment.html
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/templates/grants/grant.html b/src/main/resources/templates/grants/grant.html
index 9c0736d..d33015c 100644
--- a/src/main/resources/templates/grants/grant.html
+++ b/src/main/resources/templates/grants/grant.html
@@ -61,7 +61,7 @@
@@ -77,12 +77,14 @@
-
*/
+ function addNewFile(fileDto) {
+ var fileNumber = $("#files-list div.row").length;
+ var newFileRow = $("
")
+ .attr("id", 'files' + fileNumber)
+ .addClass("row div-row-file");
+ var idInput = $(" ")
+ .attr("type", "hidden")
+ .attr("id", "files" + fileNumber + ".id")
+ .attr("value", '')
+ .attr("name", "files[" + fileNumber + "].id");
+ newFileRow.append(idInput);
+ var flagInput = $(" ")
+ .attr("type", "hidden")
+ .attr("id", "files" + fileNumber + ".deleted")
+ .attr("value", "false")
+ .attr("name", "files[" + fileNumber + "].deleted");
+ newFileRow.append(flagInput);
+ var nameInput = $(" ")
+ .attr("type", "hidden")
+ .attr("id", "files" + fileNumber + ".name")
+ .attr("value", fileDto.fileName)
+ .attr("name", "files[" + fileNumber + "].name");
+ newFileRow.append(nameInput);
+
+ var tmpFileNameInput = $(" ")
+ .attr("type", "hidden")
+ .attr("id", "files" + fileNumber + ".tmpFileName")
+ .attr("value", fileDto.tmpFileName)
+ .attr("name", "files[" + fileNumber + "].tmpFileName");
+ newFileRow.append(tmpFileNameInput);
+
+ var nameDiv = $("
")
+ .addClass("col-10 div-file-name")
+ .append($(" ").text(fileDto.fileName)
+ .attr("href", 'javascript:void(0)')
+ .attr("onclick", "downloadFile('" + fileDto.tmpFileName + "',null,'" + fileDto.fileName + "')"));
+ newFileRow.append(nameDiv);
+
+ var nextDiv = $("
")
+ .addClass("col-2");
+
+ var nextA = $(" ")
+ .addClass("btn btn-danger float-right")
+ .attr("onclick", "$('#files" + fileNumber + "\\\\.deleted').val('true'); $('#files" + fileNumber + "').hide();")
+ .append(($(" ").attr("aria-hidden", "true")).append($(" ").addClass("fa fa-times")))
+ ;
+ nextDiv.append(nextA)
+ newFileRow.append(nextDiv);
+ $("#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 {
+ }
+ }
+ }
-
-