Fixes for self hosted setup

This commit is contained in:
David Bomba 2022-05-26 12:00:53 +10:00
parent e09f1abf73
commit f5e24de767
3 changed files with 37 additions and 25 deletions

View File

@ -48,14 +48,14 @@ class SetupController extends Controller
public function index()
{
$check = SystemHealth::check(false);
if ($check['system_health'] == true && $check['simple_db_check'] && Schema::hasTable('accounts') && $account = Account::all()->first()) {
if ($check['system_health'] == true && $check['simple_db_check'] && Schema::hasTable('accounts') && $account = Account::first()) {
return redirect('/');
}
if(Ninja::isHosted())
return redirect('/');
return view('setup.index', ['check' => $check]);
}
@ -211,29 +211,31 @@ class SetupController extends Controller
public function checkPdf(Request $request)
{
try {
if (config('ninja.pdf_generator') == 'phantom') {
return $this->testPhantom();
}
$pdf = new Snappdf();
// if (config('ninja.pdf_generator') == 'phantom') {
// return $this->testPhantom();
// }
if (config('ninja.snappdf_chromium_path')) {
$pdf->setChromiumPath(config('ninja.snappdf_chromium_path'));
}
// $pdf = new Snappdf();
if (config('ninja.snappdf_chromium_arguments')) {
$pdf->clearChromiumArguments();
$pdf->addChromiumArguments(config('ninja.snappdf_chromium_arguments'));
}
// if (config('ninja.snappdf_chromium_path')) {
// $pdf->setChromiumPath(config('ninja.snappdf_chromium_path'));
// }
$pdf = $pdf
->setHtml('GENERATING PDFs WORKS! Thank you for using Invoice Ninja!')
->generate();
// if (config('ninja.snappdf_chromium_arguments')) {
// $pdf->clearChromiumArguments();
// $pdf->addChromiumArguments(config('ninja.snappdf_chromium_arguments'));
// }
Storage::disk(config('filesystems.default'))->put('test.pdf', $pdf);
Storage::disk('local')->put('test.pdf', $pdf);
// $pdf = $pdf
// ->setHtml('GENERATING PDFs WORKS! Thank you for using Invoice Ninja!')
// ->generate();
return response(['url' => Storage::disk('local')->url('test.pdf')], 200);
// Storage::disk(config('filesystems.default'))->put('test.pdf', $pdf);
// Storage::disk('local')->put('test.pdf', $pdf);
return response(['url' => ''], 200);
// return response(['url' => Storage::disk('local')->url('test.pdf')], 200);
} catch (Exception $e) {
nlog($e->getMessage());

View File

@ -77,7 +77,7 @@ class SystemHealth
'open_basedir' => (bool)self::checkOpenBaseDir(),
'mail_mailer' => (string)self::checkMailMailer(),
'flutter_renderer' => (string)config('ninja.flutter_canvas_kit'),
'jobs_pending' => (int) Queue::size(),
'jobs_pending' => (int) self::checkQueueSize(),
'pdf_engine' => (string) self::getPdfEngine(),
'queue' => (string) config('queue.default'),
'trailing_slash' => (bool) self::checkUrlState(),
@ -85,6 +85,20 @@ class SystemHealth
];
}
private static function checkQueueSize()
{
$count = 0;
try{
$count = Queue::size();
}
catch(\Exception $e){
}
return $count;
}
public static function checkFileSystem()
{

View File

@ -52,10 +52,6 @@
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<div class="alert py-2 bg-white" id="test-pdf-response"></div>
</dd>
<a target="_blank" class="block text-sm text-gray-900 leading-5 underline"
href="https://invoiceninja.github.io/docs/self-host-troubleshooting/#pdf-conversion-issues">
{{ ctrans('texts.setup_phantomjs_note') }}
</a>
</div>
</dl>
</div>