mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Enable sandboxing with PDFs & fix setup page issues
This commit is contained in:
parent
ad6ae61996
commit
7a5027f1b4
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
@ -30,16 +31,11 @@ use Spatie\Browsershot\Browsershot;
|
||||
*/
|
||||
class SetupController extends Controller
|
||||
{
|
||||
/**
|
||||
* Main setup view.
|
||||
*
|
||||
* @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
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::all()->first()) {
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
@ -53,7 +49,7 @@ class SetupController extends Controller
|
||||
if ($check['system_health'] === false) {
|
||||
info($check);
|
||||
|
||||
return response('Oops, something went wrong. Check your logs.'); /** We should never reach this block, but jic. */
|
||||
return response('Oops, something went wrong. Check your storage/logs/laravel.log file.');
|
||||
}
|
||||
|
||||
$mail_driver = $request->input('mail_driver');
|
||||
@ -64,7 +60,7 @@ class SetupController extends Controller
|
||||
|
||||
$url = $request->input('url');
|
||||
|
||||
if(substr($url, -1) != '/')
|
||||
if (substr($url, -1) != '/')
|
||||
$url = $url . '/';
|
||||
|
||||
$_ENV['APP_KEY'] = config('app.key');
|
||||
@ -106,7 +102,7 @@ class SetupController extends Controller
|
||||
}
|
||||
|
||||
/* Write the .env file */
|
||||
$filePath = base_path().'/.env';
|
||||
$filePath = base_path() . '/.env';
|
||||
$fp = fopen($filePath, 'w');
|
||||
fwrite($fp, $config);
|
||||
fclose($fp);
|
||||
@ -185,7 +181,7 @@ class SetupController extends Controller
|
||||
if ($response_array instanceof Response) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -193,16 +189,16 @@ class SetupController extends Controller
|
||||
public function checkPdf(Request $request)
|
||||
{
|
||||
try {
|
||||
|
||||
if(config('ninja.phantomjs_key')){
|
||||
|
||||
if (config('ninja.phantomjs_key')) {
|
||||
return $this->testPhantom();
|
||||
}
|
||||
|
||||
|
||||
Browsershot::url('https://www.invoiceninja.com')->savePdf(
|
||||
// Browsershot::html('If you see this text, generating PDF works! Thanks for using Invoice Ninja!')->savePdf(
|
||||
public_path('test.pdf')
|
||||
);
|
||||
Browsershot::url('https://www.invoiceninja.com')
|
||||
->noSandbox()
|
||||
->savePdf(
|
||||
public_path('test.pdf')
|
||||
);
|
||||
|
||||
return response(['url' => asset('test.pdf')], 200);
|
||||
} catch (\Exception $e) {
|
||||
@ -216,7 +212,7 @@ class SetupController extends Controller
|
||||
{
|
||||
|
||||
try {
|
||||
|
||||
|
||||
$key = config('ninja.phantomjs_key');
|
||||
$url = 'https://www.invoiceninja.org/';
|
||||
|
||||
@ -227,14 +223,9 @@ class SetupController extends Controller
|
||||
Storage::disk('local')->put('test.pdf', $pdf);
|
||||
|
||||
return response(['url' => Storage::disk('local')->url('test.pdf')], 200);
|
||||
|
||||
}
|
||||
catch(\Exception $e){
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
return response([], 500);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,8 +40,8 @@ trait PdfMaker
|
||||
->showBackground()
|
||||
->deviceScaleFactor(1)
|
||||
->waitUntilNetworkIdle(true)
|
||||
->noSandbox()
|
||||
->pdf();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,42 +61,6 @@
|
||||
@endif
|
||||
</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.npm_status') }}
|
||||
</dt>
|
||||
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
@if($check['npm_status'])
|
||||
<span class="alert alert-success block flex justify-between items-center">
|
||||
<span>{{ $check['npm_status'] }} => {{ strtoupper(ctrans('texts.ok')) }}</span>
|
||||
<span>✔</span>
|
||||
</span>
|
||||
@else
|
||||
<span class="alert alert-failure block flex justify-between items-center">
|
||||
<span>{{ ctrans('texts.npm_status_not_found') }}</span>
|
||||
<span>❌</span>
|
||||
</span>
|
||||
@endif
|
||||
</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.node_status') }}
|
||||
</dt>
|
||||
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
@if($check['node_status'])
|
||||
<span class="alert alert-success block flex justify-between items-center">
|
||||
<span>{{ $check['node_status'] }} => {{ strtoupper(ctrans('texts.ok')) }}</span>
|
||||
<span>✔</span>
|
||||
</span>
|
||||
@else
|
||||
<span class="alert alert-failure block flex justify-between items-center">
|
||||
<span>{{ ctrans('texts.node_status_not_found') }}</span>
|
||||
<span>❌</span>
|
||||
</span>
|
||||
@endif
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
@ -25,6 +25,7 @@ class PdfGenerationTest extends TestCase
|
||||
//->footerHtml($footer)
|
||||
->waitUntilNetworkIdle()
|
||||
//->margins(10,10,10,10)
|
||||
->noSandbox()
|
||||
->savePdf($pdf);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user