Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Better report for finished import.
James Cole70b63e173636
diff --git a/app/Http/Controllers/ImportController.php b/app/Http/Controllers/ImportController.phpindex e19f312265..7c78754e1d 100644--- a/app/Http/Controllers/ImportController.php+++ b/app/Http/Controllers/ImportController.php@@ -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 Controllerif ($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;diff --git a/public/js/ff/import/status.js b/public/js/ff/import/status.jsindex f8415ae119..751de6b54b 100644--- a/public/js/ff/import/status.js+++ b/public/js/ff/import/status.js@@ -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 reportOnJobImport(data) {+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);diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.phpindex 80fc765ada..bc97125526 100644--- a/resources/lang/en_US/firefly.php+++ b/resources/lang/en_US/firefly.php@@ -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.',];diff --git a/resources/views/import/status.twig b/resources/views/import/status.twigindex 9044770356..524f6a4373 100644--- a/resources/views/import/status.twig+++ b/resources/views/import/status.twig@@ -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]) }}';