mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Support for database port on the setup
This commit is contained in:
parent
66d6595a90
commit
14efcc77e6
@ -22,7 +22,7 @@ use App\Utils\CurlUtils;
|
||||
use App\Utils\SystemHealth;
|
||||
use App\Utils\Traits\AppSetup;
|
||||
use Beganovich\Snappdf\Snappdf;
|
||||
use DB;
|
||||
use \Illuminate\Support\Facades\DB;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
@ -55,7 +55,7 @@ class SetupController extends Controller
|
||||
{
|
||||
try {
|
||||
$check = SystemHealth::check(false);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
nlog(['message' => $e->getMessage(), 'action' => 'SetupController::doSetup()']);
|
||||
|
||||
return response()->json(['message' => $e->getMessage()], 400);
|
||||
@ -71,9 +71,9 @@ class SetupController extends Controller
|
||||
$db = SystemHealth::dbCheck($request);
|
||||
|
||||
if ($db['success'] == false) {
|
||||
throw new \Exception($db['message']);
|
||||
throw new Exception($db['message']);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
return response([
|
||||
'message' => 'Oops, connection to database was not successful.',
|
||||
'error' => $e->getMessage(),
|
||||
@ -85,10 +85,10 @@ class SetupController extends Controller
|
||||
$smtp = SystemHealth::testMailServer($request);
|
||||
|
||||
if ($smtp['success'] == false) {
|
||||
throw new \Exception($smtp['message']);
|
||||
throw new Exception($smtp['message']);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
return response([
|
||||
'message' => 'Oops, connection to mail server was not successful.',
|
||||
'error' => $e->getMessage(),
|
||||
@ -103,6 +103,7 @@ class SetupController extends Controller
|
||||
'APP_DEBUG' => $request->input('debug') ? 'true' : 'false',
|
||||
|
||||
'DB_HOST1' => $request->input('db_host'),
|
||||
'DB_PORT1' => $request->input('db_port'),
|
||||
'DB_DATABASE1' => $request->input('db_database'),
|
||||
'DB_USERNAME1' => $request->input('db_username'),
|
||||
'DB_PASSWORD1' => $request->input('db_password'),
|
||||
@ -173,7 +174,7 @@ class SetupController extends Controller
|
||||
}
|
||||
|
||||
return response($status, 400);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
nlog(['message' => $e->getMessage(), 'action' => 'SetupController::checkDB()']);
|
||||
|
||||
return response()->json(['message' => $e->getMessage()], 400);
|
||||
@ -203,17 +204,6 @@ class SetupController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
private function failsafeMailCheck($request)
|
||||
{
|
||||
$response = SystemHealth::testMailServer($request);
|
||||
|
||||
if ($response['success']) {
|
||||
true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function checkPdf(Request $request)
|
||||
{
|
||||
try {
|
||||
@ -231,9 +221,10 @@ class SetupController extends Controller
|
||||
->setHtml('GENERATING PDFs WORKS! Thank you for using Invoice Ninja!')
|
||||
->generate();
|
||||
|
||||
Storage::put('public/test.pdf', $pdf);
|
||||
Storage::disk(config('filesystems.default'))->put('test.pdf', $pdf);
|
||||
Storage::disk('local')->put('test.pdf', $pdf);
|
||||
|
||||
return response(['url' => asset('test.pdf')], 200);
|
||||
return response(['url' => Storage::disk('local')->url('test.pdf')], 200);
|
||||
} catch (Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
|
||||
|
@ -35,6 +35,7 @@ class CheckDatabaseRequest extends Request
|
||||
{
|
||||
return [
|
||||
'db_host' => ['required'],
|
||||
'db_port' => ['required'],
|
||||
'db_database' => ['required'],
|
||||
'db_username' => ['required'],
|
||||
];
|
||||
|
@ -45,7 +45,7 @@ class SystemHealth
|
||||
* @param bool $check_database
|
||||
* @return array Result set of checks
|
||||
*/
|
||||
public static function check($check_database = true) : array
|
||||
public static function check($check_database = true): array
|
||||
{
|
||||
$system_health = true;
|
||||
|
||||
@ -57,7 +57,7 @@ class SystemHealth
|
||||
$system_health = false;
|
||||
}
|
||||
|
||||
if (! self::simpleDbCheck() && $check_database) {
|
||||
if (!self::simpleDbCheck() && $check_database) {
|
||||
info('db fails');
|
||||
$system_health = false;
|
||||
}
|
||||
@ -66,18 +66,18 @@ class SystemHealth
|
||||
'system_health' => $system_health,
|
||||
'extensions' => self::extensions(),
|
||||
'php_version' => [
|
||||
'minimum_php_version' => (string) self::$php_version,
|
||||
'minimum_php_version' => (string)self::$php_version,
|
||||
'current_php_version' => phpversion(),
|
||||
'current_php_cli_version' => (string) self::checkPhpCli(),
|
||||
'current_php_cli_version' => (string)self::checkPhpCli(),
|
||||
'is_okay' => version_compare(phpversion(), self::$php_version, '>='),
|
||||
],
|
||||
'env_writable' => self::checkEnvWritable(),
|
||||
//'mail' => self::testMailServer(),
|
||||
'simple_db_check' => (bool) self::simpleDbCheck(),
|
||||
'simple_db_check' => (bool)self::simpleDbCheck(),
|
||||
'cache_enabled' => self::checkConfigCache(),
|
||||
'phantom_enabled' => (bool) config('ninja.phantomjs_pdf_generation'),
|
||||
'exec' => (bool) self::checkExecWorks(),
|
||||
'open_basedir' => (bool) self::checkOpenBaseDir(),
|
||||
'phantom_enabled' => (bool)config('ninja.phantomjs_pdf_generation'),
|
||||
'exec' => (bool)self::checkExecWorks(),
|
||||
'open_basedir' => (bool)self::checkOpenBaseDir(),
|
||||
];
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ class SystemHealth
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function simpleDbCheck() :bool
|
||||
private static function simpleDbCheck(): bool
|
||||
{
|
||||
$result = true;
|
||||
|
||||
@ -135,7 +135,7 @@ class SystemHealth
|
||||
}
|
||||
}
|
||||
|
||||
private static function extensions() :array
|
||||
private static function extensions(): array
|
||||
{
|
||||
$loaded_extensions = [];
|
||||
|
||||
@ -151,22 +151,23 @@ class SystemHealth
|
||||
$result = ['success' => false];
|
||||
|
||||
if ($request) {
|
||||
config(['database.connections.db-ninja-01.host'=> $request->input('db_host')]);
|
||||
config(['database.connections.db-ninja-01.database'=> $request->input('db_database')]);
|
||||
config(['database.connections.db-ninja-01.username'=> $request->input('db_username')]);
|
||||
config(['database.connections.db-ninja-01.password'=> $request->input('db_password')]);
|
||||
config(['database.connections.db-ninja-01.host' => $request->input('db_host')]);
|
||||
config(['database.connections.db-ninja-01.port' => $request->input('db_port')]);
|
||||
config(['database.connections.db-ninja-01.database' => $request->input('db_database')]);
|
||||
config(['database.connections.db-ninja-01.username' => $request->input('db_username')]);
|
||||
config(['database.connections.db-ninja-01.password' => $request->input('db_password')]);
|
||||
config(['database.default' => 'db-ninja-01']);
|
||||
|
||||
DB::purge('db-ninja-01');
|
||||
}
|
||||
|
||||
if (! config('ninja.db.multi_db_enabled')) {
|
||||
if (!config('ninja.db.multi_db_enabled')) {
|
||||
try {
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$result[] = [DB::connection()->getDatabaseName() => true];
|
||||
$result['success'] = true;
|
||||
} catch (Exception $e) {
|
||||
$result[] = [config('database.connections.'.config('database.default').'.database') => false];
|
||||
$result[] = [config('database.connections.' . config('database.default') . '.database') => false];
|
||||
$result['success'] = false;
|
||||
$result['message'] = $e->getMessage();
|
||||
}
|
||||
@ -179,7 +180,7 @@ class SystemHealth
|
||||
$result[] = [DB::connection()->getDatabaseName() => true];
|
||||
$result['success'] = true;
|
||||
} catch (Exception $e) {
|
||||
$result[] = [config('database.connections.'.config('database.default').'.database') => false];
|
||||
$result[] = [config('database.connections.' . config('database.default') . '.database') => false];
|
||||
$result['success'] = false;
|
||||
$result['message'] = $e->getMessage();
|
||||
}
|
||||
@ -222,6 +223,6 @@ class SystemHealth
|
||||
|
||||
private static function checkEnvWritable()
|
||||
{
|
||||
return is_writable(base_path().'/.env');
|
||||
return is_writable(base_path() . '/.env');
|
||||
}
|
||||
}
|
||||
|
2
public/js/setup/setup.js
vendored
2
public/js/setup/setup.js
vendored
File diff suppressed because one or more lines are too long
@ -15,6 +15,6 @@
|
||||
"/js/clients/quotes/approve.js": "/js/clients/quotes/approve.js?id=85bcae0a646882e56b12",
|
||||
"/js/clients/shared/multiple-downloads.js": "/js/clients/shared/multiple-downloads.js?id=5c35d28cf0a3286e7c45",
|
||||
"/js/clients/shared/pdf.js": "/js/clients/shared/pdf.js?id=fa54bb4229aba6b0817c",
|
||||
"/js/setup/setup.js": "/js/setup/setup.js?id=29e88ab480038cba57df",
|
||||
"/js/setup/setup.js": "/js/setup/setup.js?id=8cb5e2bb0d404725c20a",
|
||||
"/css/card-js.min.css": "/css/card-js.min.css?id=62afeb675235451543ad"
|
||||
}
|
||||
|
7
resources/js/setup/setup.js
vendored
7
resources/js/setup/setup.js
vendored
@ -25,6 +25,7 @@ class Setup {
|
||||
handleDatabaseCheck() {
|
||||
let data = {
|
||||
db_host: document.querySelector('input[name="db_host"]').value,
|
||||
db_port: document.querySelector('input[name="db_port"]').value,
|
||||
db_database: document.querySelector('input[name="db_database"]')
|
||||
.value,
|
||||
db_username: document.querySelector('input[name="db_username"]')
|
||||
@ -33,13 +34,15 @@ class Setup {
|
||||
.value,
|
||||
};
|
||||
|
||||
this.checkDbButton.disabled = true;
|
||||
|
||||
Axios.post('/setup/check_db', data)
|
||||
.then((response) =>
|
||||
this.handleSuccess(this.checkDbAlert, 'mail-wrapper')
|
||||
)
|
||||
.catch((e) =>
|
||||
this.handleFailure(this.checkDbAlert, e.response.data.message)
|
||||
);
|
||||
).finally(() => this.checkDbButton.disabled = false);
|
||||
}
|
||||
|
||||
handleSmtpCheck() {
|
||||
@ -113,7 +116,7 @@ class Setup {
|
||||
document.getElementById(nextStep).classList.remove('hidden');
|
||||
document
|
||||
.getElementById(nextStep)
|
||||
.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
.scrollIntoView({behavior: 'smooth', block: 'center'});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,14 @@ FLUSH PRIVILEGES;
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||
{{ ctrans('texts.port') }}*
|
||||
</dt>
|
||||
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
<input type="text" class="input w-full" name="db_port" required value="{{ old('db_port') ?: '3306'}}">
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||
{{ ctrans('texts.database') }}*
|
||||
</dt>
|
||||
@ -49,15 +57,15 @@ FLUSH PRIVILEGES;
|
||||
<input type="text" class="input w-full" name="db_database" required value="{{ old('database') ?: 'db-ninja-01'}}">
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<dt class="text-sm leading-5 font-medium text-gray-500" value="{{ old('username') }}">
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||
{{ ctrans('texts.username') }}*
|
||||
</dt>
|
||||
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
<input type="text" class="input w-full" name="db_username" required value="{{ old('db_username') ?: 'ninja' }}">
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||
{{ ctrans('texts.password') }}
|
||||
</dt>
|
||||
@ -65,14 +73,14 @@ FLUSH PRIVILEGES;
|
||||
<input type="password" class="input w-full" name="db_password" value="{{ old('db_password') ?: 'ninja' }}">
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
|
||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||
<button type="button" class="button button-primary bg-blue-600 py-2 px-3 text-xs" id="test-db-connection">
|
||||
{{ ctrans('texts.test_connection') }}
|
||||
</button>
|
||||
</dt>
|
||||
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
<div class="alert py-2 bg-gray-50" id="database-response"></div>
|
||||
<div class="alert py-2 bg-white" id="database-response"></div>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
Loading…
x
Reference in New Issue
Block a user