sparkbooth anbindung gefixt
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Gallery;
|
||||
use BackedEnum;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
@@ -62,6 +63,23 @@ class SparkboothSetup extends Page implements HasForms
|
||||
Toggle::make('upload_enabled')
|
||||
->label('Uploads aktivieren')
|
||||
->default(true),
|
||||
TextInput::make('sparkbooth_username')
|
||||
->label('Sparkbooth Benutzername')
|
||||
->helperText('Wird in Sparkbooth unter „Username“ eingetragen. Erlaubt sind Buchstaben, Zahlen sowie ._-')
|
||||
->default(fn (): string => 'spark-'.Str::lower(Str::random(6)))
|
||||
->required()
|
||||
->maxLength(64)
|
||||
->rule('regex:/^[A-Za-z0-9._-]+$/')
|
||||
->unique(table: Gallery::class, column: 'sparkbooth_username'),
|
||||
Select::make('sparkbooth_response_format')
|
||||
->label('Standard-Antwortformat')
|
||||
->helperText('Sparkbooth kann JSON oder XML erwarten. JSON ist empfohlen.')
|
||||
->options([
|
||||
'json' => 'JSON',
|
||||
'xml' => 'XML',
|
||||
])
|
||||
->default('json')
|
||||
->required(),
|
||||
])
|
||||
->statePath('data');
|
||||
}
|
||||
@@ -70,6 +88,9 @@ class SparkboothSetup extends Page implements HasForms
|
||||
{
|
||||
$data = $this->form->getState();
|
||||
|
||||
$sparkboothUsername = $this->normalizeUsername($data['sparkbooth_username'] ?? '');
|
||||
$sparkboothPassword = Str::random(24);
|
||||
|
||||
$gallery = new Gallery([
|
||||
'name' => $data['name'],
|
||||
'title' => $data['title'],
|
||||
@@ -78,6 +99,9 @@ class SparkboothSetup extends Page implements HasForms
|
||||
'allow_ai_styles' => (bool) $data['allow_ai_styles'],
|
||||
'allow_print' => (bool) $data['allow_print'],
|
||||
'upload_enabled' => (bool) $data['upload_enabled'],
|
||||
'sparkbooth_username' => $sparkboothUsername,
|
||||
'sparkbooth_password' => $sparkboothPassword,
|
||||
'sparkbooth_response_format' => $data['sparkbooth_response_format'] ?? 'json',
|
||||
]);
|
||||
|
||||
$gallery->slug = Str::uuid()->toString();
|
||||
@@ -91,6 +115,9 @@ class SparkboothSetup extends Page implements HasForms
|
||||
'upload_token' => $plainToken,
|
||||
'upload_url' => route('api.sparkbooth.upload'),
|
||||
'gallery_url' => route('gallery.show', $gallery),
|
||||
'sparkbooth_username' => $sparkboothUsername,
|
||||
'sparkbooth_password' => $sparkboothPassword,
|
||||
'response_format' => $gallery->sparkbooth_response_format,
|
||||
];
|
||||
|
||||
Notification::make()
|
||||
@@ -114,4 +141,11 @@ class SparkboothSetup extends Page implements HasForms
|
||||
->url(route('filament.admin.pages.dashboard')),
|
||||
];
|
||||
}
|
||||
|
||||
protected function normalizeUsername(string $value): string
|
||||
{
|
||||
$clean = preg_replace('/[^A-Za-z0-9._-]/', '', $value) ?? '';
|
||||
|
||||
return Str::of($clean)->lower()->trim()->value();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user