Update javascript code.

This commit is contained in:
James Cole
2017-01-02 08:30:20 +01:00
parent 3cd0540474
commit 533797fc9e
23 changed files with 24 additions and 110 deletions

View File

@@ -28,20 +28,17 @@ $(function () {
function checkImportStatus() {
"use strict";
console.log('checkImportStatus()');
$.getJSON(jobImportUrl).done(reportOnJobImport).fail(failedJobImport);
}
function importComplete(data) {
"use strict";
console.log('importComplete()');
var bar = $('#import-status-bar');
bar.removeClass('active');
}
function updateBar(data) {
"use strict";
console.log('updateBar()');
var bar = $('#import-status-bar');
if (data.showPercentage) {
bar.addClass('progress-bar-success').removeClass('progress-bar-info');
@@ -63,7 +60,6 @@ function updateBar(data) {
function reportErrors(data) {
"use strict";
console.log('reportErrors()');
if (data.errors.length == 1) {
$('#import-status-error-intro').text(langImportSingleError);
//'An error has occured during the import. The import can continue, however.'
@@ -83,21 +79,18 @@ function reportErrors(data) {
function reportStatus(data) {
"use strict";
console.log('reportStatus()');
$('#import-status-txt').removeClass('text-danger').text(data.statusText);
}
function kickStartJob() {
"use strict";
console.log('kickStartJob()');
$.post(jobStartUrl, {_token: token});
$.post(jobStartUrl);
startedTheImport();
startedImport = true;
}
function updateTimeout(data) {
"use strict";
console.log('updateTimeout()');
if (data.stepsDone != stepCount) {
stepCount = data.stepsDone;
currentLimit = 0;
@@ -105,12 +98,10 @@ function updateTimeout(data) {
}
currentLimit = currentLimit + interval;
// console.log("stepCount: " + stepCount + ", stepsDone: " + data.stepsDone + ", currentLimit: " + currentLimit);
}
function timeoutError() {
"use strict";
console.log('timeoutError()');
// set status
$('#import-status-txt').addClass('text-danger').text(langImportTimeOutError);
@@ -121,13 +112,11 @@ function timeoutError() {
function importJobFinished(data) {
"use strict";
console.log('importJobFinished() = ' + data.finished);
return data.finished;
}
function finishedJob(data) {
"use strict";
console.log('finishedJob()');
// "There was an error during the import routine. Please check the log files. The error seems to be: '"
$('#import-status-txt').removeClass('text-danger').addClass('text-success').text(langImportFinished);
@@ -142,7 +131,6 @@ function finishedJob(data) {
function reportOnJobImport(data) {
"use strict";
console.log('reportOnJobImport()');
updateBar(data);
reportErrors(data);
reportStatus(data);
@@ -173,13 +161,11 @@ function reportOnJobImport(data) {
function startedTheImport() {
"use strict";
console.log('startedTheImport()');
setTimeout(checkImportStatus, interval);
}
function failedJobImport(jqxhr, textStatus, error) {
"use strict";
console.log('failedJobImport()');
// set status
// "There was an error during the import routine. Please check the log files. The error seems to be: '"
$('#import-status-txt').addClass('text-danger').text(langImportFatalError + ' ' + textStatus + ' ' + error);