Merge pull request #7370 from firefly-iii/fix-installer

Fix installer
This commit is contained in:
James Cole 2023-04-15 10:19:34 +02:00 committed by GitHub
commit fb6706648e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 45 deletions

View File

@ -127,6 +127,7 @@ class InstallController extends Controller
*/ */
public function index() public function index()
{ {
app('view')->share('FF_VERSION', config('firefly.version'));
// index will set FF3 version. // index will set FF3 version.
app('fireflyconfig')->set('ff3_version', (string)config('firefly.version')); app('fireflyconfig')->set('ff3_version', (string)config('firefly.version'));
@ -147,27 +148,19 @@ class InstallController extends Controller
$response = [ $response = [
'hasNextCommand' => false, 'hasNextCommand' => false,
'done' => true, 'done' => true,
'next' => 0,
'previous' => null, 'previous' => null,
'error' => false, 'error' => false,
'errorMessage' => null, 'errorMessage' => null,
]; ];
Log::debug(sprintf('Will now run commands. Request index is %d', $requestIndex)); Log::debug(sprintf('Will now run commands. Request index is %d', $requestIndex));
$index = 0; $indexes = array_values(array_keys($this->upgradeCommands));
/** if(array_key_exists($requestIndex, $indexes)) {
* @var string $command $command = $indexes[$requestIndex];
* @var array $args $parameters = $this->upgradeCommands[$command];
*/ Log::debug(sprintf('Will now execute command "%s" with parameters', $command), $parameters);
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;
}
try { try {
$result = $this->executeCommand($command, $args); $result = $this->executeCommand($command, $parameters);
} catch (FireflyException $e) { } catch (FireflyException $e) {
Log::error($e->getMessage()); Log::error($e->getMessage());
Log::error($e->getTraceAsString()); Log::error($e->getTraceAsString());
@ -180,15 +173,11 @@ class InstallController extends Controller
if (false === $result) { if (false === $result) {
$response['errorMessage'] = $this->lastError; $response['errorMessage'] = $this->lastError;
$response['error'] = true; $response['error'] = true;
return response()->json($response); return response()->json($response);
} }
$index++; $response['hasNextCommand'] = array_key_exists($requestIndex + 1, $indexes);
$response['hasNextCommand'] = true;
$response['previous'] = $command; $response['previous'] = $command;
} }
$response['next'] = $index;
return response()->json($response); return response()->json($response);
} }

View File

@ -23,10 +23,12 @@ $(function () {
"use strict"; "use strict";
//var status = $('#status-box'); //var status = $('#status-box');
// set HTML to "migrating...": // 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) { if (0 === index) {
$('#status-box').html('<span class="fa fa-spin fa-spinner"></span> Running first command...'); $('#status-box').html('<span class="fa fa-spin fa-spinner"></span> Running first command...');
} }
@ -34,7 +36,8 @@ function startRunningCommands() {
} }
function runCommand(index) { 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) { if (data.error === false) {
// increase index // increase index
index++; index++;
@ -59,7 +62,7 @@ function runCommand(index) {
} }
function startMigration() { function startMigration() {
console.log('Now in startMigration');
$.post(migrateUrl, {_token: token}).done(function (data) { $.post(migrateUrl, {_token: token}).done(function (data) {
if (data.error === false) { if (data.error === false) {
// move to decrypt routine. // move to decrypt routine.
@ -74,6 +77,7 @@ function startMigration() {
} }
function startDecryption() { function startDecryption() {
console.log('Now in startDecryption');
$('#status-box').html('<span class="fa fa-spin fa-spinner"></span> Setting up DB #2...'); $('#status-box').html('<span class="fa fa-spin fa-spinner"></span> Setting up DB #2...');
$.post(decryptUrl, {_token: token}).done(function (data) { $.post(decryptUrl, {_token: token}).done(function (data) {
if (data.error === false) { if (data.error === false) {
@ -151,4 +155,4 @@ function displaySoftFail(message) {
$('#status-box').html('<span class="fa fa-warning"></span> ' + message + '<br /><br />Please read the ' + $('#status-box').html('<span class="fa fa-warning"></span> ' + message + '<br /><br />Please read the ' +
'<a href="https://docs.firefly-iii.org/">' + '<a href="https://docs.firefly-iii.org/">' +
'documentation</a> about this, and upgrade by hand.'); 'documentation</a> about this, and upgrade by hand.');
} }

View File

@ -1,12 +1,14 @@
{% extends "./layout/install" %} {% extends "./layout/install" %}
{% block content %} {% block content %}
<div class="login-box-body"> <div class="card mb-2">
<p class="login-box-msg">Please wait...</p> <div class="card-body login-card-body">
<div class="row"> <p class="login-box-msg">Please wait...</p>
<div class="col-lg-12"> <div class="row">
<div id="status-box" style="border:1px #ddd solid;padding:5px;"> <div class="col-lg-12">
<span class="fa fa-spin fa-spinner"></span> Waiting to start... <div id="status-box" style="border:1px #ddd solid;padding:5px;">
<span class="fa fa-spin fa-spinner"></span> Waiting to start...
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,33 +1,28 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<title>Firefly III - Installation and update</title>
<base href="{{ route('index') }}/"> <base href="{{ route('index') }}/">
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="robots" content="noindex, nofollow, noarchive, noodp, NoImageIndex, noydir"> <meta name="robots" content="noindex, nofollow, noarchive, noodp, NoImageIndex, noydir">
<title>Firefly III - Installation and update</title> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="color-scheme" content="light dark">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="csrf-token" content="{{ csrf_token() }}"> <meta name="csrf-token" content="{{ csrf_token() }}">
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'> <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="color-scheme" content="light dark">
{# libraries #} {# CSS things #}
<link href="v1/lib/bs/css/bootstrap.min.css?v={{ FF_VERSION }}" rel="stylesheet" type="text/css" nonce="{{ JS_NONCE }}">
<link href="v1/lib/fa/css/font-awesome.min.css?v={{ FF_VERSION }}" rel="stylesheet" type="text/css" nonce="{{ JS_NONCE }}">
<link href="v1/lib/adminlte/css/AdminLTE.min.css?v={{ FF_VERSION }}" rel="stylesheet" type="text/css" nonce="{{ JS_NONCE }}"> <!-- fonts and styles -->
<link href="v1/css/firefly.css?v={{ FF_VERSION }}" rel="stylesheet" type="text/css" nonce="{{ JS_NONCE }}"> <link rel="stylesheet" href="v3-local/css/fonts.css?v=6.0.7">
<link rel="stylesheet" href="v3-local/lib/fontawesome-free/css/all.min.css?v=6.0.7">
<!--[if lt IE 9]> <link rel="stylesheet" href="v3-local/lib/icheck-bootstrap/icheck-bootstrap.min.css?v=6.0.7">
<script src="v1/js/lib/html5shiv.min.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script> <link rel="stylesheet" href="v3-local/dist/css/adminlte.min.css?v=6.0.7">
<script src="v1/js/lib/respond.min.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
<![endif]-->
{# favicons #} {# favicons #}
{% include('partials.favicons') %} {% include('partials.favicons') %}
</head> </head>
<body class="login-page"> <body class="hold-transition login-page dark-mode">
<div class="login-box"> <div class="login-box">
<div class="login-logo"> <div class="login-logo">
<strong>Firefly</strong>III<br /> <strong>Firefly</strong>III<br />
@ -35,7 +30,31 @@
</div> </div>
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
<div class="text-center text-muted">
<small>
Developed by James Cole, the source code is licensed under the <a href="https://www.gnu.org/licenses/agpl-3.0.html">AGPL-3.0-or-later</a>.
</small>
</div>
<script src="v1/js/app.js?v={{ FF_VERSION }}" type="text/javascript" nonce="{{ JS_NONCE }}"></script> <script src="v1/js/app.js?v={{ FF_VERSION }}" type="text/javascript" nonce="{{ JS_NONCE }}"></script>
<script type="text/javascript" src="v1/js/ff/guest.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
{% block scripts %}{% endblock %} {% block scripts %}{% endblock %}
{% if config('firefly.tracker_site_id') != '' and config('firefly.tracker_url') != '' %}
<!-- This tracker tag is only here because this instance of Firefly III was purposefully configured to include it -->
<!-- Your own installation will NOT include it, unless you explicitely configure it to have it. -->
<script type="text/javascript" nonce="{{ JS_NONCE }}">
var _paq = window._paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//{{ config('firefly.tracker_url') }}/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '{{ config('firefly.tracker_site_id') }}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="//{{ config('firefly.tracker_url') }}/matomo.php?idsite={{ config('firefly.tracker_site_id') }}&amp;rec=1" style="border:0;" alt="" /></p></noscript>
{% endif %}
</body> </body>
</html> </html>