ConnectionTest im Backend funktioniert jetzt
This commit is contained in:
@@ -12,4 +12,5 @@ interface ApiPluginInterface
|
|||||||
public function getStatus(string $imageUUID): array;
|
public function getStatus(string $imageUUID): array;
|
||||||
public function getProgress(string $imageUUID): array;
|
public function getProgress(string $imageUUID): array;
|
||||||
public function processImageStyleChange(\App\Models\Image $image, \App\Models\Style $style): array;
|
public function processImageStyleChange(\App\Models\Image $image, \App\Models\Style $style): array;
|
||||||
|
public function testConnection(array $data): bool;
|
||||||
}
|
}
|
||||||
@@ -227,4 +227,16 @@ class ComfyUi implements ApiPluginInterface
|
|||||||
usleep(500000); // Wait for 0.5 seconds before polling again
|
usleep(500000); // Wait for 0.5 seconds before polling again
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testConnection(array $data): bool
|
||||||
|
{
|
||||||
|
$apiUrl = rtrim($data['api_url'], '/');
|
||||||
|
try {
|
||||||
|
$response = Http::timeout(5)->get($apiUrl . '/queue');
|
||||||
|
return $response->successful();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->logError('ComfyUI connection test failed.', ['error' => $e->getMessage()]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -91,6 +91,33 @@ class RunwareAi implements ApiPluginInterface
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testConnection(array $data): bool
|
||||||
|
{
|
||||||
|
$apiUrl = rtrim($data['api_url'], '/');
|
||||||
|
$token = $data['token'] ?? null;
|
||||||
|
|
||||||
|
if (!$apiUrl || !$token) {
|
||||||
|
$this->logError('RunwareAI connection test failed: API URL or Token missing.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Authorization' => 'Bearer ' . $token,
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
])->timeout(5)->post($apiUrl, [
|
||||||
|
[
|
||||||
|
'taskType' => 'ping',
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $response->successful();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->logError('RunwareAI connection test failed.', ['error' => $e->getMessage()]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function upload(string $imagePath): array
|
private function upload(string $imagePath): array
|
||||||
{
|
{
|
||||||
$this->logInfo('Attempting to upload image to RunwareAI.', ['image_path' => $imagePath]);
|
$this->logInfo('Attempting to upload image to RunwareAI.', ['image_path' => $imagePath]);
|
||||||
|
|||||||
@@ -17,9 +17,15 @@ use Filament\Tables\Columns\TextColumn;
|
|||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use App\Api\Plugins\ApiPluginInterface;
|
use App\Api\Plugins\ApiPluginInterface;
|
||||||
|
|
||||||
use Filament\Forms\Components\Toggle;
|
use Filament\Forms\Components\Toggle;
|
||||||
use Filament\Tables\Columns\IconColumn;
|
use Filament\Tables\Columns\IconColumn;
|
||||||
|
use Filament\Forms\Components\Actions;
|
||||||
|
use Filament\Forms\Components\Actions\Action;
|
||||||
|
use Filament\Forms\Components\ViewField;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Blade;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class ApiProviderResource extends Resource
|
class ApiProviderResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -30,41 +36,130 @@ class ApiProviderResource extends Resource
|
|||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
$plugins = self::getAvailablePlugins();
|
$plugins = self::getAvailablePlugins();
|
||||||
|
$livewire = $form->getLivewire();
|
||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('name')
|
Forms\Components\Section::make()
|
||||||
->label(__('filament.resource.api_provider.form.name'))
|
->schema([
|
||||||
->required()
|
TextInput::make('name')
|
||||||
->maxLength(255),
|
->label(__('filament.resource.api_provider.form.name'))
|
||||||
Toggle::make('enabled')
|
->required()
|
||||||
->label(__('filament.resource.api_provider.form.enabled'))
|
->maxLength(255),
|
||||||
->default(true),
|
Toggle::make('enabled')
|
||||||
TextInput::make('api_url')
|
->label(__('filament.resource.api_provider.form.enabled'))
|
||||||
->label(__('filament.resource.api_provider.form.api_url'))
|
->default(true),
|
||||||
->required()
|
TextInput::make('api_url')
|
||||||
->url()
|
->label(__('filament.resource.api_provider.form.api_url'))
|
||||||
->maxLength(255),
|
->required()
|
||||||
TextInput::make('username')
|
->url()
|
||||||
->label(__('filament.resource.api_provider.form.username'))
|
->maxLength(255),
|
||||||
->nullable()
|
TextInput::make('username')
|
||||||
->maxLength(255),
|
->label(__('filament.resource.api_provider.form.username'))
|
||||||
TextInput::make('password')
|
->nullable()
|
||||||
->label(__('filament.resource.api_provider.form.password'))
|
->maxLength(255),
|
||||||
->password()
|
TextInput::make('password')
|
||||||
->nullable()
|
->label(__('filament.resource.api_provider.form.password'))
|
||||||
->maxLength(255),
|
->password()
|
||||||
TextInput::make('token')
|
->nullable()
|
||||||
->label(__('filament.resource.api_provider.form.token'))
|
->maxLength(255),
|
||||||
->nullable()
|
TextInput::make('token')
|
||||||
->maxLength(255),
|
->label(__('filament.resource.api_provider.form.token'))
|
||||||
Select::make('plugin')
|
->nullable()
|
||||||
->options($plugins)
|
->maxLength(255),
|
||||||
->nullable()
|
Select::make('plugin')
|
||||||
->label(__('filament.resource.api_provider.form.plugin')),
|
->options($plugins)
|
||||||
|
->nullable()
|
||||||
|
->label(__('filament.resource.api_provider.form.plugin')),
|
||||||
|
Actions::make([
|
||||||
|
Action::make('test_connection')
|
||||||
|
->label(__('filament.resource.api_provider.action.test_connection'))
|
||||||
|
->icon(function (\Livewire\Component $livewire) {
|
||||||
|
return match ($livewire->testResultState) {
|
||||||
|
'success' => 'heroicon-o-check-circle',
|
||||||
|
'failed' => 'heroicon-o-x-circle',
|
||||||
|
default => 'heroicon-o-link',
|
||||||
|
};
|
||||||
|
})
|
||||||
|
->color(function (\Livewire\Component $livewire) {
|
||||||
|
return match ($livewire->testResultState) {
|
||||||
|
'success' => 'success',
|
||||||
|
'failed' => 'danger',
|
||||||
|
default => 'gray',
|
||||||
|
};
|
||||||
|
})
|
||||||
|
->action(function (array $data, Forms\Components\Component $component, \Livewire\Component $livewire) {
|
||||||
|
$formData = $component->getLivewire()->form->getState();
|
||||||
|
$apiUrl = str_replace('127.0.0.1', 'localhost', $formData['api_url'] ?? null);
|
||||||
|
$plugin = $formData['plugin'] ?? null;
|
||||||
|
$username = $formData['username'] ?? null;
|
||||||
|
$password = $formData['password'] ?? null;
|
||||||
|
$token = $formData['token'] ?? null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$http = Http::timeout(25);
|
||||||
|
|
||||||
|
if ($username && $password) {
|
||||||
|
$http->withBasicAuth($username, $password);
|
||||||
|
} elseif ($token) {
|
||||||
|
$http->withToken($token);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $http->get($apiUrl);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('External API connection successful.', [
|
||||||
|
'api_url' => $apiUrl,
|
||||||
|
'plugin' => $plugin,
|
||||||
|
]);
|
||||||
|
Notification::make()
|
||||||
|
->title(__('filament.resource.api_provider.notification.connection_successful'))
|
||||||
|
->success()
|
||||||
|
->send();
|
||||||
|
$component->getLivewire()->dispatch('testConnectionFinished', result: 'success');
|
||||||
|
} else {
|
||||||
|
Log::warning('External API connection failed: Non-successful response.', [
|
||||||
|
'api_url' => $apiUrl,
|
||||||
|
'plugin' => $plugin,
|
||||||
|
'status' => $response->status(),
|
||||||
|
'response_body' => $response->body(),
|
||||||
|
]);
|
||||||
|
Notification::make()
|
||||||
|
->title(__('filament.resource.api_provider.notification.connection_failed'))
|
||||||
|
->body($response->json('message', 'An unknown error occurred.'))
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$component->getLivewire()->dispatch('testConnectionFinished', result: 'failed');
|
||||||
|
}
|
||||||
|
} catch (\Illuminate\Http\Client\RequestException $e) {
|
||||||
|
Log::error('External API connection failed: Timeout or network error.', [
|
||||||
|
'api_url' => $apiUrl,
|
||||||
|
'plugin' => $plugin,
|
||||||
|
'error_message' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
Notification::make()
|
||||||
|
->title(__('filament.resource.api_provider.notification.connection_failed'))
|
||||||
|
->body('Timeout or network error: ' . $e->getMessage())
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$component->getLivewire()->dispatch('testConnectionFinished', result: 'failed');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('External API connection failed: An unexpected error occurred.', [
|
||||||
|
'api_url' => $apiUrl,
|
||||||
|
'plugin' => $plugin,
|
||||||
|
'error_message' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
Notification::make()
|
||||||
|
->title(__('filament.resource.api_provider.notification.connection_failed'))
|
||||||
|
->body('An unexpected error occurred: ' . $e->getMessage())
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$component->getLivewire()->dispatch('testConnectionFinished', result: 'failed');
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
@@ -103,42 +198,38 @@ class ApiProviderResource extends Resource
|
|||||||
Tables\Actions\CreateAction::make(),
|
Tables\Actions\CreateAction::make(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
public static function getRelations(): array
|
||||||
public static function getRelations(): array
|
{
|
||||||
{
|
return [
|
||||||
return [
|
//
|
||||||
//
|
];
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
public static function getPages(): array
|
||||||
public static function getPages(): array
|
{
|
||||||
{
|
return [
|
||||||
return [
|
'index' => Pages\ListApiProviders::route('/'),
|
||||||
'index' => Pages\ListApiProviders::route('/'),
|
'create' => Pages\CreateApiProvider::route('/create'),
|
||||||
'create' => Pages\CreateApiProvider::route('/create'),
|
'edit' => Pages\EditApiProvider::route('/{record}/edit'),
|
||||||
'edit' => Pages\EditApiProvider::route('/{record}/edit'),
|
];
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
protected static function getAvailablePlugins(): array
|
||||||
protected static function getAvailablePlugins(): array
|
{
|
||||||
{
|
$plugins = [];
|
||||||
$plugins = [];
|
$path = app_path('Api/Plugins');
|
||||||
$path = app_path('Api/Plugins');
|
$files = File::files($path);
|
||||||
$files = File::files($path);
|
|
||||||
|
foreach ($files as $file) {
|
||||||
foreach ($files as $file) {
|
$filename = $file->getFilenameWithoutExtension();
|
||||||
$filename = $file->getFilenameWithoutExtension();
|
if (in_array($filename, ['ApiPluginInterface', 'PluginLoader'])) {
|
||||||
if (in_array($filename, ['ApiPluginInterface', 'PluginLoader'])) {
|
continue;
|
||||||
continue;
|
}
|
||||||
|
$class = "App\Api\Plugins\\" . $filename;
|
||||||
|
if (class_exists($class) && in_array(ApiPluginInterface::class, class_implements($class))) {
|
||||||
|
// Do not instantiate here, just get identifier and name if possible statically or by convention
|
||||||
|
// For now, we'll use filename as identifier and name
|
||||||
|
$plugins[$filename] = $filename;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$class = 'App\\Api\\Plugins\\' . $filename;
|
return $plugins;
|
||||||
if (class_exists($class) && in_array(ApiPluginInterface::class, class_implements($class))) {
|
}
|
||||||
// Do not instantiate here, just get identifier and name if possible statically or by convention
|
|
||||||
// For now, we'll use filename as identifier and name
|
|
||||||
$plugins[$filename] = $filename;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $plugins;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -5,11 +5,20 @@ namespace App\Filament\Resources\ApiProviderResource\Pages;
|
|||||||
use App\Filament\Resources\ApiProviderResource;
|
use App\Filament\Resources\ApiProviderResource;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
use Livewire\Attributes\On;
|
||||||
|
|
||||||
class CreateApiProvider extends CreateRecord
|
class CreateApiProvider extends CreateRecord
|
||||||
{
|
{
|
||||||
|
public $testResultState = 'none';
|
||||||
|
|
||||||
protected static string $resource = ApiProviderResource::class;
|
protected static string $resource = ApiProviderResource::class;
|
||||||
|
|
||||||
|
#[On('testConnectionFinished')]
|
||||||
|
public function onTestConnectionFinished($result)
|
||||||
|
{
|
||||||
|
$this->testResultState = $result;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getRedirectUrl(): string
|
protected function getRedirectUrl(): string
|
||||||
{
|
{
|
||||||
return $this->getResource()::getUrl('index');
|
return $this->getResource()::getUrl('index');
|
||||||
|
|||||||
@@ -5,11 +5,20 @@ namespace App\Filament\Resources\ApiProviderResource\Pages;
|
|||||||
use App\Filament\Resources\ApiProviderResource;
|
use App\Filament\Resources\ApiProviderResource;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
use Filament\Resources\Pages\EditRecord;
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
use Livewire\Attributes\On;
|
||||||
|
|
||||||
class EditApiProvider extends EditRecord
|
class EditApiProvider extends EditRecord
|
||||||
{
|
{
|
||||||
|
public $testResultState = 'none';
|
||||||
|
|
||||||
protected static string $resource = ApiProviderResource::class;
|
protected static string $resource = ApiProviderResource::class;
|
||||||
|
|
||||||
|
#[On('testConnectionFinished')]
|
||||||
|
public function onTestConnectionFinished($result)
|
||||||
|
{
|
||||||
|
$this->testResultState = $result;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -31,11 +31,27 @@ class SettingResource extends Resource
|
|||||||
->maxLength(255)
|
->maxLength(255)
|
||||||
->hiddenOn('edit'),
|
->hiddenOn('edit'),
|
||||||
Forms\Components\Fieldset::make()
|
Forms\Components\Fieldset::make()
|
||||||
->label(fn (?Setting $record) => $record ? $record->key : __('New Setting'))
|
->label(fn (?Setting $record) => $record ? __('filament.resource.setting.form.' . $record->key) : __('New Setting'))
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('value')
|
TextInput::make('value')
|
||||||
->label(__('Value'))
|
->label(__('Bitte Wert eingeben'))
|
||||||
->disableLabel()
|
->disableLabel(fn (?Setting $record) => $record && ($record->key !== 'image_refresh_interval' && $record->key !== 'new_image_timespan_minutes' && $record->key !== 'gallery_heading'))
|
||||||
|
->formatStateUsing(function (?string $state, ?Setting $record) {
|
||||||
|
if ($record && $record->key === 'image_refresh_interval') {
|
||||||
|
return (int)$state / 1000;
|
||||||
|
} else if ($record && $record->key === 'new_image_timespan_minutes') {
|
||||||
|
return (int)$state;
|
||||||
|
}
|
||||||
|
return $state;
|
||||||
|
})
|
||||||
|
->dehydrateStateUsing(function (?string $state, ?Setting $record) {
|
||||||
|
if ($record && $record->key === 'image_refresh_interval') {
|
||||||
|
return (int)$state * 1000;
|
||||||
|
} else if ($record && $record->key === 'new_image_timespan_minutes') {
|
||||||
|
return (int)$state;
|
||||||
|
}
|
||||||
|
return $state;
|
||||||
|
})
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,47 +27,70 @@ class StyleResource extends Resource
|
|||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
|
->columns('full')
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('title')
|
Forms\Components\Tabs::make('Style Details')
|
||||||
->label(__('filament.resource.style.form.title'))
|
->tabs([
|
||||||
->required()
|
Forms\Components\Tabs\Tab::make('General')
|
||||||
->maxLength(255),
|
->schema([
|
||||||
Toggle::make('enabled')
|
Forms\Components\Grid::make(2)
|
||||||
->label(__('filament.resource.style.form.enabled'))
|
->schema([
|
||||||
->default(true),
|
TextInput::make('title')
|
||||||
Textarea::make('prompt')
|
->label(__('filament.resource.style.form.title'))
|
||||||
->label(__('filament.resource.style.form.prompt'))
|
->required()
|
||||||
->required()
|
->maxLength(255),
|
||||||
->rows(5),
|
Toggle::make('enabled')
|
||||||
Textarea::make('description')
|
->label(__('filament.resource.style.form.enabled'))
|
||||||
->label(__('filament.resource.style.form.description'))
|
->default(true),
|
||||||
->required()
|
]),
|
||||||
->rows(5),
|
Forms\Components\Grid::make(2)
|
||||||
FileUpload::make('preview_image')
|
->schema([
|
||||||
->label(__('filament.resource.style.form.preview_image'))
|
Textarea::make('prompt')
|
||||||
->disk('public')
|
->label(__('filament.resource.style.form.prompt'))
|
||||||
->directory('style_previews')
|
->required()
|
||||||
->image()
|
->rows(5),
|
||||||
->imageEditor()
|
Textarea::make('description')
|
||||||
->required()
|
->label(__('filament.resource.style.form.description'))
|
||||||
->rules(['mimes:jpeg,png,bmp,gif,webp']),
|
->required()
|
||||||
Textarea::make('parameters')
|
->rows(5),
|
||||||
->label(__('filament.resource.style.form.parameters'))
|
]),
|
||||||
->nullable()
|
Select::make('ai_model_id')
|
||||||
->rows(15)
|
->relationship('aiModel', 'name')
|
||||||
->json()
|
->label(__('filament.resource.style.form.ai_model'))
|
||||||
->helperText(__('filament.resource.style.form.parameters_help'))
|
->required(),
|
||||||
->formatStateUsing(fn (?array $state): ?string => $state ? json_encode($state, JSON_PRETTY_PRINT) : null),
|
FileUpload::make('preview_image')
|
||||||
Select::make('ai_model_id')
|
->label(__('filament.resource.style.form.preview_image'))
|
||||||
->relationship('aiModel', 'name')
|
->disk('public')
|
||||||
->label(__('filament.resource.style.form.ai_model'))
|
->directory('style_previews')
|
||||||
->required(),
|
->image()
|
||||||
|
->imageEditor()
|
||||||
|
->required()
|
||||||
|
->rules(['mimes:jpeg,png,bmp,gif,webp']),
|
||||||
|
]),
|
||||||
|
Forms\Components\Tabs\Tab::make('Details')
|
||||||
|
->schema([
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('sort_order')
|
||||||
|
->numeric()
|
||||||
|
->default(0)
|
||||||
|
->label(__('filament.resource.style.form.sort_order')),
|
||||||
|
Textarea::make('parameters')
|
||||||
|
->label(__('filament.resource.style.form.parameters'))
|
||||||
|
->nullable()
|
||||||
|
->rows(15)
|
||||||
|
->json()
|
||||||
|
->helperText(__('filament.resource.style.form.parameters_help'))
|
||||||
|
->formatStateUsing(fn (?array $state): ?string => $state ? json_encode($state, JSON_PRETTY_PRINT) : null),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
|
->defaultSort('sort_order')
|
||||||
|
->reorderable('sort_order')
|
||||||
->columns([
|
->columns([
|
||||||
TextColumn::make('title')->label(__('filament.resource.style.table.title'))->searchable()->sortable(),
|
TextColumn::make('title')->label(__('filament.resource.style.table.title'))->searchable()->sortable(),
|
||||||
IconColumn::make('enabled')
|
IconColumn::make('enabled')
|
||||||
@@ -75,6 +98,7 @@ class StyleResource extends Resource
|
|||||||
->boolean(),
|
->boolean(),
|
||||||
TextColumn::make('aiModel.name')->label(__('filament.resource.style.table.ai_model'))->searchable()->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'),
|
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([
|
->filters([
|
||||||
SelectFilter::make('ai_model')
|
SelectFilter::make('ai_model')
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ namespace App\Filament\Resources\StyleResource\Pages;
|
|||||||
use App\Filament\Resources\StyleResource;
|
use App\Filament\Resources\StyleResource;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
use Filament\Tables\Concerns\CanReorderRecords;
|
||||||
use Illuminate\Contracts\Pagination\Paginator;
|
use Illuminate\Contracts\Pagination\Paginator;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
class ListStyles extends ListRecords
|
class ListStyles extends ListRecords
|
||||||
{
|
{
|
||||||
|
use CanReorderRecords;
|
||||||
protected static string $resource = StyleResource::class;
|
protected static string $resource = StyleResource::class;
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
|
|||||||
15
app/Http/Controllers/Admin/NavigationStateController.php
Normal file
15
app/Http/Controllers/Admin/NavigationStateController.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class NavigationStateController extends Controller
|
||||||
|
{
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
// Placeholder for storing navigation state
|
||||||
|
return response()->json(['message' => 'Navigation state stored.']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Style;
|
use App\Models\Style;
|
||||||
|
use App\Models\Setting;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class StyleController extends Controller
|
class StyleController extends Controller
|
||||||
@@ -18,7 +19,8 @@ class StyleController extends Controller
|
|||||||
$query->where('enabled', true);
|
$query->where('enabled', true);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
->get();
|
->get()
|
||||||
|
->sortBy('sort_order');
|
||||||
|
|
||||||
if ($styles->isEmpty()) {
|
if ($styles->isEmpty()) {
|
||||||
return response()->json(['message' => __('api.no_styles_available')], 404);
|
return response()->json(['message' => __('api.no_styles_available')], 404);
|
||||||
@@ -26,4 +28,11 @@ class StyleController extends Controller
|
|||||||
|
|
||||||
return response()->json($styles);
|
return response()->json($styles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getImageRefreshInterval()
|
||||||
|
{
|
||||||
|
$interval = Setting::where('key', 'image_refresh_interval')->first();
|
||||||
|
|
||||||
|
return response()->json(['interval' => $interval ? (int)$interval->value / 1000 : 5]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,9 @@ class AdminPanelProvider extends PanelProvider
|
|||||||
'primary' => Color::Amber,
|
'primary' => Color::Amber,
|
||||||
])
|
])
|
||||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
|
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
|
||||||
|
->resources([
|
||||||
|
\App\Filament\Resources\ApiProviderResource::class,
|
||||||
|
])
|
||||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
|
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
|
||||||
->pages([
|
->pages([
|
||||||
Pages\Dashboard::class,
|
Pages\Dashboard::class,
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^8.3",
|
"php": "^8.3",
|
||||||
"amphp/websocket-client": "^2.0",
|
"amphp/websocket-client": "^2.0",
|
||||||
"filament/filament": "^3.2",
|
"blade-ui-kit/blade-icons": "^1.8",
|
||||||
|
"filament/filament": "^3.3",
|
||||||
"guzzlehttp/guzzle": "^7.2",
|
"guzzlehttp/guzzle": "^7.2",
|
||||||
"inertiajs/inertia-laravel": "^1.0",
|
"inertiajs/inertia-laravel": "^1.0",
|
||||||
"laravel/breeze": "^2.0",
|
"laravel/breeze": "^2.0",
|
||||||
|
|||||||
2
composer.lock
generated
2
composer.lock
generated
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "0b1ebe92702b13e1e049bf2d7f192913",
|
"content-hash": "c6dbfef94da04e316c0664ef987fb127",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "amphp/amp",
|
"name": "amphp/amp",
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ return [
|
|||||||
/*
|
/*
|
||||||
* Package Service Providers...
|
* Package Service Providers...
|
||||||
*/
|
*/
|
||||||
|
BladeUI\Icons\BladeIconsServiceProvider::class,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Application Service Providers...
|
* Application Service Providers...
|
||||||
|
|||||||
183
config/blade-icons.php
Normal file
183
config/blade-icons.php
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Icons Sets
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| With this config option you can define a couple of
|
||||||
|
| default icon sets. Provide a key name for your icon
|
||||||
|
| set and a combination from the options below.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'sets' => [
|
||||||
|
|
||||||
|
// 'default' => [
|
||||||
|
//
|
||||||
|
// /*
|
||||||
|
// |-----------------------------------------------------------------
|
||||||
|
// | Icons Path
|
||||||
|
// |-----------------------------------------------------------------
|
||||||
|
// |
|
||||||
|
// | Provide the relative path from your app root to your SVG icons
|
||||||
|
// | directory. Icons are loaded recursively so there's no need to
|
||||||
|
// | list every sub-directory.
|
||||||
|
// |
|
||||||
|
// | Relative to the disk root when the disk option is set.
|
||||||
|
// |
|
||||||
|
// */
|
||||||
|
//
|
||||||
|
// 'path' => 'resources/svg',
|
||||||
|
//
|
||||||
|
// /*
|
||||||
|
// |-----------------------------------------------------------------
|
||||||
|
// | Filesystem Disk
|
||||||
|
// |-----------------------------------------------------------------
|
||||||
|
// |
|
||||||
|
// | Optionally, provide a specific filesystem disk to read
|
||||||
|
// | icons from. When defining a disk, the "path" option
|
||||||
|
// | starts relatively from the disk root.
|
||||||
|
// |
|
||||||
|
// */
|
||||||
|
//
|
||||||
|
// 'disk' => '',
|
||||||
|
//
|
||||||
|
// /*
|
||||||
|
// |-----------------------------------------------------------------
|
||||||
|
// | Default Prefix
|
||||||
|
// |-----------------------------------------------------------------
|
||||||
|
// |
|
||||||
|
// | This config option allows you to define a default prefix for
|
||||||
|
// | your icons. The dash separator will be applied automatically
|
||||||
|
// | to every icon name. It's required and needs to be unique.
|
||||||
|
// |
|
||||||
|
// */
|
||||||
|
//
|
||||||
|
// 'prefix' => 'icon',
|
||||||
|
//
|
||||||
|
// /*
|
||||||
|
// |-----------------------------------------------------------------
|
||||||
|
// | Fallback Icon
|
||||||
|
// |-----------------------------------------------------------------
|
||||||
|
// |
|
||||||
|
// | This config option allows you to define a fallback
|
||||||
|
// | icon when an icon in this set cannot be found.
|
||||||
|
// |
|
||||||
|
// */
|
||||||
|
//
|
||||||
|
// 'fallback' => '',
|
||||||
|
//
|
||||||
|
// /*
|
||||||
|
// |-----------------------------------------------------------------
|
||||||
|
// | Default Set Classes
|
||||||
|
// |-----------------------------------------------------------------
|
||||||
|
// |
|
||||||
|
// | This config option allows you to define some classes which
|
||||||
|
// | will be applied by default to all icons within this set.
|
||||||
|
// |
|
||||||
|
// */
|
||||||
|
//
|
||||||
|
// 'class' => '',
|
||||||
|
//
|
||||||
|
// /*
|
||||||
|
// |-----------------------------------------------------------------
|
||||||
|
// | Default Set Attributes
|
||||||
|
// |-----------------------------------------------------------------
|
||||||
|
// |
|
||||||
|
// | This config option allows you to define some attributes which
|
||||||
|
// | will be applied by default to all icons within this set.
|
||||||
|
// |
|
||||||
|
// */
|
||||||
|
//
|
||||||
|
// 'attributes' => [
|
||||||
|
// // 'width' => 50,
|
||||||
|
// // 'height' => 50,
|
||||||
|
// ],
|
||||||
|
//
|
||||||
|
// ],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Global Default Classes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This config option allows you to define some classes which
|
||||||
|
| will be applied by default to all icons.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'class' => '',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Global Default Attributes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This config option allows you to define some attributes which
|
||||||
|
| will be applied by default to all icons.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'attributes' => [
|
||||||
|
// 'width' => 50,
|
||||||
|
// 'height' => 50,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Global Fallback Icon
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This config option allows you to define a global fallback
|
||||||
|
| icon when an icon in any set cannot be found. It can
|
||||||
|
| reference any icon from any configured set.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'fallback' => '',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Components
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These config options allow you to define some
|
||||||
|
| settings related to Blade Components.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'components' => [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|----------------------------------------------------------------------
|
||||||
|
| Disable Components
|
||||||
|
|----------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This config option allows you to disable Blade components
|
||||||
|
| completely. It's useful to avoid performance problems
|
||||||
|
| when working with large icon libraries.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'disabled' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|----------------------------------------------------------------------
|
||||||
|
| Default Icon Component Name
|
||||||
|
|----------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This config option allows you to define the name
|
||||||
|
| for the default Icon class component.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => 'icon',
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('styles', function (Blueprint $table) {
|
||||||
|
$table->integer('sort_order')->default(0)->after('enabled');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('styles', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('sort_order');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -283,7 +283,17 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fetchImages();
|
fetchImages();
|
||||||
fetchInterval = setInterval(fetchImages, 5000);
|
|
||||||
|
// Fetch image refresh interval from API
|
||||||
|
axios.get('/api/image-refresh-interval')
|
||||||
|
.then(response => {
|
||||||
|
const interval = response.data.interval * 1000;
|
||||||
|
fetchInterval = setInterval(fetchImages, interval);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error fetching image refresh interval:', error);
|
||||||
|
fetchInterval = setInterval(fetchImages, 5000); // Fallback to 5 seconds
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ return [
|
|||||||
'delete' => 'Löschen',
|
'delete' => 'Löschen',
|
||||||
'enable_selected' => 'Ausgewählte aktivieren',
|
'enable_selected' => 'Ausgewählte aktivieren',
|
||||||
'disable_selected' => 'Ausgewählte deaktivieren',
|
'disable_selected' => 'Ausgewählte deaktivieren',
|
||||||
|
'test_connection' => 'Verbindung testen',
|
||||||
|
],
|
||||||
|
'notification' => [
|
||||||
|
'connection_successful' => 'Verbindung erfolgreich!',
|
||||||
|
'connection_failed' => 'Verbindung fehlgeschlagen.',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'image' => [
|
'image' => [
|
||||||
@@ -76,12 +81,14 @@ return [
|
|||||||
'api_provider' => 'API Anbieter',
|
'api_provider' => 'API Anbieter',
|
||||||
'ai_model' => 'AI Modell',
|
'ai_model' => 'AI Modell',
|
||||||
'enabled' => 'Aktiviert',
|
'enabled' => 'Aktiviert',
|
||||||
|
'sort_order' => 'Sortierreihenfolge',
|
||||||
],
|
],
|
||||||
'table' => [
|
'table' => [
|
||||||
'title' => 'Titel',
|
'title' => 'Titel',
|
||||||
'ai_model' => 'AI Modell',
|
'ai_model' => 'AI Modell',
|
||||||
'preview_image' => 'Vorschaubild',
|
'preview_image' => 'Vorschaubild',
|
||||||
'enabled' => 'Aktiviert',
|
'enabled' => 'Aktiviert',
|
||||||
|
'sort_order' => 'Sortierreihenfolge',
|
||||||
],
|
],
|
||||||
'action' => [
|
'action' => [
|
||||||
'duplicate' => 'Duplizieren',
|
'duplicate' => 'Duplizieren',
|
||||||
@@ -89,6 +96,13 @@ return [
|
|||||||
'disable_selected' => 'Ausgewählte deaktivieren',
|
'disable_selected' => 'Ausgewählte deaktivieren',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'setting' => [
|
||||||
|
'form' => [
|
||||||
|
'image_refresh_interval' => 'Bildaktualisierungsintervall (Sekunden)',
|
||||||
|
'new_image_timespan_minutes' => 'Neue Bilder Zeitspanne (Minuten)',
|
||||||
|
'gallery_heading' => 'Galerie Überschrift',
|
||||||
|
],
|
||||||
|
],
|
||||||
'plugin' => [
|
'plugin' => [
|
||||||
'navigation' => [
|
'navigation' => [
|
||||||
'group' => 'Plugins',
|
'group' => 'Plugins',
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ return [
|
|||||||
'delete' => 'Delete',
|
'delete' => 'Delete',
|
||||||
'enable_selected' => 'Enable Selected',
|
'enable_selected' => 'Enable Selected',
|
||||||
'disable_selected' => 'Disable Selected',
|
'disable_selected' => 'Disable Selected',
|
||||||
|
'test_connection' => 'Test Connection',
|
||||||
|
],
|
||||||
|
'notification' => [
|
||||||
|
'connection_successful' => 'Connection successful!',
|
||||||
|
'connection_failed' => 'Connection failed.',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'image' => [
|
'image' => [
|
||||||
@@ -75,12 +80,14 @@ return [
|
|||||||
'api_provider' => 'API Provider',
|
'api_provider' => 'API Provider',
|
||||||
'ai_model' => 'AI Model',
|
'ai_model' => 'AI Model',
|
||||||
'enabled' => 'Enabled',
|
'enabled' => 'Enabled',
|
||||||
|
'sort_order' => 'Sort Order',
|
||||||
],
|
],
|
||||||
'table' => [
|
'table' => [
|
||||||
'title' => 'Title',
|
'title' => 'Title',
|
||||||
'ai_model' => 'AI Model',
|
'ai_model' => 'AI Model',
|
||||||
'preview_image' => 'Preview Image',
|
'preview_image' => 'Preview Image',
|
||||||
'enabled' => 'Enabled',
|
'enabled' => 'Enabled',
|
||||||
|
'sort_order' => 'Sort Order',
|
||||||
],
|
],
|
||||||
'action' => [
|
'action' => [
|
||||||
'duplicate' => 'Duplicate',
|
'duplicate' => 'Duplicate',
|
||||||
@@ -88,7 +95,14 @@ return [
|
|||||||
'disable_selected' => 'Disable Selected',
|
'disable_selected' => 'Disable Selected',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'user' => [
|
'setting' => [
|
||||||
|
'form' => [
|
||||||
|
'image_refresh_interval' => 'Image Refresh Interval (seconds)',
|
||||||
|
'new_image_timespan_minutes' => 'New Image Timespan (minutes)',
|
||||||
|
'gallery_heading' => 'Gallery Heading',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'user' => [
|
||||||
'navigation' => [
|
'navigation' => [
|
||||||
'group' => 'User Management',
|
'group' => 'User Management',
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ Route::post('/admin/navigation-state', [NavigationStateController::class, 'store
|
|||||||
// Publicly accessible routes
|
// Publicly accessible routes
|
||||||
Route::get('/images', [ImageController::class, 'index']);
|
Route::get('/images', [ImageController::class, 'index']);
|
||||||
Route::get('/styles', [StyleController::class, 'index']);
|
Route::get('/styles', [StyleController::class, 'index']);
|
||||||
|
Route::get('/image-refresh-interval', [StyleController::class, 'getImageRefreshInterval']);
|
||||||
|
|
||||||
Route::post('/images/style-change', [ImageController::class, 'styleChangeRequest']);
|
Route::post('/images/style-change', [ImageController::class, 'styleChangeRequest']);
|
||||||
Route::get('/comfyui-url', [ImageController::class, 'getComfyUiUrl']);
|
Route::get('/comfyui-url', [ImageController::class, 'getComfyUiUrl']);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user