mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 14:12:44 +01:00
Fixes for PDF display latency
This commit is contained in:
parent
7005c6ffe8
commit
7bf74e012c
@ -64,7 +64,7 @@ class CreateEntityPdf implements ShouldQueue
|
||||
*
|
||||
* @param $invitation
|
||||
*/
|
||||
public function __construct($invitation)
|
||||
public function __construct($invitation, $disk = 'public')
|
||||
{
|
||||
$this->invitation = $invitation;
|
||||
|
||||
@ -86,7 +86,7 @@ class CreateEntityPdf implements ShouldQueue
|
||||
|
||||
$this->contact = $invitation->contact;
|
||||
|
||||
$this->disk = 'public';
|
||||
$this->disk = $disk;
|
||||
|
||||
// $this->disk = $disk ?? config('filesystems.default');
|
||||
}
|
||||
@ -194,12 +194,12 @@ class CreateEntityPdf implements ShouldQueue
|
||||
try{
|
||||
|
||||
Storage::disk($this->disk)->put($file_path, $pdf);
|
||||
|
||||
|
||||
}
|
||||
catch(\Exception $e)
|
||||
{
|
||||
|
||||
throw new FilePermissionsFailure('Could not write the PDF, permission issues!');
|
||||
throw new FilePermissionsFailure($e->getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
@ -211,8 +211,5 @@ class CreateEntityPdf implements ShouldQueue
|
||||
{
|
||||
|
||||
}
|
||||
// public function failed(\Exception $exception)
|
||||
// {
|
||||
// nlog("help!");
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ class Credit extends BaseModel
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function pdf_file_path($invitation = null, string $type = 'path')
|
||||
public function pdf_file_path($invitation = null, string $type = 'path', bool $portal = false)
|
||||
{
|
||||
if (! $invitation) {
|
||||
|
||||
@ -267,11 +267,15 @@ class Credit extends BaseModel
|
||||
if(!$invitation)
|
||||
throw new \Exception('Hard fail, could not create an invitation - is there a valid contact?');
|
||||
|
||||
$file_path = $this->client->credit_filepath().$this->numberFormatter().'.pdf';
|
||||
|
||||
if(Storage::disk('public')->exists($file_path))
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
|
||||
$file_path = CreateEntityPdf::dispatchNow($invitation);
|
||||
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
}
|
||||
|
||||
public function markInvitationsSent()
|
||||
{
|
||||
$this->invitations->each(function ($invitation) {
|
||||
|
@ -392,7 +392,7 @@ class Invoice extends BaseModel
|
||||
return $invoice_calc->build();
|
||||
}
|
||||
|
||||
public function pdf_file_path($invitation = null, string $type = 'path')
|
||||
public function pdf_file_path($invitation = null, string $type = 'path', bool $portal = false)
|
||||
{
|
||||
if (! $invitation) {
|
||||
|
||||
@ -408,6 +408,11 @@ class Invoice extends BaseModel
|
||||
if(!$invitation)
|
||||
throw new \Exception('Hard fail, could not create an invitation - is there a valid contact?');
|
||||
|
||||
$file_path = $this->client->invoice_filepath().$this->numberFormatter().'.pdf';
|
||||
|
||||
if(Storage::disk('public')->exists($file_path))
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
|
||||
$file_path = CreateEntityPdf::dispatchNow($invitation);
|
||||
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
|
@ -207,7 +207,7 @@ class Quote extends BaseModel
|
||||
}
|
||||
|
||||
|
||||
public function pdf_file_path($invitation = null, string $type = 'path')
|
||||
public function pdf_file_path($invitation = null, string $type = 'path', bool $portal = false)
|
||||
{
|
||||
if (! $invitation) {
|
||||
|
||||
@ -223,13 +223,16 @@ class Quote extends BaseModel
|
||||
if(!$invitation)
|
||||
throw new \Exception('Hard fail, could not create an invitation - is there a valid contact?');
|
||||
|
||||
$file_path = $this->client->quote_filepath().$this->numberFormatter().'.pdf';
|
||||
|
||||
if(Storage::disk('public')->exists($file_path))
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
|
||||
$file_path = CreateEntityPdf::dispatchNow($invitation);
|
||||
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param int $status
|
||||
* @return string
|
||||
|
@ -2,7 +2,7 @@
|
||||
@section('meta_title', ctrans('texts.entity_number_placeholder', ['entity' => ctrans('texts.credit'), 'entity_number' => $credit->number]))
|
||||
|
||||
@push('head')
|
||||
<meta name="pdf-url" content="{{ $credit->pdf_file_path(null, 'url') }}">
|
||||
<meta name="pdf-url" content="{{ $credit->pdf_file_path(null, 'url', true) }}">
|
||||
<script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script>
|
||||
@endpush
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
<iframe src="{{ $invoice->pdf_file_path(null, 'url') }}"
|
||||
<iframe src="{{ $invoice->pdf_file_path(null, 'url', true) }}"
|
||||
style="position:fixed; top:0; left:0; bottom:0; right:0; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;"></iframe>
|
||||
|
@ -2,7 +2,7 @@
|
||||
@section('meta_title', ctrans('texts.view_invoice'))
|
||||
|
||||
@push('head')
|
||||
<meta name="pdf-url" content="{{ $invoice->pdf_file_path(null, 'url') }}">
|
||||
<meta name="pdf-url" content="{{ $invoice->pdf_file_path(null, 'url', true) }}">
|
||||
<meta name="show-invoice-terms" content="{{ $settings->show_accept_invoice_terms ? true : false }}">
|
||||
<meta name="require-invoice-signature" content="{{ $client->user->account->hasFeature(\App\Models\Account::FEATURE_INVOICE_SETTINGS) && $settings->require_invoice_signature }}">
|
||||
<script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script>
|
||||
@ -174,7 +174,7 @@
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<iframe src="{{ $invoice->pdf_file_path(null, 'url') }}" class="h-screen w-full border-0 hidden lg:block mt-4"></iframe>
|
||||
<iframe src="{{ $invoice->pdf_file_path(null, 'url', true) }}" class="h-screen w-full border-0 hidden lg:block mt-4"></iframe>
|
||||
|
||||
<div class="flex justify-center">
|
||||
<canvas id="pdf-placeholder" class="shadow rounded-lg bg-white lg:hidden mt-4 p-4"></canvas>
|
||||
|
@ -1,2 +1,2 @@
|
||||
<iframe src="{{ $quote->pdf_file_path(null,'url') }}"
|
||||
<iframe src="{{ $quote->pdf_file_path(null,'url',true) }}"
|
||||
style="position:fixed; top:0; left:0; bottom:0; right:0; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;"></iframe>
|
||||
|
@ -2,7 +2,7 @@
|
||||
@section('meta_title', ctrans('texts.entity_number_placeholder', ['entity' => ctrans('texts.quote'), 'entity_number' => $quote->number]))
|
||||
|
||||
@push('head')
|
||||
<meta name="pdf-url" content="{{ asset($quote->pdf_file_path(null, 'url')) }}">
|
||||
<meta name="pdf-url" content="{{ asset($quote->pdf_file_path(null, 'url', true)) }}">
|
||||
<script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script>
|
||||
|
||||
<meta name="show-quote-terms" content="{{ $settings->show_accept_quote_terms ? true : false }}">
|
||||
@ -78,7 +78,7 @@
|
||||
<canvas id="pdf-placeholder" class="shadow rounded-lg bg-white lg:hidden mt-4 p-4"></canvas>
|
||||
</div>
|
||||
|
||||
<iframe src="{{ $quote->pdf_file_path(null, 'url') }}" class="h-screen w-full border-0 hidden lg:block mt-4"></iframe>
|
||||
<iframe src="{{ $quote->pdf_file_path(null, 'url',true) }}" class="h-screen w-full border-0 hidden lg:block mt-4"></iframe>
|
||||
|
||||
@include('portal.ninja2020.invoices.includes.terms', ['entities' => [$quote], 'entity_type' => ctrans('texts.quote')])
|
||||
@include('portal.ninja2020.invoices.includes.signature')
|
||||
|
@ -1,7 +1,7 @@
|
||||
@extends('portal.ninja2020.layout.clean')
|
||||
|
||||
@push('head')
|
||||
<meta name="pdf-url" content="{{ asset($entity->pdf_file_path(null, 'url')) }}">
|
||||
<meta name="pdf-url" content="{{ asset($entity->pdf_file_path(null, 'url',true)) }}">
|
||||
<script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.7.x/dist/alpine.min.js" defer></script>
|
||||
@endpush
|
||||
@ -39,7 +39,7 @@
|
||||
<div x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="transform opacity-0 scale-95" x-transition:enter-end="transform opacity-100 scale-100" x-transition:leave="transition ease-in duration-75" x-transition:leave-start="transform opacity-100 scale-100" x-transition:leave-end="transform opacity-0 scale-95" class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg">
|
||||
<div class="rounded-md bg-white shadow-xs">
|
||||
<div class="py-1">
|
||||
<a target="_blank" href="{{ asset($entity->pdf_file_path(null, 'url')) }}" class="block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900">{{ ctrans('texts.open_in_new_tab') }}</a>
|
||||
<a target="_blank" href="{{ asset($entity->pdf_file_path(null, 'url',true)) }}" class="block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900">{{ ctrans('texts.open_in_new_tab') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user