mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 02:44:18 +00:00
Add progress bar for file upload.
This commit is contained in:
parent
22a1223258
commit
9005c583ca
30
app/static/js/opaque.js
Normal file
30
app/static/js/opaque.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
function sendNewJobFormData(form, progress) {
|
||||||
|
var XHR = new XMLHttpRequest();
|
||||||
|
var FD = new FormData(form);
|
||||||
|
XHR.upload.addEventListener("progress", function(event) {
|
||||||
|
progress.querySelector(".determinate").style.width = ((event.loaded / event.total) * 100).toString() + "%";
|
||||||
|
});
|
||||||
|
XHR.addEventListener("loadend", function(event) {
|
||||||
|
form.reset();
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
XHR.open("POST", window.location.href);
|
||||||
|
XHR.send(FD);
|
||||||
|
}
|
||||||
|
function initNewJobForm(newJobFormElement) {
|
||||||
|
newJobFormElement.addEventListener("submit", function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
var toast = M.toast(
|
||||||
|
{html: `<div class="row">
|
||||||
|
<div class="col s12">${this.title.value}</div>
|
||||||
|
<div class="col s12">
|
||||||
|
<div class="progress">
|
||||||
|
<div class="determinate" style="width: 0%"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>`,
|
||||||
|
displayLength: Infinity}
|
||||||
|
);
|
||||||
|
sendNewJobFormData(this, toast.el.querySelector(".progress"));
|
||||||
|
});
|
||||||
|
}
|
@ -12,6 +12,7 @@
|
|||||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/materialize.min.css') }}" media="screen,projection"/>
|
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/materialize.min.css') }}" media="screen,projection"/>
|
||||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/opaque.css') }}" media="screen,projection"/>
|
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/opaque.css') }}" media="screen,projection"/>
|
||||||
<script src="{{ url_for('static', filename='js/Animations.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/Animations.js') }}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/opaque.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/jsonpatch.min.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/jsonpatch.min.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/socket.io.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/socket.io.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/list.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/list.js') }}"></script>
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<form method="POST" enctype="multipart/form-data">
|
<form method="POST" enctype="multipart/form-data" id="new-nlp-job-form">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
{{ new_nlp_job_form.hidden_tag() }}
|
{{ new_nlp_job_form.hidden_tag() }}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -121,4 +121,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
initNewJobForm(document.getElementById("new-nlp-job-form"));
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
|
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<form method="POST" enctype="multipart/form-data">
|
<form method="POST" enctype="multipart/form-data" id="new-ocr-job-form">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
{{ new_ocr_job_form.hidden_tag() }}
|
{{ new_ocr_job_form.hidden_tag() }}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -138,4 +138,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
initNewJobForm(document.getElementById("new-ocr-job-form"));
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user