From 3c20fd7533d041196b63866cdb52b749b9a5f2fe Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 15 Apr 2023 10:14:14 +0200 Subject: [PATCH] Fix installer --- .../Controllers/System/InstallController.php | 27 +++------- public/v1/js/ff/install/index.js | 14 ++++-- resources/views/install/index.twig | 14 +++--- resources/views/layout/install.twig | 49 +++++++++++++------ 4 files changed, 59 insertions(+), 45 deletions(-) diff --git a/app/Http/Controllers/System/InstallController.php b/app/Http/Controllers/System/InstallController.php index 7a8d53f6c3..62a5d7143a 100644 --- a/app/Http/Controllers/System/InstallController.php +++ b/app/Http/Controllers/System/InstallController.php @@ -127,6 +127,7 @@ class InstallController extends Controller */ public function index() { + app('view')->share('FF_VERSION', config('firefly.version')); // index will set FF3 version. app('fireflyconfig')->set('ff3_version', (string)config('firefly.version')); @@ -147,27 +148,19 @@ class InstallController extends Controller $response = [ 'hasNextCommand' => false, 'done' => true, - 'next' => 0, 'previous' => null, 'error' => false, 'errorMessage' => null, ]; Log::debug(sprintf('Will now run commands. Request index is %d', $requestIndex)); - $index = 0; - /** - * @var string $command - * @var array $args - */ - foreach ($this->upgradeCommands as $command => $args) { - Log::debug(sprintf('Current command is "%s", index is %d', $command, $index)); - if ($index < $requestIndex) { - Log::debug('Will not execute.'); - $index++; - continue; - } + $indexes = array_values(array_keys($this->upgradeCommands)); + if(array_key_exists($requestIndex, $indexes)) { + $command = $indexes[$requestIndex]; + $parameters = $this->upgradeCommands[$command]; + Log::debug(sprintf('Will now execute command "%s" with parameters', $command), $parameters); try { - $result = $this->executeCommand($command, $args); + $result = $this->executeCommand($command, $parameters); } catch (FireflyException $e) { Log::error($e->getMessage()); Log::error($e->getTraceAsString()); @@ -180,15 +173,11 @@ class InstallController extends Controller if (false === $result) { $response['errorMessage'] = $this->lastError; $response['error'] = true; - return response()->json($response); } - $index++; - $response['hasNextCommand'] = true; + $response['hasNextCommand'] = array_key_exists($requestIndex + 1, $indexes); $response['previous'] = $command; } - $response['next'] = $index; - return response()->json($response); } diff --git a/public/v1/js/ff/install/index.js b/public/v1/js/ff/install/index.js index a26d547ccd..29733b9cda 100644 --- a/public/v1/js/ff/install/index.js +++ b/public/v1/js/ff/install/index.js @@ -23,10 +23,12 @@ $(function () { "use strict"; //var status = $('#status-box'); // set HTML to "migrating...": - startRunningCommands(); + console.log('Starting...'); + startRunningCommands(0); }); -function startRunningCommands() { +function startRunningCommands(index) { + console.log('Now in startRunningCommands with index' + index); if (0 === index) { $('#status-box').html(' Running first command...'); } @@ -34,7 +36,8 @@ function startRunningCommands() { } function runCommand(index) { - $.post(runCommandUrl, {_token: token, index: index}).done(function (data) { + console.log('Now in runCommand(' + index + '): ' + runCommandUrl); + $.post(runCommandUrl, {_token: token, index: parseInt(index)}).done(function (data) { if (data.error === false) { // increase index index++; @@ -59,7 +62,7 @@ function runCommand(index) { } function startMigration() { - + console.log('Now in startMigration'); $.post(migrateUrl, {_token: token}).done(function (data) { if (data.error === false) { // move to decrypt routine. @@ -74,6 +77,7 @@ function startMigration() { } function startDecryption() { + console.log('Now in startDecryption'); $('#status-box').html(' Setting up DB #2...'); $.post(decryptUrl, {_token: token}).done(function (data) { if (data.error === false) { @@ -151,4 +155,4 @@ function displaySoftFail(message) { $('#status-box').html(' ' + message + '

Please read the ' + '' + 'documentation about this, and upgrade by hand.'); -} \ No newline at end of file +} diff --git a/resources/views/install/index.twig b/resources/views/install/index.twig index fcffaef7cb..2635f4817a 100644 --- a/resources/views/install/index.twig +++ b/resources/views/install/index.twig @@ -1,12 +1,14 @@ {% extends "./layout/install" %} {% block content %} -
- -
-
-
- Waiting to start... +
+ diff --git a/resources/views/layout/install.twig b/resources/views/layout/install.twig index 5dcb483edd..bbb966e5de 100644 --- a/resources/views/layout/install.twig +++ b/resources/views/layout/install.twig @@ -1,33 +1,28 @@ + Firefly III - Installation and update - Firefly III - Installation and update + + - - - {# libraries #} - - + {# CSS things #} - - - - + + + + + {# favicons #} {% include('partials.favicons') %} - - + +
+ + Developed by James Cole, the source code is licensed under the AGPL-3.0-or-later. + +
+ {% block scripts %}{% endblock %} +{% if config('firefly.tracker_site_id') != '' and config('firefly.tracker_url') != '' %} + + + + +{% endif %} +