lokalisierung vervollständigt, api provider testconnection, runware modellsuche aktiviert und style preview generation integriert
This commit is contained in:
@@ -26,6 +26,16 @@ class GlobalSettings extends Page implements HasForms
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Admin';
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return __('filament.pages.global_settings');
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return __('filament.pages.global_settings');
|
||||
}
|
||||
|
||||
public ?array $data = [];
|
||||
|
||||
public function mount(GeneralSettings $settings): void
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Api\Plugins\ApiPluginInterface;
|
||||
use App\Api\Plugins\PluginLoader;
|
||||
use App\Models\AiModel;
|
||||
use App\Models\ApiProvider;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
@@ -27,7 +28,7 @@ class AiModelResource extends Resource
|
||||
{
|
||||
protected static ?string $model = AiModel::class;
|
||||
|
||||
// protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
protected static BackedEnum|string|null $navigationIcon = 'heroicon-o-cpu-chip';
|
||||
|
||||
protected static ?int $navigationSort = -100;
|
||||
|
||||
@@ -36,30 +37,71 @@ class AiModelResource extends Resource
|
||||
return __('filament.navigation.groups.ai_models');
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return __('filament.navigation.ai_models');
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make('Hinweise zu Model-Parametern')
|
||||
->description('Parameter werden je nach Plugin unterschiedlich verwendet: Runware/ComfyUI als JSON für Workflow/Model-Settings, Leonardo v2 akzeptiert z. B. width/height/style_ids/prompt_enhance. Prüfe die Plugin-Doku; Felder, die nicht zum Plugin passen, werden ignoriert.')
|
||||
Section::make(__('filament.resource.ai_model.parameters_help_title'))
|
||||
->description(__('filament.resource.ai_model.parameters_help_text'))
|
||||
->columns(1)
|
||||
->collapsible()
|
||||
->schema([]),
|
||||
TextInput::make('name')
|
||||
->label(__('filament.resource.ai_model.form.name'))
|
||||
->required(),
|
||||
TextInput::make('model_id')
|
||||
->required(),
|
||||
Select::make('model_id')
|
||||
->label(__('filament.resource.ai_model.form.model_id'))
|
||||
->searchable()
|
||||
->required()
|
||||
->getSearchResultsUsing(function (string $search, callable $get): array {
|
||||
$providerId = $get('api_provider_id');
|
||||
if (! $providerId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$provider = ApiProvider::find($providerId);
|
||||
if (! $provider || ! $provider->plugin) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$plugin = PluginLoader::getPlugin($provider->plugin, $provider);
|
||||
if (! method_exists($plugin, 'searchModels')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$results = $plugin->searchModels($search);
|
||||
|
||||
$options = [];
|
||||
foreach ($results as $result) {
|
||||
$id = $result['id'] ?? null;
|
||||
$name = $result['name'] ?? $id;
|
||||
if ($id) {
|
||||
$options[$id] = $name ? $name.' ('.$id.')' : $id;
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
})
|
||||
->getOptionLabelUsing(fn ($value): ?string => $value),
|
||||
TextInput::make('model_type')
|
||||
->label(__('filament.resource.ai_model.form.model_type'))
|
||||
->nullable(),
|
||||
Select::make('api_provider_id')
|
||||
->label('API Provider')
|
||||
->label(__('filament.resource.ai_model.form.api_provider'))
|
||||
->relationship('primaryApiProvider', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
Toggle::make('enabled')
|
||||
->label(__('filament.resource.ai_model.form.enabled'))
|
||||
->default(true),
|
||||
Textarea::make('parameters')
|
||||
->label(__('filament.resource.ai_model.form.parameters'))
|
||||
->nullable()
|
||||
->rows(15),
|
||||
]);
|
||||
@@ -143,7 +185,7 @@ class AiModelResource extends Resource
|
||||
->actions([
|
||||
EditAction::make(),
|
||||
Action::make('duplicate')
|
||||
->label('Duplicate')
|
||||
->label(__('filament.resource.ai_model.action.duplicate'))
|
||||
->icon('heroicon-o-document-duplicate')
|
||||
->action(function (Model $record, $livewire) {
|
||||
$livewire->redirect(static::getUrl('create', ['sourceRecord' => $record->id]));
|
||||
|
||||
@@ -33,6 +33,11 @@ class ApiProviderResource extends Resource
|
||||
return __('filament.navigation.groups.ai_models');
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return __('filament.navigation.api_providers');
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
$plugins = self::getAvailablePlugins();
|
||||
@@ -40,31 +45,38 @@ class ApiProviderResource extends Resource
|
||||
return $schema
|
||||
->components([
|
||||
Placeholder::make('provider_dashboard')
|
||||
->label('Provider Dashboard')
|
||||
->label(__('filament.resource.api_provider.dashboard'))
|
||||
->content(fn (?ApiProvider $record) => $record?->getDashboardUrl() ? '<a href="'.$record->getDashboardUrl().'" target="_blank" class="text-primary-600 underline">'.$record->getDashboardUrl().'</a>' : '—')
|
||||
->disableLabel(false)
|
||||
->columnSpanFull()
|
||||
->visible(fn (?ApiProvider $record) => (bool) $record?->getDashboardUrl()),
|
||||
TextInput::make('name')
|
||||
->label(__('filament.resource.api_provider.form.name'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Toggle::make('enabled')
|
||||
->label(__('filament.resource.api_provider.form.enabled'))
|
||||
->default(true),
|
||||
TextInput::make('api_url')
|
||||
->label(__('filament.resource.api_provider.form.api_url'))
|
||||
->required()
|
||||
->url()
|
||||
->maxLength(255),
|
||||
TextInput::make('username')
|
||||
->label(__('filament.resource.api_provider.form.username'))
|
||||
->nullable()
|
||||
->maxLength(255),
|
||||
TextInput::make('password')
|
||||
->label(__('filament.resource.api_provider.form.password'))
|
||||
->password()
|
||||
->nullable()
|
||||
->maxLength(255),
|
||||
TextInput::make('token')
|
||||
->label(__('filament.resource.api_provider.form.token'))
|
||||
->nullable()
|
||||
->maxLength(255),
|
||||
Select::make('plugin')
|
||||
->label(__('filament.resource.api_provider.form.plugin'))
|
||||
->options($plugins)
|
||||
->nullable(),
|
||||
]);
|
||||
@@ -74,11 +86,12 @@ class ApiProviderResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')->searchable()->sortable(),
|
||||
TextColumn::make('name')->label(__('filament.resource.api_provider.table.name'))->searchable()->sortable(),
|
||||
IconColumn::make('enabled')
|
||||
->label(__('filament.resource.api_provider.table.enabled'))
|
||||
->boolean(),
|
||||
TextColumn::make('api_url')->searchable(),
|
||||
TextColumn::make('plugin')->searchable()->sortable(),
|
||||
TextColumn::make('api_url')->label(__('filament.resource.api_provider.table.api_url'))->searchable(),
|
||||
TextColumn::make('plugin')->label(__('filament.resource.api_provider.table.plugin'))->searchable()->sortable(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
|
||||
@@ -27,6 +27,11 @@ class ImageResource extends Resource
|
||||
return __('filament.navigation.groups.content');
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return __('filament.navigation.images');
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
@@ -45,8 +50,9 @@ class ImageResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('path')->searchable()->sortable(),
|
||||
TextColumn::make('path')->label(__('filament.resource.image.table.path'))->searchable()->sortable(),
|
||||
ImageColumn::make('path')
|
||||
->label(__('filament.resource.image.table.image'))
|
||||
->disk('public'),
|
||||
])
|
||||
->filters([
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Roles;
|
||||
|
||||
use App\Models\Role;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
@@ -20,9 +21,17 @@ class RoleResource extends Resource
|
||||
|
||||
protected static UnitEnum|string|null $navigationGroup = 'User Management';
|
||||
|
||||
protected static ?string $navigationLabel = 'User Roles';
|
||||
protected static BackedEnum|string|null $navigationIcon = 'heroicon-o-key';
|
||||
|
||||
protected static bool $shouldRegisterNavigation = false;
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return __('filament.navigation.user_roles');
|
||||
}
|
||||
|
||||
public static function getNavigationGroup(): ?string
|
||||
{
|
||||
return __('filament.navigation.groups.user_management');
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@@ -2,16 +2,110 @@
|
||||
|
||||
namespace App\Filament\Resources\Styles\Pages;
|
||||
|
||||
use App\Api\Plugins\PluginLoader;
|
||||
use App\Filament\Resources\Styles\StyleResource;
|
||||
use Filament\Actions;
|
||||
use App\Models\AiModel;
|
||||
use App\Models\Image;
|
||||
use App\Models\Style;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreateStyle extends CreateRecord
|
||||
{
|
||||
protected static string $resource = StyleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('generate_preview')
|
||||
->label(__('filament.resource.style.preview.generate'))
|
||||
->icon('heroicon-o-sparkles')
|
||||
->color('gray')
|
||||
->action(function (): void {
|
||||
try {
|
||||
$state = $this->form->getState();
|
||||
$path = $state['preview_source'] ?? null;
|
||||
$aiModelId = $state['ai_model_id'] ?? null;
|
||||
$prompt = $state['prompt'] ?? null;
|
||||
|
||||
if (! $path) {
|
||||
throw new \RuntimeException(__('filament.resource.style.preview.missing_image'));
|
||||
}
|
||||
if (! $aiModelId) {
|
||||
throw new \RuntimeException(__('filament.resource.style.preview.missing_model'));
|
||||
}
|
||||
if (! $prompt) {
|
||||
throw new \RuntimeException(__('filament.resource.style.preview.missing_prompt'));
|
||||
}
|
||||
|
||||
$aiModel = AiModel::with('primaryApiProvider')->findOrFail($aiModelId);
|
||||
$provider = $aiModel->primaryApiProvider;
|
||||
if (! $provider || ! $provider->enabled || ! $provider->plugin || ! $provider->token) {
|
||||
throw new \RuntimeException(__('filament.resource.style.preview.provider_invalid'));
|
||||
}
|
||||
|
||||
$style = new Style([
|
||||
'title' => $state['title'] ?? 'Preview',
|
||||
'prompt' => $prompt,
|
||||
'description' => $state['description'] ?? '',
|
||||
'parameters' => $state['parameters'] ?? [],
|
||||
]);
|
||||
$style->setRelation('aiModel', $aiModel);
|
||||
|
||||
$image = new Image([
|
||||
'path' => $path,
|
||||
]);
|
||||
|
||||
$plugin = PluginLoader::getPlugin($provider->plugin, $provider);
|
||||
$result = $plugin->processImageStyleChange($image, $style);
|
||||
|
||||
$imageData = null;
|
||||
if (isset($result['base64Data'])) {
|
||||
$imageData = base64_decode($result['base64Data']);
|
||||
} elseif (isset($result['prompt_id'])) {
|
||||
$fetched = $plugin->getStyledImage($result['prompt_id']);
|
||||
if (str_starts_with($fetched, 'http')) {
|
||||
$resp = Http::timeout(30)->get($fetched);
|
||||
$resp->throw();
|
||||
$imageData = $resp->body();
|
||||
} else {
|
||||
$imageData = base64_decode($fetched);
|
||||
}
|
||||
}
|
||||
|
||||
if (! $imageData) {
|
||||
throw new \RuntimeException(__('filament.resource.style.preview.no_image'));
|
||||
}
|
||||
|
||||
$fileName = 'style_previews/generated_'.Str::uuid().'.png';
|
||||
Storage::disk('public')->put($fileName, $imageData);
|
||||
|
||||
$this->form->fill([
|
||||
'preview_image' => $fileName,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title(__('filament.resource.style.preview.done'))
|
||||
->body(__('filament.resource.style.preview.saved_hint'))
|
||||
->success()
|
||||
->send();
|
||||
} catch (\Throwable $e) {
|
||||
Notification::make()
|
||||
->title(__('filament.resource.style.preview.failed'))
|
||||
->body($e->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('index');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,18 @@
|
||||
|
||||
namespace App\Filament\Resources\Styles\Pages;
|
||||
|
||||
use App\Api\Plugins\PluginLoader;
|
||||
use App\Filament\Resources\Styles\StyleResource;
|
||||
use App\Models\AiModel;
|
||||
use App\Models\Image;
|
||||
use App\Models\Style;
|
||||
use Filament\Actions;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EditStyle extends EditRecord
|
||||
{
|
||||
@@ -13,6 +22,88 @@ class EditStyle extends EditRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('generate_preview')
|
||||
->label(__('filament.resource.style.preview.generate'))
|
||||
->icon('heroicon-o-sparkles')
|
||||
->color('gray')
|
||||
->action(function (): void {
|
||||
try {
|
||||
$state = $this->form->getState();
|
||||
$path = $state['preview_source'] ?? null;
|
||||
$aiModelId = $state['ai_model_id'] ?? null;
|
||||
$prompt = $state['prompt'] ?? null;
|
||||
|
||||
if (! $path) {
|
||||
throw new \RuntimeException(__('filament.resource.style.preview.missing_image'));
|
||||
}
|
||||
if (! $aiModelId) {
|
||||
throw new \RuntimeException(__('filament.resource.style.preview.missing_model'));
|
||||
}
|
||||
if (! $prompt) {
|
||||
throw new \RuntimeException(__('filament.resource.style.preview.missing_prompt'));
|
||||
}
|
||||
|
||||
$aiModel = AiModel::with('primaryApiProvider')->findOrFail($aiModelId);
|
||||
$provider = $aiModel->primaryApiProvider;
|
||||
if (! $provider || ! $provider->enabled || ! $provider->plugin || ! $provider->token) {
|
||||
throw new \RuntimeException(__('filament.resource.style.preview.provider_invalid'));
|
||||
}
|
||||
|
||||
// Temporary style + image instances
|
||||
$style = new Style([
|
||||
'title' => $state['title'] ?? 'Preview',
|
||||
'prompt' => $prompt,
|
||||
'description' => $state['description'] ?? '',
|
||||
'parameters' => $state['parameters'] ?? [],
|
||||
]);
|
||||
$style->setRelation('aiModel', $aiModel);
|
||||
|
||||
$image = new Image([
|
||||
'path' => $path,
|
||||
]);
|
||||
|
||||
$plugin = PluginLoader::getPlugin($provider->plugin, $provider);
|
||||
$result = $plugin->processImageStyleChange($image, $style);
|
||||
|
||||
$imageData = null;
|
||||
if (isset($result['base64Data'])) {
|
||||
$imageData = base64_decode($result['base64Data']);
|
||||
} elseif (isset($result['prompt_id'])) {
|
||||
$fetched = $plugin->getStyledImage($result['prompt_id']);
|
||||
if (str_starts_with($fetched, 'http')) {
|
||||
$resp = Http::timeout(30)->get($fetched);
|
||||
$resp->throw();
|
||||
$imageData = $resp->body();
|
||||
} else {
|
||||
$imageData = base64_decode($fetched);
|
||||
}
|
||||
}
|
||||
|
||||
if (! $imageData) {
|
||||
throw new \RuntimeException(__('filament.resource.style.preview.no_image'));
|
||||
}
|
||||
|
||||
$fileName = 'style_previews/generated_'.Str::uuid().'.png';
|
||||
Storage::disk('public')->put($fileName, $imageData);
|
||||
|
||||
// Update form state
|
||||
$this->form->fill([
|
||||
'preview_image' => $fileName,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title(__('filament.resource.style.preview.done'))
|
||||
->body(__('filament.resource.style.preview.saved_hint'))
|
||||
->success()
|
||||
->send();
|
||||
} catch (\Throwable $e) {
|
||||
Notification::make()
|
||||
->title(__('filament.resource.style.preview.failed'))
|
||||
->body($e->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}),
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
@@ -21,4 +112,4 @@ class EditStyle extends EditRecord
|
||||
{
|
||||
return $this->getResource()::getUrl('index');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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([
|
||||
|
||||
@@ -16,14 +16,17 @@ use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
use BackedEnum;
|
||||
|
||||
class UserResource extends Resource
|
||||
{
|
||||
protected static ?string $model = User::class;
|
||||
|
||||
protected static BackedEnum|string|null $navigationIcon = 'heroicon-o-user-group';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'User Management';
|
||||
|
||||
protected static ?string $navigationLabel = 'Users';
|
||||
protected static ?string $navigationLabel = null;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@@ -32,19 +35,23 @@ class UserResource extends Resource
|
||||
Section::make('User Details')
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->label(__('filament.resource.user.form.name'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('email')
|
||||
->label(__('filament.resource.user.form.email'))
|
||||
->email()
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('password')
|
||||
->label(__('filament.resource.user.form.password'))
|
||||
->password()
|
||||
->dehydrateStateUsing(fn (string $state): string => bcrypt($state))
|
||||
->dehydrated(fn (?string $state): bool => filled($state))
|
||||
->required(fn (string $operation): bool => $operation === 'create')
|
||||
->maxLength(255),
|
||||
Select::make('role_id')
|
||||
->label(__('filament.resource.user.form.role'))
|
||||
->relationship('role', 'name')
|
||||
->required(),
|
||||
])->columns(2)
|
||||
@@ -53,14 +60,17 @@ class UserResource extends Resource
|
||||
Section::make('Preferences')
|
||||
->components([
|
||||
Toggle::make('email_notifications_enabled')
|
||||
->label(__('filament.resource.user.form.email_notifications_enabled'))
|
||||
->default(true),
|
||||
Select::make('theme_preference')
|
||||
->label(__('filament.resource.user.form.theme_preference'))
|
||||
->options([
|
||||
'light' => 'Light',
|
||||
'dark' => 'Dark',
|
||||
'light' => __('filament.resource.user.form.theme_light'),
|
||||
'dark' => __('filament.resource.user.form.theme_dark'),
|
||||
])
|
||||
->default('light'),
|
||||
Select::make('locale')
|
||||
->label(__('filament.resource.user.form.locale'))
|
||||
->options([
|
||||
'en' => 'English',
|
||||
'de' => 'Deutsch',
|
||||
|
||||
@@ -2,24 +2,24 @@
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
use App\Models\AiModel;
|
||||
use App\Models\ApiProvider;
|
||||
use App\Models\Style;
|
||||
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
|
||||
class AppStatsOverview extends BaseWidget
|
||||
{
|
||||
protected function getCards(): array
|
||||
{
|
||||
return [
|
||||
Stat::make('Anzahl AI Modelle', AiModel::count())
|
||||
Stat::make(__('filament.widgets.app_stats.ai_models'), AiModel::count())
|
||||
->icon('heroicon-o-server')
|
||||
->url(route('filament.admin.resources.ai-models.index')),
|
||||
Stat::make('Anzahl API-Provider', ApiProvider::count())
|
||||
Stat::make(__('filament.widgets.app_stats.api_providers'), ApiProvider::count())
|
||||
->icon('heroicon-o-cube')
|
||||
->url(route('filament.admin.resources.api-providers.index')),
|
||||
Stat::make('Anzahl Styles', Style::count())
|
||||
Stat::make(__('filament.widgets.app_stats.styles'), Style::count())
|
||||
->icon('heroicon-o-sparkles')
|
||||
->url(route('filament.admin.resources.styles.index')),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user