112 lines
4.4 KiB
PHP
112 lines
4.4 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages;
|
|
|
|
use App\Models\Gallery;
|
|
use BackedEnum;
|
|
use Filament\Actions\Action;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Pages\Page;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Concerns\InteractsWithTable;
|
|
use Filament\Tables\Contracts\HasTable;
|
|
use Filament\Tables\Table;
|
|
use UnitEnum;
|
|
|
|
class PhotoboothConnections 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 = 'Photobooth Verbindungen';
|
|
|
|
protected ?string $heading = 'Photobooth Verbindungen';
|
|
|
|
protected string $view = 'filament.pages.photobooth-connections';
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->heading('Vorhandene Photobooth-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('sparkbooth_username')
|
|
->label('Benutzername')
|
|
->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('Schliessen')
|
|
->modalContent(function (Gallery $record) {
|
|
$plainToken = $record->regenerateUploadToken();
|
|
|
|
$data = [
|
|
'gallery' => $record->only(['id', 'name', 'slug', 'images_path']),
|
|
'upload_token' => $plainToken,
|
|
'upload_url' => route('api.photobooth.upload'),
|
|
'gallery_url' => route('gallery.show', $record),
|
|
'sparkbooth_username' => $record->sparkbooth_username,
|
|
'sparkbooth_password' => $record->sparkbooth_password,
|
|
'response_format' => $record->sparkbooth_response_format,
|
|
];
|
|
|
|
Notification::make()
|
|
->title('Zugangsdaten aktualisiert.')
|
|
->body('Der Upload-Token wurde erneuert. Username/Passwort bleiben unveraendert.')
|
|
->success()
|
|
->send();
|
|
|
|
return view('filament.pages.partials.photobooth-token', $data);
|
|
}),
|
|
Action::make('deleteConnection')
|
|
->label('Verbindung loeschen')
|
|
->icon('heroicon-o-trash')
|
|
->color('danger')
|
|
->requiresConfirmation()
|
|
->modalHeading('Photobooth-Verbindung entfernen')
|
|
->modalDescription('Die Galerie bleibt erhalten, aber Upload-Token und Zugangsdaten werden geloescht.')
|
|
->action(function (Gallery $record): void {
|
|
$record->clearSparkboothConnection();
|
|
|
|
Notification::make()
|
|
->title('Photobooth-Verbindung entfernt.')
|
|
->body('Der Upload-Token und die Zugangsdaten wurden geloescht.')
|
|
->success()
|
|
->send();
|
|
}),
|
|
])
|
|
->emptyStateHeading('Keine Photobooth-Verbindungen')
|
|
->emptyStateDescription('Lege eine neue Verbindung an oder aktiviere Uploads fuer eine Galerie.');
|
|
}
|
|
}
|