Allow simultaneous exports
This commit is contained in:
parent
c93503e50e
commit
291cdf8e7b
2 changed files with 45 additions and 9 deletions
|
@ -40,8 +40,14 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal"></div>
|
||||
|
||||
<div class="py-5">
|
||||
<div class="container">
|
||||
<div class="row" id="cards"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal"></div>
|
||||
|
||||
<script src="jquery-3.3.1.min.js"></script>
|
||||
<script src="bootstrap.min.js"></script>
|
||||
|
|
|
@ -16,6 +16,34 @@ function unlockform() {
|
|||
$body.removeClass("loading");
|
||||
}
|
||||
|
||||
function deletecard(jobid) {
|
||||
if ( $("#" + jobid).length ) {
|
||||
$("#" + jobid).remove();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function addcard(jobid) {
|
||||
var text = '<div class="col-sm-3" id="' + jobid + '"> <div class="card"> <img class="card-img-top img-fluid" src="/spinner.gif" alt="Creating Image"> </div> </div>';
|
||||
$('#cards').append(text);
|
||||
$('#' + jobid).show();
|
||||
}
|
||||
|
||||
function failcard(jobid) {
|
||||
deletecard(jobid);
|
||||
|
||||
var text = '<div class="col-sm-3" id="' + jobid + '"> <div class="card"> <div style="text-align: center; color: red; font-weight: bold;" class="card-block">Export failed.</div><div style="text-align: center;" class="card-block"> <a style="color: white;" onclick="deletecard(\'' + jobid + '\');" class="btn btn-danger">Hide</a></div> </div> </div>';
|
||||
$('#cards').append(text);
|
||||
}
|
||||
|
||||
|
||||
function finishcard(jobid) {
|
||||
deletecard(jobid);
|
||||
|
||||
var text = '<div class="col-sm-3" id="' + jobid + '"> <div class="card"> <img class="card-img-top img-fluid" src="/getjob/' + jobid + '" alt="Final Image"> <div style="text-align: center; color: white;" class="card-block"> <a href="/getjob/' + jobid + '" class="btn btn-primary">Download</a> <a onclick="deletecard(\'' + jobid + '\');" class="btn btn-danger">Hide</a></div> </div> </div>';
|
||||
$('#cards').append(text);
|
||||
}
|
||||
|
||||
$('#theform').submit(function(event){
|
||||
event.preventDefault();
|
||||
if(this.checkValidity()) {
|
||||
|
@ -24,9 +52,10 @@ $('#theform').submit(function(event){
|
|||
url: "/addjob",
|
||||
data: $('#theform').serialize(),
|
||||
success: function(msg){
|
||||
lockform();
|
||||
interval = setInterval(checkServerForFile,3000,msg);
|
||||
var interval = setInterval(checkServerForFile,3000,msg);
|
||||
window.panaxworking = false;
|
||||
addcard(msg);
|
||||
|
||||
function checkServerForFile(jobid) {
|
||||
if (!window.panaxworking) {
|
||||
window.panaxworking = true;
|
||||
|
@ -37,17 +66,18 @@ $('#theform').submit(function(event){
|
|||
statusCode: {
|
||||
404: function() {
|
||||
clearInterval(interval);
|
||||
unlockform();
|
||||
failcard(jobid);
|
||||
return;
|
||||
},
|
||||
200: function() {
|
||||
clearInterval(interval);
|
||||
unlockform();
|
||||
window.location.href = "/getjob/" + jobid;
|
||||
finishcard(jobid);
|
||||
return;
|
||||
},
|
||||
500: function() {
|
||||
clearInterval(interval);
|
||||
window.alert("Failed to process request. The URL may be incorrect or unsupported.")
|
||||
unlockform();
|
||||
failcard(jobid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue