sparkbooth anbindung optimiert
This commit is contained in:
88
app/Filament/Pages/SparkboothConnections.php
Normal file
88
app/Filament/Pages/SparkboothConnections.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Gallery;
|
||||
use BackedEnum;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class SparkboothConnections extends Page implements HasTable
|
||||
{
|
||||
use InteractsWithTable;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-link';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Admin';
|
||||
|
||||
protected static ?int $navigationSort = 11;
|
||||
|
||||
protected static ?string $title = 'Sparkbooth Verbindungen';
|
||||
|
||||
protected ?string $heading = 'Sparkbooth Verbindungen';
|
||||
|
||||
protected string $view = 'filament.pages.sparkbooth-connections';
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->heading('Vorhandene Sparkbooth-Verbindungen')
|
||||
->query(
|
||||
Gallery::query()
|
||||
->whereNotNull('upload_token_hash')
|
||||
->orderByDesc('created_at')
|
||||
)
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label('Name')
|
||||
->searchable(),
|
||||
TextColumn::make('slug')
|
||||
->label('Slug')
|
||||
->copyable()
|
||||
->toggleable(),
|
||||
TextColumn::make('images_path')
|
||||
->label('Upload-Pfad')
|
||||
->copyable()
|
||||
->toggleable(),
|
||||
TextColumn::make('created_at')
|
||||
->label('Angelegt')
|
||||
->since()
|
||||
->sortable(),
|
||||
])
|
||||
->actions([
|
||||
Action::make('show')
|
||||
->label('Zugangsdaten anzeigen')
|
||||
->icon('heroicon-o-key')
|
||||
->color('primary')
|
||||
->modalHeading('Upload-Zugangsdaten')
|
||||
->modalSubmitAction(false)
|
||||
->modalCancelActionLabel('Schließen')
|
||||
->modalContent(function (Gallery $record) {
|
||||
$plainToken = $record->regenerateUploadToken();
|
||||
|
||||
$data = [
|
||||
'gallery' => $record->only(['id', 'name', 'slug', 'images_path']),
|
||||
'upload_token' => $plainToken,
|
||||
'upload_url' => route('api.sparkbooth.upload'),
|
||||
'gallery_url' => route('gallery.show', $record),
|
||||
];
|
||||
|
||||
Notification::make()
|
||||
->title('Upload-Token wurde erneuert.')
|
||||
->body('Bitte verwende den neuen Token in Sparkbooth.')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
return view('filament.pages.partials.sparkbooth-token', $data);
|
||||
}),
|
||||
])
|
||||
->emptyStateHeading('Keine Sparkbooth-Verbindungen')
|
||||
->emptyStateDescription('Lege eine neue Verbindung an oder aktiviere Uploads für eine Galerie.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user