Jonathan Druart
5e51279ce9
From comment 0 """ Moving marc batch import actions to background jobs has introduced some confusing clicks to the process. Before this change, after staging a batch one was taken to a "MARC staging results" page with details of how the staging went and, most importantly, a link straight to the batch you'd just staged (at manage-marc-import.pl?import_batch_id). Now, however, one must click the status bar to get to details of the job and then click "View batch" from there. Not only is that an extra click and page load, but neither of those links are particularly large or obvious. """ Test plan: - Stage a record for import, notice that the "View batch" link appears when the job is finished - Add order to basket from a new file, select a file and import Notice that the "Add staged files to basket" link is displayed when the job is finished Note for QA: We should have a js_callback in the background_job include file instead. Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
35 lines
1.6 KiB
JavaScript
35 lines
1.6 KiB
JavaScript
function updateProgress(job_id, callback) {
|
|
$.getJSON('/api/v1/jobs/' + job_id, function(job){
|
|
let recheck = true;
|
|
|
|
if ( job.status == "new" ) {
|
|
$('#job-percent-' + job_id).text(0);
|
|
$('#job-status-' + job_id).text(JOB_PROGRESS_NOT_STARTED);
|
|
$('#progress-bar-' + job_id).attr('aria-valuenow', 0).css("width", "100%");
|
|
} else if ( job.status == "started" ) {
|
|
const progress = job["progress"];
|
|
const size = job["size"];
|
|
const percent = progress > 0 ? ( progress / size ) * 100 : 0;
|
|
$('#job-percent-' + job_id).text(percent.toFixed(2));
|
|
$('#job-status-' + job_id).text(JOB_PROGRESS_STARTED);
|
|
$('#progress-bar-' + job_id).attr('aria-valuenow', percent).css("width", "percent+%");
|
|
} else if ( job.status == "finished" ) {
|
|
$('#job-percent-' + job_id).text(100);
|
|
$('#job-status-' + job_id).text(JOB_PROGRESS_FINISHED);
|
|
$('#progress-bar-' + job_id).addClass("progress-bar-success");
|
|
$('#progress-bar-' + job_id).attr('aria-valuenow', 100).css("width", "100%");
|
|
recheck = false;
|
|
callback();
|
|
} else if ( job.status == "failed" ) {
|
|
$('#job-percent-' + job_id).text(0);
|
|
$('#job-status-' + job_id).text(JOB_PROGRESS_FAILED);
|
|
$('#progress-bar-' + job_id).addClass("progress-bar-danger");
|
|
$('#progress-bar-' + job_id).attr('aria-valuenow', 0).css("width", "100%");
|
|
recheck = false;
|
|
}
|
|
|
|
if ( recheck ) {
|
|
setTimeout(function(){updateProgress(job_id, callback)}, 1 * 1000);
|
|
}
|
|
});
|
|
}
|