mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Expand install routine.
This commit is contained in:
@@ -29,7 +29,6 @@ use FireflyIII\Http\Controllers\Controller;
|
|||||||
use Laravel\Passport\Passport;
|
use Laravel\Passport\Passport;
|
||||||
use Log;
|
use Log;
|
||||||
use phpseclib\Crypt\RSA;
|
use phpseclib\Crypt\RSA;
|
||||||
use Symfony\Component\Console\Output\BufferedOutput;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class InstallController
|
* Class InstallController
|
||||||
@@ -47,15 +46,16 @@ class InstallController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
public function migrate()
|
public function index()
|
||||||
{
|
{
|
||||||
Log::debug('Am now calling migrate routine...');
|
return view('install.index');
|
||||||
$output = new BufferedOutput();
|
}
|
||||||
Artisan::call('migrate', ['--seed' => true, '--force' => true]);
|
|
||||||
$result = $output->fetch();
|
|
||||||
Log::debug($result);
|
|
||||||
Log::debug(Artisan::output());
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
|
*/
|
||||||
|
public function keys()
|
||||||
|
{
|
||||||
// create keys manually because for some reason the passport namespace
|
// create keys manually because for some reason the passport namespace
|
||||||
// does not exist
|
// does not exist
|
||||||
$rsa = new RSA();
|
$rsa = new RSA();
|
||||||
@@ -67,13 +67,37 @@ class InstallController extends Controller
|
|||||||
];
|
];
|
||||||
|
|
||||||
if ((file_exists($publicKey) || file_exists($privateKey))) {
|
if ((file_exists($publicKey) || file_exists($privateKey))) {
|
||||||
return redirect(route('index'));
|
return response()->json(['OK']);
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents($publicKey, array_get($keys, 'publickey'));
|
file_put_contents($publicKey, array_get($keys, 'publickey'));
|
||||||
file_put_contents($privateKey, array_get($keys, 'privatekey'));
|
file_put_contents($privateKey, array_get($keys, 'privatekey'));
|
||||||
|
|
||||||
return redirect(route('index'));
|
return response()->json(['OK']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
|
public function migrate()
|
||||||
|
{
|
||||||
|
Log::debug('Am now calling migrate routine...');
|
||||||
|
Artisan::call('migrate', ['--seed' => true, '--force' => true]);
|
||||||
|
Log::debug(Artisan::output());
|
||||||
|
|
||||||
|
return response()->json(['OK']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
|
public function upgrade()
|
||||||
|
{
|
||||||
|
Log::debug('Am now calling upgrade database routine...');
|
||||||
|
Artisan::call('firefly:upgrade-database');
|
||||||
|
Log::debug(Artisan::output());
|
||||||
|
|
||||||
|
return response()->json(['OK']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -50,7 +50,7 @@ class Installer
|
|||||||
// redirect to UpdateController
|
// redirect to UpdateController
|
||||||
Log::warning('There are no Firefly III tables present. Redirect to migrate routine.');
|
Log::warning('There are no Firefly III tables present. Redirect to migrate routine.');
|
||||||
|
|
||||||
return response()->redirectTo(route('installer.migrate'));
|
return response()->redirectTo(route('installer.index'));
|
||||||
}
|
}
|
||||||
throw new FireflyException(sprintf('Could not access the database: %s', $message));
|
throw new FireflyException(sprintf('Could not access the database: %s', $message));
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ class Installer
|
|||||||
));
|
));
|
||||||
|
|
||||||
// redirect to migrate routine:
|
// redirect to migrate routine:
|
||||||
return response()->redirectTo(route('installer.migrate'));
|
return response()->redirectTo(route('installer.index'));
|
||||||
}
|
}
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
70
public/js/ff/install/index.js
vendored
Normal file
70
public/js/ff/install/index.js
vendored
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* index.js
|
||||||
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III.
|
||||||
|
*
|
||||||
|
* Firefly III is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Firefly III is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
"use strict";
|
||||||
|
//var status = $('#status-box');
|
||||||
|
// set HTML to "migrating...":
|
||||||
|
startMigration();
|
||||||
|
});
|
||||||
|
|
||||||
|
function startMigration() {
|
||||||
|
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Setting up DB...');
|
||||||
|
$.post(migrateUri, {_token: token}).done(function () {
|
||||||
|
startPassport();
|
||||||
|
}).fail(function () {
|
||||||
|
$('#status-box').html('<i class="fa fa-warning"></i> Migration failed! See log files :(');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function startPassport() {
|
||||||
|
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Setting up OAuth2...');
|
||||||
|
$.post(keysUri, {_token: token}).done(function () {
|
||||||
|
startUpgrade();
|
||||||
|
}).fail(function () {
|
||||||
|
$('#status-box').html('<i class="fa fa-warning"></i> OAuth2 failed! See log files :(');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function startUpgrade() {
|
||||||
|
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Upgrading database...');
|
||||||
|
$.post(upgradeUri, {_token: token}).done(function () {
|
||||||
|
completeDone();
|
||||||
|
}).fail(function () {
|
||||||
|
$('#status-box').html('<i class="fa fa-warning"></i> Upgrade failed! See log files :(');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function completeDone() {
|
||||||
|
$('#status-box').html('<i class="fa fa-thumbs-up"></i> Installation complete! Wait to be redirected...');
|
||||||
|
setTimeout(function () {
|
||||||
|
window.location = homeUri;
|
||||||
|
}, 3000);
|
||||||
|
}
|
@@ -4,10 +4,22 @@
|
|||||||
<div class="login-box-body">
|
<div class="login-box-body">
|
||||||
<p class="login-box-msg">Please wait...</p>
|
<p class="login-box-msg">Please wait...</p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-8">
|
<div class="col-lg-12">
|
||||||
Hello
|
<div id="status-box" style="border:1px #ddd solid;padding:5px;">
|
||||||
|
<i class="fa fa-spin fa-spinner"></i> Waiting to start...
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
{% block scripts %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
var token = '{{ csrf_token() }}';
|
||||||
|
var migrateUri = '{{ route('installer.migrate') }}';
|
||||||
|
var keysUri = '{{ route('installer.keys') }}';
|
||||||
|
var upgradeUri = '{{ route('installer.upgrade') }}';
|
||||||
|
var homeUri = '{{ route('home') }}';
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript" src="js/ff/install/index.js"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
<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>
|
<title>Firefly III - Installation and update</title>
|
||||||
<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 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'>
|
||||||
<link href="css/app.css?v={{ FF_VERSION }}" rel="stylesheet" type="text/css"/>
|
<link href="css/app.css?v={{ FF_VERSION }}" rel="stylesheet" type="text/css"/>
|
||||||
<link href="lib/adminlte/css/AdminLTE.min.css?v={{ FF_VERSION }}" rel="stylesheet" type="text/css"/>
|
<link href="lib/adminlte/css/AdminLTE.min.css?v={{ FF_VERSION }}" rel="stylesheet" type="text/css"/>
|
||||||
@@ -29,5 +30,6 @@
|
|||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
<script src="js/app.js?v={{ FF_VERSION }}" type="text/javascript"></script>
|
<script src="js/app.js?v={{ FF_VERSION }}" type="text/javascript"></script>
|
||||||
|
{% block scripts %}{% endblock %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@@ -26,8 +26,9 @@ Route::group(
|
|||||||
['namespace' => 'FireflyIII\Http\Controllers\System',
|
['namespace' => 'FireflyIII\Http\Controllers\System',
|
||||||
'as' => 'installer.', 'prefix' => 'install'], function () {
|
'as' => 'installer.', 'prefix' => 'install'], function () {
|
||||||
Route::get('', ['uses' => 'InstallController@index', 'as' => 'index']);
|
Route::get('', ['uses' => 'InstallController@index', 'as' => 'index']);
|
||||||
|
Route::post('migrate', ['uses' => 'InstallController@migrate', 'as' => 'migrate']);
|
||||||
Route::get('migrate', ['uses' => 'InstallController@migrate', 'as' => 'migrate']);
|
Route::post('keys', ['uses' => 'InstallController@keys', 'as' => 'keys']);
|
||||||
|
Route::post('upgrade', ['uses' => 'InstallController@upgrade', 'as' => 'upgrade']);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user