mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #8843 from turbo124/v5-develop
Improve resiliency of pdf previews
This commit is contained in:
commit
ea8381fd11
@ -48,7 +48,15 @@ class ReactBuilder extends Command
|
||||
{
|
||||
$includes = '';
|
||||
|
||||
$directoryIterator = new \RecursiveDirectoryIterator(public_path('react/v'.config('ninja.app_version').'/'), \RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
$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') {
|
||||
|
@ -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){
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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
|
@ -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
|
@ -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:
|
||||
|
@ -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"
|
||||
|
@ -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')
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user