- Show message if migration didn't start properly

- Update completed.blade.php with errors message
- Better status checking in CompleteService.php
This commit is contained in:
Benjamin Beganović 2021-03-30 10:49:29 +02:00
parent 3d69498c6e
commit 25dca51b5e
3 changed files with 12 additions and 13 deletions

View File

@ -175,9 +175,13 @@ class StepsController extends BaseController
->endpoint(session('MIGRATION_ENDPOINT')) ->endpoint(session('MIGRATION_ENDPOINT'))
->start(); ->start();
if ($completeService->isSuccessful()) {
return view('migration.completed'); return view('migration.completed');
} }
return view('migration.completed', ['customMessage' => $completeService->getErrors()[0]]);
}
public function completed() public function completed()
{ {
return view('migration.completed'); return view('migration.completed');
@ -250,7 +254,7 @@ class StepsController extends BaseController
'documents' => $this->getDocuments(), 'documents' => $this->getDocuments(),
]; ];
$localMigrationData['force'] = array_key_exists('force', $company) ? true : false; $localMigrationData['force'] = array_key_exists('force', $company);
$file = storage_path("migrations/{$fileName}.zip"); $file = storage_path("migrations/{$fileName}.zip");

View File

@ -55,20 +55,16 @@ class CompleteService
$body = \Unirest\Request\Body::multipart(['companies' => json_encode($data)], $files); $body = \Unirest\Request\Body::multipart(['companies' => json_encode($data)], $files);
try {
$response = Request::post($this->getUrl(), $this->getHeaders(), $body); $response = Request::post($this->getUrl(), $this->getHeaders(), $body);
} catch (\Exception $e) {
info($e->getMessage());
}
if ($response->code == 200) { if (in_array($response->code, [200])) {
$this->isSuccessful = true; $this->isSuccessful = true;
} } else {
info($response->raw_body);
if (in_array($response->code, [401, 422, 500])) {
$this->isSuccessful = false; $this->isSuccessful = false;
$this->errors = [ $this->errors = [
'Oops, something went wrong. Migration can\'t be processed at the moment.', 'Oops, something went wrong. Migration can\'t be processed at the moment. Please checks the logs.',
]; ];
} }

View File

@ -9,8 +9,7 @@
<h3 class="panel-title">{!! trans('texts.welcome_to_the_new_version') !!}</h3> <h3 class="panel-title">{!! trans('texts.welcome_to_the_new_version') !!}</h3>
</div> </div>
<div class="panel-body"> <div class="panel-body">
Migration has started. We'll update you with status, on your company e-mail. {{ $customMessage ?? 'Migration has started. We\'ll update you with status, on your company e-mail.' }}
<!-- Note: This message needs edit, like next instructions, etc. -->
</div> </div>
</div> </div>