Updates for html cp

This commit is contained in:
David Bomba 2023-07-12 14:55:48 +10:00
parent bff7e056ba
commit 8812286ccb
5 changed files with 37 additions and 29 deletions

View File

@ -206,8 +206,6 @@ class InvoiceController extends Controller
$file = $invoice->service()->getInvoicePdf(auth()->guard('contact')->user());
// return response()->download(file_get_contents(public_path($file)));
return response()->streamDownload(function () use ($file) {
echo Storage::get($file);
}, basename($file), ['Content-Type' => 'application/pdf']);

View File

@ -45,9 +45,13 @@ class PdfSlot extends Component
private $entity_type;
public $download_button_text;
public function mount()
{
MultiDB::setDb($this->db);
$this->download_button_text = ctrans('texts.download_pdf');
}
public function getPdf()
@ -55,6 +59,25 @@ class PdfSlot extends Component
$this->pdf = $this->entity->fullscreenPdfViewer($this->invitation);
}
public function downloadPdf()
{
$this->download_button_text = ctrans('texts.working');
$file_name = $this->entity->numberFormatter().'.pdf';
$file = (new \App\Jobs\Entity\CreateRawPdf($this->invitation, $this->invitation->company->db))->handle();
$headers = ['Content-Type' => 'application/pdf'];
return response()->streamDownload(function () use ($file) {
echo $file;
}, $file_name, $headers);
$this->download_button_text = ctrans('texts.download_pdf');
}
public function render()
{
$this->entity_type = $this->resolveEntityType();

View File

@ -26,6 +26,7 @@ span {
}
</style>
<div class="w-full bg-white py-3 border-2 shadow sm:rounded-lg">
<div class="px-3 border-fuchsia-600 border-b-2 pb-3">

View File

@ -1,4 +1,16 @@
<div>
<div class="flex flex-col items-end mb-2">
<button wire:loading.attr="disabled" wire:click="downloadPdf" class="bg-gray-100 hover:bg-gray-200 text-gray-800 font-bold px-2 rounded inline-flex">
<span>{{ ctrans('texts.download_pdf') }}</span>
<div wire:loading wire:target="downloadPdf">
<svg class="animate-spin h-5 w-5 text-blue" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
</div>
</button>
</div>
<div class="hidden lg:block">
<div wire:init="getPdf()">
@if($pdf)
@ -45,7 +57,7 @@
</div>
</div>
<div class="hidden md:block">
<div class="block lg:hidden">
@include('portal.ninja2020.components.html-viewer')
</div>
</div>

View File

@ -53,32 +53,6 @@
</svg>
</a>
</div>
<div x-data="{ open: false }" @keydown.escape="open = false" @click.away="open = false"
class="relative inline-block text-left">
<div>
<button @click="open = !open"
class="flex items-center text-gray-400 hover:text-gray-600 focus:outline-none focus:text-gray-600">
<svg class="h-5 w-5" fill="currentColor" viewBox="0 0 20 20">
<path
d="M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z" />
</svg>
</button>
</div>
<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 ring-1 ring-black ring-opacity-5">
<div class="py-1">
<a target="_blank" href="{{ $fullscreen_url ?? '?mode=fullscreen' }}"
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>
</div>
</section>
</div>