Merge pull request #8843 from turbo124/v5-develop

Improve resiliency of pdf previews
This commit is contained in:
David Bomba 2023-10-01 11:46:36 +11:00 committed by GitHub
commit ea8381fd11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 125 additions and 14 deletions

View File

@ -48,7 +48,15 @@ class ReactBuilder extends Command
{
$includes = '';
$directoryIterator = false;
try {
$directoryIterator = new \RecursiveDirectoryIterator(public_path('react/v'.config('ninja.app_version').'/'), \RecursiveDirectoryIterator::SKIP_DOTS);
}
catch (\Exception $e) {
$this->error('React files not found');
return;
}
foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) {
if ($file->getExtension() == 'js') {

View File

@ -87,6 +87,12 @@ class InvoiceController extends Controller
public function showBlob($hash)
{
$data = Cache::get($hash);
if(!$data){
usleep(200000);
$data = Cache::get($hash);
}
$invitation = false;
match($data['entity_type'] ?? false){

View File

@ -59,11 +59,16 @@ class PdfSlot extends Component
public function mount()
{
MultiDB::setDb($this->db);
if(!$this->invitation) {
$this->entity->service()->createInvitations();
$this->invitation = $this->entity->invitations()->first();
}
}
public function getPdf()
{
// $this->pdf = $this->entity->fullscreenPdfViewer($this->invitation);
$blob = [
'entity_type' => $this->resolveEntityType(),
@ -74,7 +79,7 @@ class PdfSlot extends Component
$hash = Str::random(64);
Cache::put($hash, $blob, now()->addMinutes(2));
Cache::put($hash, $blob, 1800);
$this->pdf = $hash;

View File

@ -2766,11 +2766,15 @@ paths:
parameters:
- $ref: "#/components/parameters/X-Requested-With"
requestBody:
description: "The template subject and body"
description: "Required fields to send an email"
required: true
content:
application/json:
schema:
required:
- entity
- entity_id
- template
properties:
subject:
description: "The email subject"
@ -2784,9 +2788,13 @@ paths:
entity_id:
description: "The entity_id"
type: string
cc_email:
description: "The email address of a user to be CC'd on the email"
type: string
template:
description: "The template required"
type: string
example: invoice,quote,credit,purchase_order,payment,payment_partial,reminder1,reminder2,reminder3,reminder_endless
type: object
responses:
200:
@ -11226,7 +11234,22 @@ paths:
tags:
- invoices
summary: "Create invoice"
description: "Adds a invoice to a company"
description: |
Adds a invoice to a company
Triggered actions are available when updating or creating an invoice.
These are query parameters that can be chained in order to perform additional actions on the entity, these include:
```
?send_email=true [Saves and sends the invoice]
?mark_sent=true [Saves and marks the invoice as sent]
?paid=true [Saves and marks the invoice as paid]
?amount_paid=100 [Saves and marks the invoice as paid with the given amount]
?cancel=true [Saves and marks the invoice as cancelled]
?save_default_footer=true [Saves the current footer as the default footer]
?save_default_terms=true [Saves the current terms as the default terms]
```
operationId: storeInvoice
parameters:
- $ref: "#/components/parameters/X-API-TOKEN"
@ -11315,7 +11338,22 @@ paths:
tags:
- invoices
summary: "Update invoice"
description: "Handles the updating of an invoice by id"
description: |
Handles the updating of an invoice by id.
Triggered actions are available when updating or creating an invoice.
These are query parameters that can be chained in order to perform additional actions on the entity, these include:
```
?send_email=true [Saves and sends the invoice]
?mark_sent=true [Saves and marks the invoice as sent]
?paid=true [Saves and marks the invoice as paid]
?amount_paid=100 [Saves and marks the invoice as paid with the given amount]
?cancel=true [Saves and marks the invoice as cancelled]
?save_default_footer=true [Saves the current footer as the default footer]
?save_default_terms=true [Saves the current terms as the default terms]
```
operationId: updateInvoice
parameters:
- $ref: "#/components/parameters/X-API-TOKEN"
@ -16746,6 +16784,10 @@ components:
description: 'Toggles charging taxes on custom surcharge amounts'
type: boolean
example: true
project_id:
description: 'The project associated with this invoice'
type: string
example: Opnel5aKBz
type: object
FillableInvoice:
properties:
@ -19032,6 +19074,10 @@ components:
description: 'Toggles charging taxes on custom surcharge amounts'
type: boolean
example: true
project_id:
description: 'The project associated with this invoice'
type: string
example: Opnel5aKBz
type: object
ClientRequest:
required:

View File

@ -219,4 +219,8 @@
description: 'Toggles charging taxes on custom surcharge amounts'
type: boolean
example: true
project_id:
description: 'The project associated with this invoice'
type: string
example: Opnel5aKBz
type: object

View File

@ -234,4 +234,8 @@
description: 'Toggles charging taxes on custom surcharge amounts'
type: boolean
example: true
project_id:
description: 'The project associated with this invoice'
type: string
example: Opnel5aKBz
type: object

View File

@ -2742,11 +2742,15 @@ paths:
parameters:
- $ref: "#/components/parameters/X-Requested-With"
requestBody:
description: "The template subject and body"
description: "Required fields to send an email"
required: true
content:
application/json:
schema:
required:
- entity
- entity_id
- template
properties:
subject:
description: "The email subject"
@ -2760,9 +2764,13 @@ paths:
entity_id:
description: "The entity_id"
type: string
cc_email:
description: "The email address of a user to be CC'd on the email"
type: string
template:
description: "The template required"
type: string
example: invoice,quote,credit,purchase_order,payment,payment_partial,reminder1,reminder2,reminder3,reminder_endless
type: object
responses:
200:

View File

@ -132,7 +132,22 @@
tags:
- invoices
summary: "Create invoice"
description: "Adds a invoice to a company"
description: |
Adds a invoice to a company
Triggered actions are available when updating or creating an invoice.
These are query parameters that can be chained in order to perform additional actions on the entity, these include:
```
?send_email=true [Saves and sends the invoice]
?mark_sent=true [Saves and marks the invoice as sent]
?paid=true [Saves and marks the invoice as paid]
?amount_paid=100 [Saves and marks the invoice as paid with the given amount]
?cancel=true [Saves and marks the invoice as cancelled]
?save_default_footer=true [Saves the current footer as the default footer]
?save_default_terms=true [Saves the current terms as the default terms]
```
operationId: storeInvoice
parameters:
- $ref: "#/components/parameters/X-API-TOKEN"
@ -221,7 +236,22 @@
tags:
- invoices
summary: "Update invoice"
description: "Handles the updating of an invoice by id"
description: |
Handles the updating of an invoice by id.
Triggered actions are available when updating or creating an invoice.
These are query parameters that can be chained in order to perform additional actions on the entity, these include:
```
?send_email=true [Saves and sends the invoice]
?mark_sent=true [Saves and marks the invoice as sent]
?paid=true [Saves and marks the invoice as paid]
?amount_paid=100 [Saves and marks the invoice as paid with the given amount]
?cancel=true [Saves and marks the invoice as cancelled]
?save_default_footer=true [Saves the current footer as the default footer]
?save_default_terms=true [Saves the current terms as the default terms]
```
operationId: updateInvoice
parameters:
- $ref: "#/components/parameters/X-API-TOKEN"

View File

@ -46,7 +46,7 @@
</section>
</div>
@livewire('pdf-slot', ['entity' => $entity, 'invitation' => $invitation, 'db' => $invitation->company->db])
@livewire('pdf-slot', ['entity' => $entity, 'invitation' => $invitation, 'db' => $entity->company->db])
@if($mobile)
@push('footer')

View File

@ -25,7 +25,7 @@
</div>
@include('portal.ninja2020.components.entity-documents', ['entity' => $credit])
@livewire('pdf-slot', ['entity' => $credit, 'invitation' => $invitation, 'db' => $invitation->company->db])
@livewire('pdf-slot', ['entity' => $credit, 'invitation' => $invitation, 'db' => $credit->company->db])
@endsection

View File

@ -95,7 +95,7 @@
@endif
@include('portal.ninja2020.components.entity-documents', ['entity' => $invoice])
@livewire('pdf-slot', ['entity' => $invoice, 'invitation' => $invitation, 'db' => $invitation->company->db])
@livewire('pdf-slot', ['entity' => $invoice, 'invitation' => $invitation, 'db' => $invoice->company->db])
@endsection

View File

@ -46,7 +46,7 @@
@endif
@include('portal.ninja2020.components.entity-documents', ['entity' => $purchase_order])
@livewire('pdf-slot', ['entity' => $purchase_order, 'invitation' => $invitation, 'db' => $invitation->company->db])
@livewire('pdf-slot', ['entity' => $purchase_order, 'invitation' => $invitation, 'db' => $purchase_order->company->db])
@endsection

View File

@ -100,7 +100,7 @@
@endif
@include('portal.ninja2020.components.entity-documents', ['entity' => $quote])
@livewire('pdf-slot', ['entity' => $quote, 'invitation' => $invitation, 'db' => $invitation->company->db])
@livewire('pdf-slot', ['entity' => $quote, 'invitation' => $invitation, 'db' => $quote->company->db])
@endsection