lokalisierung vervollständigt, api provider testconnection, runware modellsuche aktiviert und style preview generation integriert
This commit is contained in:
@@ -5,7 +5,6 @@ namespace App\Filament\Resources\Styles;
|
||||
use App\Models\Style;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Action\Step;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
@@ -41,6 +40,11 @@ class StyleResource extends Resource
|
||||
return __('filament.navigation.groups.ai_models');
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return __('filament.navigation.styles');
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
@@ -68,9 +72,17 @@ class StyleResource extends Resource
|
||||
Textarea::make('description')
|
||||
->required()
|
||||
->rows(5),
|
||||
FileUpload::make('preview_source')
|
||||
->label('Referenzbild für Vorschau')
|
||||
->helperText('Lade ein Bild hoch, um eine Vorschau mit dem aktuellen Prompt zu generieren.')
|
||||
->disk('public')
|
||||
->directory('style_previews/reference')
|
||||
->image()
|
||||
->dehydrated(false),
|
||||
]),
|
||||
Select::make('ai_model_id')
|
||||
->relationship('aiModel', 'name')
|
||||
->label(__('filament.resource.style.form.ai_model'))
|
||||
->required(),
|
||||
FileUpload::make('preview_image')
|
||||
->disk('public')
|
||||
@@ -82,9 +94,11 @@ class StyleResource extends Resource
|
||||
Tab::make('Details')
|
||||
->components([
|
||||
TextInput::make('sort_order')
|
||||
->label(__('filament.resource.style.form.sort_order'))
|
||||
->numeric()
|
||||
->default(0),
|
||||
Textarea::make('parameters')
|
||||
->label(__('filament.resource.style.form.parameters'))
|
||||
->nullable()
|
||||
->rows(15),
|
||||
]),
|
||||
@@ -97,12 +111,13 @@ class StyleResource extends Resource
|
||||
return $table
|
||||
->defaultSort('sort_order')
|
||||
->columns([
|
||||
TextColumn::make('title')->searchable()->sortable(),
|
||||
TextColumn::make('title')->label(__('filament.resource.style.table.title'))->searchable()->sortable(),
|
||||
IconColumn::make('enabled')
|
||||
->label(__('filament.resource.style.table.enabled'))
|
||||
->boolean(),
|
||||
TextColumn::make('aiModel.name')->searchable()->sortable(),
|
||||
ImageColumn::make('preview_image')->disk('public'),
|
||||
TextColumn::make('sort_order')->sortable(),
|
||||
TextColumn::make('aiModel.name')->label(__('filament.resource.style.table.ai_model'))->searchable()->sortable(),
|
||||
ImageColumn::make('preview_image')->label(__('filament.resource.style.table.preview_image'))->disk('public'),
|
||||
TextColumn::make('sort_order')->label(__('filament.resource.style.table.sort_order'))->sortable(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('ai_model')
|
||||
@@ -111,30 +126,24 @@ class StyleResource extends Resource
|
||||
->deferFilters(false)
|
||||
->headerActions([
|
||||
Action::make('import_styles')
|
||||
->label('Import Styles (CSV)')
|
||||
->label(__('filament.resource.style.import.title'))
|
||||
->icon('heroicon-o-arrow-up-on-square-stack')
|
||||
->steps([
|
||||
Step::make('Datei')
|
||||
->schema([
|
||||
FileUpload::make('import_file')
|
||||
->label('CSV-Datei (Titel,Prompt,[Beschreibung])')
|
||||
->acceptedFileTypes([
|
||||
'text/csv',
|
||||
'text/plain',
|
||||
'application/vnd.ms-excel',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
])
|
||||
->directory('imports/styles')
|
||||
->visibility('private')
|
||||
->required(),
|
||||
]),
|
||||
Step::make('Zuordnung')
|
||||
->schema([
|
||||
Select::make('ai_model_id')
|
||||
->label('AI Modell')
|
||||
->relationship('aiModel', 'name')
|
||||
->required(),
|
||||
]),
|
||||
->form([
|
||||
FileUpload::make('import_file')
|
||||
->label(__('filament.resource.style.import.file_label'))
|
||||
->acceptedFileTypes([
|
||||
'text/csv',
|
||||
'text/plain',
|
||||
'application/vnd.ms-excel',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
])
|
||||
->directory('imports/styles')
|
||||
->visibility('private')
|
||||
->required(),
|
||||
Select::make('ai_model_id')
|
||||
->label(__('filament.resource.style.import.model_label'))
|
||||
->relationship('aiModel', 'name')
|
||||
->required(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$path = storage_path('app/'.$data['import_file']);
|
||||
@@ -146,7 +155,7 @@ class StyleResource extends Resource
|
||||
$rows = self::parseImportFile($path);
|
||||
|
||||
if (empty($rows)) {
|
||||
throw new \RuntimeException('Keine gültigen Zeilen gefunden.');
|
||||
throw new \RuntimeException(__('filament.resource.style.import.empty'));
|
||||
}
|
||||
|
||||
$created = 0;
|
||||
@@ -176,8 +185,8 @@ class StyleResource extends Resource
|
||||
}
|
||||
|
||||
\Filament\Notifications\Notification::make()
|
||||
->title('Import abgeschlossen')
|
||||
->body($created.' Styles importiert. Bitte Vorschau-Bilder ergänzen.')
|
||||
->title(__('filament.resource.style.import.title'))
|
||||
->body($created.' '.__('filament.resource.style.import.success'))
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
@@ -185,7 +194,7 @@ class StyleResource extends Resource
|
||||
->actions([
|
||||
EditAction::make(),
|
||||
Action::make('duplicate')
|
||||
->label('Duplicate')
|
||||
->label(__('filament.resource.style.action.duplicate'))
|
||||
->icon('heroicon-o-document-duplicate')
|
||||
->action(function (\App\Models\Style $record) {
|
||||
$newStyle = $record->replicate();
|
||||
@@ -199,17 +208,64 @@ class StyleResource extends Resource
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
BulkAction::make('enable')
|
||||
->label('Enable Selected')
|
||||
->label(__('filament.resource.style.action.enable_selected'))
|
||||
->icon('heroicon-o-check-circle')
|
||||
->action(function (\Illuminate\Support\Collection $records) {
|
||||
$records->each->update(['enabled' => true]);
|
||||
}),
|
||||
BulkAction::make('disable')
|
||||
->label('Disable Selected')
|
||||
->label(__('filament.resource.style.action.disable_selected'))
|
||||
->icon('heroicon-o-x-circle')
|
||||
->action(function (\Illuminate\Support\Collection $records) {
|
||||
$records->each->update(['enabled' => false]);
|
||||
}),
|
||||
BulkAction::make('reassignModel')
|
||||
->label(__('filament.resource.style.action.reassign_model'))
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->form([
|
||||
Select::make('ai_model_id')
|
||||
->label('Zielmodell')
|
||||
->relationship('aiModel', 'name')
|
||||
->required(),
|
||||
])
|
||||
->action(function (\Illuminate\Support\Collection $records, array $data) {
|
||||
$count = 0;
|
||||
foreach ($records as $record) {
|
||||
$record->update(['ai_model_id' => $data['ai_model_id']]);
|
||||
$count++;
|
||||
}
|
||||
|
||||
\Filament\Notifications\Notification::make()
|
||||
->title(__('filament.resource.style.action.reassign_model'))
|
||||
->body("{$count} ".__('filament.resource.style.table.title'))
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
BulkAction::make('duplicateToModel')
|
||||
->label(__('filament.resource.style.action.duplicate_to_model'))
|
||||
->icon('heroicon-o-document-duplicate')
|
||||
->form([
|
||||
Select::make('ai_model_id')
|
||||
->label('Zielmodell')
|
||||
->relationship('aiModel', 'name')
|
||||
->required(),
|
||||
])
|
||||
->action(function (\Illuminate\Support\Collection $records, array $data) {
|
||||
$created = 0;
|
||||
foreach ($records as $record) {
|
||||
$copy = $record->replicate();
|
||||
$copy->title = $record->title.' (Copy)';
|
||||
$copy->ai_model_id = $data['ai_model_id'];
|
||||
$copy->save();
|
||||
$created++;
|
||||
}
|
||||
|
||||
\Filament\Notifications\Notification::make()
|
||||
->title(__('filament.resource.style.action.duplicate'))
|
||||
->body("{$created} Kopien erstellt.")
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
]),
|
||||
])
|
||||
->emptyStateActions([
|
||||
|
||||
Reference in New Issue
Block a user