Added download button in shared editor page #1517
@@ -6,6 +6,7 @@ use App\Models\Configuration;
|
|||||||
use App\Models\SharedClipBoard;
|
use App\Models\SharedClipBoard;
|
||||||
use Filament\Pages\Page;
|
use Filament\Pages\Page;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
|
||||||
class SharedEditor extends Page
|
class SharedEditor extends Page
|
||||||
{
|
{
|
||||||
@@ -61,6 +62,20 @@ class SharedEditor extends Page
|
|||||||
{
|
{
|
||||||
$this->dispatch('copy-to-clipboard', content: $this->content);
|
$this->dispatch('copy-to-clipboard', content: $this->content);
|
||||||
}
|
}
|
||||||
|
public function downloadTxt(): StreamedResponse
|
||||||
|
{
|
||||||
|
$content = $this->content;
|
||||||
|
|
||||||
|
return response()->streamDownload(
|
||||||
|
function () use ($content) {
|
||||||
|
echo $content;
|
||||||
|
},
|
||||||
|
'shared-clipboard.txt',
|
||||||
|
[
|
||||||
|
'Content-Type' => 'text/plain; charset=UTF-8',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static function canAccess(): bool
|
public static function canAccess(): bool
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,20 +43,14 @@
|
|||||||
|
|
||||||
<div wire:poll.1s="refreshSharedContent" class="space-y-4">
|
<div wire:poll.1s="refreshSharedContent" class="space-y-4">
|
||||||
|
|
||||||
{{-- Header --}}
|
<div class="flex items-center justify-start">
|
||||||
<div class="flex items-center justify-between gap-4">
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<h2 class="text-lg font-semibold text-gray-900 dark:text-white">
|
|
||||||
Shared Clipboard
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<p class="text-sm text-gray-500 dark:text-gray-400">
|
<p class="text-sm text-gray-500 dark:text-gray-400">
|
||||||
Type here to share content with other users.
|
Type here to share content with other users.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Clear Button --}}
|
<div class="flex items-center justify-end gap-2">
|
||||||
|
|
||||||
<x-filament::button
|
<x-filament::button
|
||||||
color="info"
|
color="info"
|
||||||
icon="heroicon-o-clipboard"
|
icon="heroicon-o-clipboard"
|
||||||
@@ -64,10 +58,18 @@
|
|||||||
>
|
>
|
||||||
Copy To ClipBoard
|
Copy To ClipBoard
|
||||||
</x-filament::button>
|
</x-filament::button>
|
||||||
|
{{-- @if (auth()->user()?->hasRole('Super Admin')) --}}
|
||||||
|
<x-filament::button
|
||||||
|
color="success"
|
||||||
|
icon="heroicon-o-arrow-down-tray"
|
||||||
|
wire:click="downloadTxt"
|
||||||
|
>
|
||||||
|
Download Txt
|
||||||
|
</x-filament::button>
|
||||||
|
{{-- @endif --}}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Shared Textarea --}}
|
|
||||||
<div>
|
<div>
|
||||||
<textarea
|
<textarea
|
||||||
wire:model.live.debounce.500ms="content"
|
wire:model.live.debounce.500ms="content"
|
||||||
@@ -78,7 +80,6 @@
|
|||||||
></textarea>
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Footer --}}
|
|
||||||
<div class="flex items-center justify-between text-xs text-gray-500 dark:text-gray-400">
|
<div class="flex items-center justify-between text-xs text-gray-500 dark:text-gray-400">
|
||||||
|
|
||||||
<span>
|
<span>
|
||||||
|
|||||||
Reference in New Issue
Block a user