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,8 +48,16 @@ class ReactBuilder extends Command
|
|||||||
{
|
{
|
||||||
$includes = '';
|
$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) {
|
foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) {
|
||||||
if ($file->getExtension() == 'js') {
|
if ($file->getExtension() == 'js') {
|
||||||
if (str_contains($file->getFileName(), 'index-')) {
|
if (str_contains($file->getFileName(), 'index-')) {
|
||||||
|
@ -87,6 +87,12 @@ class InvoiceController extends Controller
|
|||||||
public function showBlob($hash)
|
public function showBlob($hash)
|
||||||
{
|
{
|
||||||
$data = Cache::get($hash);
|
$data = Cache::get($hash);
|
||||||
|
|
||||||
|
if(!$data){
|
||||||
|
usleep(200000);
|
||||||
|
$data = Cache::get($hash);
|
||||||
|
}
|
||||||
|
|
||||||
$invitation = false;
|
$invitation = false;
|
||||||
|
|
||||||
match($data['entity_type'] ?? false){
|
match($data['entity_type'] ?? false){
|
||||||
|
@ -59,11 +59,16 @@ class PdfSlot extends Component
|
|||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
MultiDB::setDb($this->db);
|
MultiDB::setDb($this->db);
|
||||||
|
|
||||||
|
if(!$this->invitation) {
|
||||||
|
$this->entity->service()->createInvitations();
|
||||||
|
$this->invitation = $this->entity->invitations()->first();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPdf()
|
public function getPdf()
|
||||||
{
|
{
|
||||||
// $this->pdf = $this->entity->fullscreenPdfViewer($this->invitation);
|
|
||||||
|
|
||||||
$blob = [
|
$blob = [
|
||||||
'entity_type' => $this->resolveEntityType(),
|
'entity_type' => $this->resolveEntityType(),
|
||||||
@ -74,7 +79,7 @@ class PdfSlot extends Component
|
|||||||
|
|
||||||
$hash = Str::random(64);
|
$hash = Str::random(64);
|
||||||
|
|
||||||
Cache::put($hash, $blob, now()->addMinutes(2));
|
Cache::put($hash, $blob, 1800);
|
||||||
|
|
||||||
$this->pdf = $hash;
|
$this->pdf = $hash;
|
||||||
|
|
||||||
|
@ -2766,11 +2766,15 @@ paths:
|
|||||||
parameters:
|
parameters:
|
||||||
- $ref: "#/components/parameters/X-Requested-With"
|
- $ref: "#/components/parameters/X-Requested-With"
|
||||||
requestBody:
|
requestBody:
|
||||||
description: "The template subject and body"
|
description: "Required fields to send an email"
|
||||||
required: true
|
required: true
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
|
required:
|
||||||
|
- entity
|
||||||
|
- entity_id
|
||||||
|
- template
|
||||||
properties:
|
properties:
|
||||||
subject:
|
subject:
|
||||||
description: "The email subject"
|
description: "The email subject"
|
||||||
@ -2784,9 +2788,13 @@ paths:
|
|||||||
entity_id:
|
entity_id:
|
||||||
description: "The entity_id"
|
description: "The entity_id"
|
||||||
type: string
|
type: string
|
||||||
|
cc_email:
|
||||||
|
description: "The email address of a user to be CC'd on the email"
|
||||||
|
type: string
|
||||||
template:
|
template:
|
||||||
description: "The template required"
|
description: "The template required"
|
||||||
type: string
|
type: string
|
||||||
|
example: invoice,quote,credit,purchase_order,payment,payment_partial,reminder1,reminder2,reminder3,reminder_endless
|
||||||
type: object
|
type: object
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
@ -11226,7 +11234,22 @@ paths:
|
|||||||
tags:
|
tags:
|
||||||
- invoices
|
- invoices
|
||||||
summary: "Create invoice"
|
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
|
operationId: storeInvoice
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: "#/components/parameters/X-API-TOKEN"
|
- $ref: "#/components/parameters/X-API-TOKEN"
|
||||||
@ -11315,7 +11338,22 @@ paths:
|
|||||||
tags:
|
tags:
|
||||||
- invoices
|
- invoices
|
||||||
summary: "Update invoice"
|
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
|
operationId: updateInvoice
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: "#/components/parameters/X-API-TOKEN"
|
- $ref: "#/components/parameters/X-API-TOKEN"
|
||||||
@ -16746,6 +16784,10 @@ components:
|
|||||||
description: 'Toggles charging taxes on custom surcharge amounts'
|
description: 'Toggles charging taxes on custom surcharge amounts'
|
||||||
type: boolean
|
type: boolean
|
||||||
example: true
|
example: true
|
||||||
|
project_id:
|
||||||
|
description: 'The project associated with this invoice'
|
||||||
|
type: string
|
||||||
|
example: Opnel5aKBz
|
||||||
type: object
|
type: object
|
||||||
FillableInvoice:
|
FillableInvoice:
|
||||||
properties:
|
properties:
|
||||||
@ -19032,6 +19074,10 @@ components:
|
|||||||
description: 'Toggles charging taxes on custom surcharge amounts'
|
description: 'Toggles charging taxes on custom surcharge amounts'
|
||||||
type: boolean
|
type: boolean
|
||||||
example: true
|
example: true
|
||||||
|
project_id:
|
||||||
|
description: 'The project associated with this invoice'
|
||||||
|
type: string
|
||||||
|
example: Opnel5aKBz
|
||||||
type: object
|
type: object
|
||||||
ClientRequest:
|
ClientRequest:
|
||||||
required:
|
required:
|
||||||
|
@ -219,4 +219,8 @@
|
|||||||
description: 'Toggles charging taxes on custom surcharge amounts'
|
description: 'Toggles charging taxes on custom surcharge amounts'
|
||||||
type: boolean
|
type: boolean
|
||||||
example: true
|
example: true
|
||||||
|
project_id:
|
||||||
|
description: 'The project associated with this invoice'
|
||||||
|
type: string
|
||||||
|
example: Opnel5aKBz
|
||||||
type: object
|
type: object
|
@ -234,4 +234,8 @@
|
|||||||
description: 'Toggles charging taxes on custom surcharge amounts'
|
description: 'Toggles charging taxes on custom surcharge amounts'
|
||||||
type: boolean
|
type: boolean
|
||||||
example: true
|
example: true
|
||||||
|
project_id:
|
||||||
|
description: 'The project associated with this invoice'
|
||||||
|
type: string
|
||||||
|
example: Opnel5aKBz
|
||||||
type: object
|
type: object
|
@ -2742,11 +2742,15 @@ paths:
|
|||||||
parameters:
|
parameters:
|
||||||
- $ref: "#/components/parameters/X-Requested-With"
|
- $ref: "#/components/parameters/X-Requested-With"
|
||||||
requestBody:
|
requestBody:
|
||||||
description: "The template subject and body"
|
description: "Required fields to send an email"
|
||||||
required: true
|
required: true
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
|
required:
|
||||||
|
- entity
|
||||||
|
- entity_id
|
||||||
|
- template
|
||||||
properties:
|
properties:
|
||||||
subject:
|
subject:
|
||||||
description: "The email subject"
|
description: "The email subject"
|
||||||
@ -2760,9 +2764,13 @@ paths:
|
|||||||
entity_id:
|
entity_id:
|
||||||
description: "The entity_id"
|
description: "The entity_id"
|
||||||
type: string
|
type: string
|
||||||
|
cc_email:
|
||||||
|
description: "The email address of a user to be CC'd on the email"
|
||||||
|
type: string
|
||||||
template:
|
template:
|
||||||
description: "The template required"
|
description: "The template required"
|
||||||
type: string
|
type: string
|
||||||
|
example: invoice,quote,credit,purchase_order,payment,payment_partial,reminder1,reminder2,reminder3,reminder_endless
|
||||||
type: object
|
type: object
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
|
@ -132,7 +132,22 @@
|
|||||||
tags:
|
tags:
|
||||||
- invoices
|
- invoices
|
||||||
summary: "Create invoice"
|
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
|
operationId: storeInvoice
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: "#/components/parameters/X-API-TOKEN"
|
- $ref: "#/components/parameters/X-API-TOKEN"
|
||||||
@ -221,7 +236,22 @@
|
|||||||
tags:
|
tags:
|
||||||
- invoices
|
- invoices
|
||||||
summary: "Update invoice"
|
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
|
operationId: updateInvoice
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: "#/components/parameters/X-API-TOKEN"
|
- $ref: "#/components/parameters/X-API-TOKEN"
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
</section>
|
</section>
|
||||||
</div>
|
</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)
|
@if($mobile)
|
||||||
@push('footer')
|
@push('footer')
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
@include('portal.ninja2020.components.entity-documents', ['entity' => $credit])
|
@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
|
@endsection
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
@include('portal.ninja2020.components.entity-documents', ['entity' => $invoice])
|
@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
|
@endsection
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
@include('portal.ninja2020.components.entity-documents', ['entity' => $purchase_order])
|
@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
|
@endsection
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
@include('portal.ninja2020.components.entity-documents', ['entity' => $quote])
|
@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
|
@endsection
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user