mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-27 17:31:09 -06:00
Better report for finished import.
This commit is contained in:
parent
106665a468
commit
70b63e1736
@ -168,10 +168,8 @@ class ImportController extends Controller
|
||||
{
|
||||
$result = [
|
||||
'showPercentage' => false,
|
||||
'status' => $job->status,
|
||||
'key' => $job->key,
|
||||
'started' => false,
|
||||
'completed' => false,
|
||||
'finished' => false,
|
||||
'running' => false,
|
||||
'errors' => $job->extended_status['errors'],
|
||||
'percentage' => 0,
|
||||
@ -183,6 +181,9 @@ class ImportController extends Controller
|
||||
if ($job->extended_status['total_steps'] !== 0) {
|
||||
$percentage = round(($job->extended_status['steps_done'] / $job->extended_status['total_steps']) * 100, 0);
|
||||
}
|
||||
if ($job->status === 'import_complete') {
|
||||
$result['finished'] = true;
|
||||
}
|
||||
|
||||
if ($job->status === 'import_running') {
|
||||
$result['started'] = true;
|
||||
|
@ -25,18 +25,20 @@ $(function () {
|
||||
|
||||
function checkImportStatus() {
|
||||
"use strict";
|
||||
console.log('checkImportStatus()');
|
||||
$.getJSON(jobImportUrl).success(reportOnJobImport).fail(failedJobImport);
|
||||
}
|
||||
|
||||
function importComplete(data) {
|
||||
"use strict";
|
||||
console.log('importComplete()');
|
||||
var bar = $('#import-status-bar');
|
||||
bar.removeClass('active');
|
||||
// TODO show more completion info.
|
||||
}
|
||||
|
||||
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');
|
||||
@ -59,6 +61,7 @@ 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.'
|
||||
@ -78,11 +81,13 @@ 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});
|
||||
startedTheImport();
|
||||
startedImport = true;
|
||||
@ -90,6 +95,7 @@ function kickStartJob() {
|
||||
|
||||
function updateTimeout(data) {
|
||||
"use strict";
|
||||
console.log('updateTimeout()');
|
||||
if (data.stepsDone != stepCount) {
|
||||
stepCount = data.stepsDone;
|
||||
currentLimit = 0;
|
||||
@ -97,12 +103,12 @@ function updateTimeout(data) {
|
||||
}
|
||||
|
||||
currentLimit = currentLimit + interval;
|
||||
console.log("stepCount: " + stepCount + ", stepsDone: " + data.stepsDone + ", currentLimit: " + currentLimit);
|
||||
// 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);
|
||||
|
||||
@ -111,14 +117,36 @@ function timeoutError() {
|
||||
|
||||
}
|
||||
|
||||
function importJobFinished(data) {
|
||||
"use strict";
|
||||
console.log('importJobFinished() = ' + data.finished);
|
||||
return data.finished;
|
||||
}
|
||||
|
||||
function finishedJob() {
|
||||
"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);
|
||||
|
||||
// remove progress bar.
|
||||
$('#import-status-holder').hide();
|
||||
}
|
||||
|
||||
function reportOnJobImport(data) {
|
||||
"use strict";
|
||||
|
||||
console.log('reportOnJobImport()');
|
||||
updateBar(data);
|
||||
reportErrors(data);
|
||||
reportStatus(data);
|
||||
updateTimeout(data);
|
||||
|
||||
if (importJobFinished(data)) {
|
||||
finishedJob();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// same number of steps as last time?
|
||||
if (currentLimit > timeoutLimit) {
|
||||
timeoutError();
|
||||
@ -138,12 +166,13 @@ 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);
|
||||
|
@ -791,4 +791,5 @@ return [
|
||||
'import_error_fatal' => 'There was an error during the import routine. Please check the log files. The error seems to be:',
|
||||
'import_error_timeout' => 'The import seems to have timed out. If this error persists, please import your data using the console command.',
|
||||
'import_double' => 'Row #:row: This row has been imported before, and is stored in <a href=":link">:description</a>.',
|
||||
'import_finished_all' => 'The import has finished. Please check out the result below.',
|
||||
];
|
||||
|
@ -63,6 +63,7 @@
|
||||
var langImportMultiError = '{{ 'import_error_multi'|_ }}';
|
||||
var langImportFatalError = '{{ 'import_error_fatal'|_ }}';
|
||||
var langImportTimeOutError = '{{ 'import_error_timeout'|_ }}';
|
||||
var langImportFinished = '{{ 'import_finished_all'|_ }}';
|
||||
|
||||
var jobKey = '{{ job.key }}';
|
||||
var jobImportUrl = '{{ route('import.json', [job.key]) }}';
|
||||
|
Loading…
Reference in New Issue
Block a user