mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-28 09:51:21 -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 = [
|
$result = [
|
||||||
'showPercentage' => false,
|
'showPercentage' => false,
|
||||||
'status' => $job->status,
|
|
||||||
'key' => $job->key,
|
|
||||||
'started' => false,
|
'started' => false,
|
||||||
'completed' => false,
|
'finished' => false,
|
||||||
'running' => false,
|
'running' => false,
|
||||||
'errors' => $job->extended_status['errors'],
|
'errors' => $job->extended_status['errors'],
|
||||||
'percentage' => 0,
|
'percentage' => 0,
|
||||||
@ -183,6 +181,9 @@ class ImportController extends Controller
|
|||||||
if ($job->extended_status['total_steps'] !== 0) {
|
if ($job->extended_status['total_steps'] !== 0) {
|
||||||
$percentage = round(($job->extended_status['steps_done'] / $job->extended_status['total_steps']) * 100, 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') {
|
if ($job->status === 'import_running') {
|
||||||
$result['started'] = true;
|
$result['started'] = true;
|
||||||
|
@ -25,18 +25,20 @@ $(function () {
|
|||||||
|
|
||||||
function checkImportStatus() {
|
function checkImportStatus() {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
console.log('checkImportStatus()');
|
||||||
$.getJSON(jobImportUrl).success(reportOnJobImport).fail(failedJobImport);
|
$.getJSON(jobImportUrl).success(reportOnJobImport).fail(failedJobImport);
|
||||||
}
|
}
|
||||||
|
|
||||||
function importComplete(data) {
|
function importComplete(data) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
console.log('importComplete()');
|
||||||
var bar = $('#import-status-bar');
|
var bar = $('#import-status-bar');
|
||||||
bar.removeClass('active');
|
bar.removeClass('active');
|
||||||
// TODO show more completion info.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateBar(data) {
|
function updateBar(data) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
console.log('updateBar()');
|
||||||
var bar = $('#import-status-bar');
|
var bar = $('#import-status-bar');
|
||||||
if (data.showPercentage) {
|
if (data.showPercentage) {
|
||||||
bar.addClass('progress-bar-success').removeClass('progress-bar-info');
|
bar.addClass('progress-bar-success').removeClass('progress-bar-info');
|
||||||
@ -59,6 +61,7 @@ function updateBar(data) {
|
|||||||
|
|
||||||
function reportErrors(data) {
|
function reportErrors(data) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
console.log('reportErrors()');
|
||||||
if (data.errors.length == 1) {
|
if (data.errors.length == 1) {
|
||||||
$('#import-status-error-intro').text(langImportSingleError);
|
$('#import-status-error-intro').text(langImportSingleError);
|
||||||
//'An error has occured during the import. The import can continue, however.'
|
//'An error has occured during the import. The import can continue, however.'
|
||||||
@ -78,11 +81,13 @@ function reportErrors(data) {
|
|||||||
|
|
||||||
function reportStatus(data) {
|
function reportStatus(data) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
console.log('reportStatus()');
|
||||||
$('#import-status-txt').removeClass('text-danger').text(data.statusText);
|
$('#import-status-txt').removeClass('text-danger').text(data.statusText);
|
||||||
}
|
}
|
||||||
|
|
||||||
function kickStartJob() {
|
function kickStartJob() {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
console.log('kickStartJob()');
|
||||||
$.post(jobStartUrl, {_token: token});
|
$.post(jobStartUrl, {_token: token});
|
||||||
startedTheImport();
|
startedTheImport();
|
||||||
startedImport = true;
|
startedImport = true;
|
||||||
@ -90,6 +95,7 @@ function kickStartJob() {
|
|||||||
|
|
||||||
function updateTimeout(data) {
|
function updateTimeout(data) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
console.log('updateTimeout()');
|
||||||
if (data.stepsDone != stepCount) {
|
if (data.stepsDone != stepCount) {
|
||||||
stepCount = data.stepsDone;
|
stepCount = data.stepsDone;
|
||||||
currentLimit = 0;
|
currentLimit = 0;
|
||||||
@ -97,12 +103,12 @@ function updateTimeout(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentLimit = currentLimit + interval;
|
currentLimit = currentLimit + interval;
|
||||||
console.log("stepCount: " + stepCount + ", stepsDone: " + data.stepsDone + ", currentLimit: " + currentLimit);
|
// console.log("stepCount: " + stepCount + ", stepsDone: " + data.stepsDone + ", currentLimit: " + currentLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
function timeoutError() {
|
function timeoutError() {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
console.log('timeoutError()');
|
||||||
// set status
|
// set status
|
||||||
$('#import-status-txt').addClass('text-danger').text(langImportTimeOutError);
|
$('#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) {
|
function reportOnJobImport(data) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
console.log('reportOnJobImport()');
|
||||||
updateBar(data);
|
updateBar(data);
|
||||||
reportErrors(data);
|
reportErrors(data);
|
||||||
reportStatus(data);
|
reportStatus(data);
|
||||||
updateTimeout(data);
|
updateTimeout(data);
|
||||||
|
|
||||||
|
if (importJobFinished(data)) {
|
||||||
|
finishedJob();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// same number of steps as last time?
|
// same number of steps as last time?
|
||||||
if (currentLimit > timeoutLimit) {
|
if (currentLimit > timeoutLimit) {
|
||||||
timeoutError();
|
timeoutError();
|
||||||
@ -138,12 +166,13 @@ function reportOnJobImport(data) {
|
|||||||
|
|
||||||
function startedTheImport() {
|
function startedTheImport() {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
console.log('startedTheImport()');
|
||||||
setTimeout(checkImportStatus, interval);
|
setTimeout(checkImportStatus, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
function failedJobImport(jqxhr, textStatus, error) {
|
function failedJobImport(jqxhr, textStatus, error) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
console.log('failedJobImport()');
|
||||||
// set status
|
// set status
|
||||||
// "There was an error during the import routine. Please check the log files. The error seems to be: '"
|
// "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);
|
$('#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_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_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_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 langImportMultiError = '{{ 'import_error_multi'|_ }}';
|
||||||
var langImportFatalError = '{{ 'import_error_fatal'|_ }}';
|
var langImportFatalError = '{{ 'import_error_fatal'|_ }}';
|
||||||
var langImportTimeOutError = '{{ 'import_error_timeout'|_ }}';
|
var langImportTimeOutError = '{{ 'import_error_timeout'|_ }}';
|
||||||
|
var langImportFinished = '{{ 'import_finished_all'|_ }}';
|
||||||
|
|
||||||
var jobKey = '{{ job.key }}';
|
var jobKey = '{{ job.key }}';
|
||||||
var jobImportUrl = '{{ route('import.json', [job.key]) }}';
|
var jobImportUrl = '{{ route('import.json', [job.key]) }}';
|
||||||
|
Loading…
Reference in New Issue
Block a user