mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fine-tuning the import routine.
This commit is contained in:
@@ -54,7 +54,7 @@ class ImportController extends Controller
|
||||
if (!$this->jobInCorrectStep($job, 'complete')) {
|
||||
return $this->redirectToCorrectStep($job);
|
||||
}
|
||||
$subTitle = trans('firefy.import_complete');
|
||||
$subTitle = trans('firefly.import_complete');
|
||||
$subTitleIcon = 'fa-star';
|
||||
|
||||
return view('import.complete', compact('job', 'subTitle', 'subTitleIcon'));
|
||||
@@ -120,6 +120,19 @@ class ImportController extends Controller
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImportJob $job
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function finished(ImportJob $job)
|
||||
{
|
||||
$subTitle = trans('firefly.import_finished');
|
||||
$subTitleIcon = 'fa-star';
|
||||
|
||||
return view('import.finished', compact('job', 'subTitle', 'subTitleIcon'));
|
||||
}
|
||||
|
||||
/**
|
||||
* This is step 1. Upload a file.
|
||||
*
|
||||
@@ -154,6 +167,7 @@ class ImportController extends Controller
|
||||
'started' => false,
|
||||
'completed' => false,
|
||||
'running' => false,
|
||||
'errors' => $job->extended_status['errors'],
|
||||
'percentage' => 0,
|
||||
'steps' => $job->extended_status['total_steps'],
|
||||
'stepsDone' => $job->extended_status['steps_done'],
|
||||
@@ -290,7 +304,7 @@ class ImportController extends Controller
|
||||
if (!$this->jobInCorrectStep($job, 'status')) {
|
||||
return $this->redirectToCorrectStep($job);
|
||||
}
|
||||
$subTitle = trans('firefy.import_status');
|
||||
$subTitle = trans('firefly.import_status');
|
||||
$subTitleIcon = 'fa-star';
|
||||
|
||||
return view('import.status', compact('job', 'subTitle', 'subTitleIcon'));
|
||||
@@ -414,6 +428,8 @@ class ImportController extends Controller
|
||||
Log::debug('Will redirect to complete()');
|
||||
|
||||
return redirect(route('import.complete', [$job->key]));
|
||||
case 'import_complete':
|
||||
return redirect(route('import.finished', [$job->key]));
|
||||
}
|
||||
|
||||
throw new FireflyException('Cannot redirect for job state ' . $job->status);
|
||||
|
@@ -234,8 +234,9 @@ Route::group(
|
||||
|
||||
Route::get('/import/status/{importJob}', ['uses' => 'ImportController@status', 'as' => 'import.status']);
|
||||
Route::get('/import/json/{importJob}', ['uses' => 'ImportController@json', 'as' => 'import.json']);
|
||||
Route::post('/import/start/{importJob}', ['uses' => 'ImportController@start', 'as' => 'import.start']);
|
||||
|
||||
Route::post('/import/start/{importJob}', ['uses' => 'ImportController@start', 'as' => 'import.start']);
|
||||
Route::get('/import/finished/{importJob}', ['uses' => 'ImportController@finished', 'as' => 'import.finished']);
|
||||
|
||||
/**
|
||||
* Help Controller
|
||||
|
@@ -220,8 +220,13 @@ class ImportStorage
|
||||
Log::warning(sprintf('Cannot import row %d, because the entry is not valid.', $index));
|
||||
$result = new ImportResult();
|
||||
$result->failed();
|
||||
$errors = join(', ', $entry->errors->all());
|
||||
$result->appendError(sprintf('Row #%d: ' . $errors, $index));
|
||||
$errors = join(', ', $entry->errors->all());
|
||||
$errorText = sprintf('Row #%d: ' . $errors, $index);
|
||||
$result->appendError($errorText);
|
||||
$extendedStatus = $this->job->extended_status;
|
||||
$extendedStatus['errors'][] = $errorText;
|
||||
$this->job->extended_status = $extendedStatus;
|
||||
$this->job->save();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
||||
$importJob->file_type = $fileType;
|
||||
$importJob->key = Str::random(12);
|
||||
$importJob->status = 'import_status_never_started';
|
||||
$importJob->extended_status = ['total_steps' => 0, 'steps_done' => 0,];
|
||||
$importJob->extended_status = ['total_steps' => 0, 'steps_done' => 0, 'errors' => [], 'import_count' => 0];
|
||||
$importJob->save();
|
||||
|
||||
// breaks the loop:
|
||||
|
Reference in New Issue
Block a user