- Galerien sind nun eine Entität - es kann mehrere geben
- Neues Sparkbooth-Upload-Feature: Endpoint /api/sparkbooth/upload (Token-basiert pro Galerie), Controller Api/SparkboothUploadController, Migration 2026_01_21_000001_add_upload_fields_to_galleries_table.php mit Upload-Flags/Token/Expiry;
Galerie-Modell und Factory/Seeder entsprechend erweitert.
- Filament: Neue Setup-Seite SparkboothSetup (mit View) zur schnellen Galerie- und Token-Erstellung inkl. QR/Endpoint/Snippet;
Galerie-Link-Views nutzen jetzt simple-qrcode (Composer-Dependency hinzugefügt) und bieten PNG-Download.
- Galerie-Tabelle: Slug/Pfad-Spalten entfernt, Action „Link-Details“ mit Modal; Created-at-Spalte hinzugefügt.
- Zugriffshärtung: Galerie-IDs in API (ImageController, Download/Print) geprüft; GalleryAccess/Middleware + Gallery-Modell/Slug-UUID
eingeführt; GalleryAccess-Inertia-Seite.
- UI/UX: LoadingSpinner/StyledImageDisplay verbessert, Delete-Confirm, Übersetzungen ergänzt.
This commit is contained in:
@@ -5,6 +5,8 @@ namespace App\Filament\Pages;
|
||||
use App\Services\PrinterService;
|
||||
use App\Settings\GeneralSettings;
|
||||
use BackedEnum;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
@@ -14,6 +16,7 @@ use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use UnitEnum;
|
||||
|
||||
class GlobalSettings extends Page implements HasForms
|
||||
@@ -40,7 +43,10 @@ class GlobalSettings extends Page implements HasForms
|
||||
|
||||
public function mount(GeneralSettings $settings): void
|
||||
{
|
||||
$this->form->fill($settings->toArray());
|
||||
$data = $settings->toArray();
|
||||
$data['gallery_password'] = null;
|
||||
|
||||
$this->form->fill($data);
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
@@ -59,6 +65,24 @@ class GlobalSettings extends Page implements HasForms
|
||||
TextInput::make('gallery_heading')
|
||||
->label(__('filament.resource.setting.form.gallery_heading'))
|
||||
->required(),
|
||||
Toggle::make('require_gallery_password')
|
||||
->label(__('filament.resource.setting.form.require_gallery_password'))
|
||||
->helperText(__('filament.resource.setting.form.require_gallery_password_help')),
|
||||
TextInput::make('gallery_password')
|
||||
->label(__('filament.resource.setting.form.gallery_password'))
|
||||
->password()
|
||||
->revealable()
|
||||
->helperText(__('filament.resource.setting.form.gallery_password_help'))
|
||||
->dehydrated(true),
|
||||
DateTimePicker::make('gallery_expires_at')
|
||||
->label(__('filament.resource.setting.form.gallery_expires_at'))
|
||||
->native(false)
|
||||
->seconds(false),
|
||||
TextInput::make('gallery_access_duration_minutes')
|
||||
->label(__('filament.resource.setting.form.gallery_access_duration_minutes'))
|
||||
->numeric()
|
||||
->minValue(1)
|
||||
->helperText(__('filament.resource.setting.form.gallery_access_duration_help')),
|
||||
TextInput::make('new_image_timespan_minutes')
|
||||
->label(__('filament.resource.setting.form.new_image_timespan_minutes'))
|
||||
->numeric()
|
||||
@@ -92,11 +116,39 @@ class GlobalSettings extends Page implements HasForms
|
||||
$data['custom_printer_address'] = null;
|
||||
}
|
||||
|
||||
$data['require_gallery_password'] = (bool) Arr::get($data, 'require_gallery_password', false);
|
||||
$data['new_image_timespan_minutes'] = (int) Arr::get($data, 'new_image_timespan_minutes', 0);
|
||||
$data['image_refresh_interval'] = (int) Arr::get($data, 'image_refresh_interval', 0);
|
||||
$data['max_number_of_copies'] = (int) Arr::get($data, 'max_number_of_copies', 0);
|
||||
$data['show_print_button'] = (bool) Arr::get($data, 'show_print_button', false);
|
||||
$data['custom_printer_address'] = $data['custom_printer_address'] ?: null;
|
||||
$duration = Arr::get($data, 'gallery_access_duration_minutes');
|
||||
$data['gallery_access_duration_minutes'] = $duration === null || $duration === '' ? null : (int) $duration;
|
||||
|
||||
$expiresAt = Arr::get($data, 'gallery_expires_at');
|
||||
$data['gallery_expires_at'] = $expiresAt ? Carbon::parse($expiresAt) : null;
|
||||
|
||||
$newPassword = Arr::get($data, 'gallery_password');
|
||||
$currentHash = $settings->gallery_password_hash;
|
||||
|
||||
if (! $data['require_gallery_password']) {
|
||||
$data['gallery_password_hash'] = null;
|
||||
} else {
|
||||
$data['gallery_password_hash'] = $newPassword
|
||||
? Hash::make($newPassword)
|
||||
: $currentHash;
|
||||
|
||||
if (! $data['gallery_password_hash']) {
|
||||
Notification::make()
|
||||
->title(__('filament.resource.setting.form.gallery_password_missing'))
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unset($data['gallery_password']);
|
||||
|
||||
$settings->fill($data)->save();
|
||||
|
||||
|
||||
107
app/Filament/Pages/SparkboothSetup.php
Normal file
107
app/Filament/Pages/SparkboothSetup.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Gallery;
|
||||
use BackedEnum;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
use UnitEnum;
|
||||
|
||||
class SparkboothSetup extends Page implements HasForms
|
||||
{
|
||||
use InteractsWithForms;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-camera';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Admin';
|
||||
|
||||
protected static ?int $navigationSort = 10;
|
||||
|
||||
protected string $view = 'filament.pages.sparkbooth-setup';
|
||||
|
||||
public ?array $data = [];
|
||||
|
||||
public ?array $result = null;
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Sparkbooth Setup';
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label('Event-Name')
|
||||
->required(),
|
||||
TextInput::make('title')
|
||||
->label('Galerie Titel')
|
||||
->required(),
|
||||
TextInput::make('images_path')
|
||||
->label('Upload-Pfad')
|
||||
->helperText('Relativ zu public/storage, z.B. uploads/event-xyz')
|
||||
->default(fn () => 'uploads/'.Str::slug('event-'.Str::random(4)))
|
||||
->required(),
|
||||
Toggle::make('allow_print')
|
||||
->label('Drucken erlauben')
|
||||
->default(true),
|
||||
Toggle::make('allow_ai_styles')
|
||||
->label('AI-Stile erlauben')
|
||||
->default(true),
|
||||
Toggle::make('upload_enabled')
|
||||
->label('Uploads aktivieren')
|
||||
->default(true),
|
||||
])
|
||||
->statePath('data');
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
$data = $this->form->getState();
|
||||
|
||||
$gallery = new Gallery([
|
||||
'name' => $data['name'],
|
||||
'title' => $data['title'],
|
||||
'images_path' => trim($data['images_path'], '/'),
|
||||
'is_public' => true,
|
||||
'allow_ai_styles' => (bool) $data['allow_ai_styles'],
|
||||
'allow_print' => (bool) $data['allow_print'],
|
||||
'upload_enabled' => (bool) $data['upload_enabled'],
|
||||
]);
|
||||
|
||||
$gallery->slug = Str::uuid()->toString();
|
||||
|
||||
$plainToken = Str::random(40);
|
||||
$gallery->setUploadToken($plainToken);
|
||||
$gallery->save();
|
||||
|
||||
$this->result = [
|
||||
'gallery' => $gallery->only(['id', 'name', 'slug', 'images_path']),
|
||||
'upload_token' => $plainToken,
|
||||
'upload_url' => route('api.sparkbooth.upload'),
|
||||
'gallery_url' => route('gallery.show', $gallery),
|
||||
];
|
||||
|
||||
Notification::make()
|
||||
->title('Galerie erstellt und Upload-Token generiert.')
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
|
||||
protected function getFormActions(): array
|
||||
{
|
||||
return [
|
||||
\Filament\Actions\Action::make('save')
|
||||
->label('Setup erstellen')
|
||||
->submit('save'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user