NDOJ/templates/test_formatter/download_test_formatter.html

83 lines
2.1 KiB
HTML
Raw Normal View History

2024-01-08 18:27:20 +00:00
{% extends 'base.html' %}
{% block media %}
<style>
.container {
width: 100%;
margin: auto;
}
.preview-container {
padding-bottom: 16px;
}
#preview {
background-color: rgb(220, 220, 220);
border: solid 2px rgb(180, 180, 180);
padding: 8px;
max-height: 134px;
height: 20%;
overflow-y: scroll;
}
.button-container {
text-align:left;
}
.button {
display:inline-block;
}
</style>
{% endblock %}
{% block js_media %}
<script>
$(document).ready(function(){
$("#download").on("click", function(event) {
event.preventDefault()
var file_path = document.getElementById('file_path').value;
$.ajax({
2024-01-08 19:06:18 +00:00
url: "{{url('test_formatter_download')}}",
2024-01-08 18:27:20 +00:00
type: 'POST',
data: {
file_path: file_path
},
xhrFields: {
responseType: 'blob'
},
success: function(data) {
var url = window.URL.createObjectURL(data);
var a = document.createElement('a');
a.href = url;
a.download = file_path.split('/').pop();
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
},
error: function(error) {
alert(error);
console.log(error.message)
}
})
});
});
</script>
{% endblock %}
{% block body %}
<div class="container">
<input type="hidden" id="file_path" value={{file_path}}>
<input type="hidden" id="file_path_getnames" value={{file_path_getnames}}>
<div class="preview-container">
<h2>{{_('Download')}}</h2><br>
<h4>{{file_name}}</h4><br>
<div id="preview">
{{ response|safe }}
</div>
</div>
<div class="button-container">
<button type="submit" id="download" class="button">{{_('Download')}}</button>
2024-01-08 19:06:18 +00:00
<a href="{{url('test_formatter_edit')}}?file_path={{file_path_getnames}}" id="edit" class="button">{{_('Edit')}}</a>
2024-01-08 18:27:20 +00:00
</div>
</div>
{% endblock %}