feat: add IMAP connection testing and website settings optimization
- Add dynamic IMAP connection testing for multiple account types (public, premium) - Implement testIMAPConnection method using ZEmail::connectMailBox for reliable testing - Add comprehensive error handling and user-friendly notifications - Support easy extension for future IMAP configurations (vip, etc.) - Add queued artisan command execution in WebsiteSettings (optimize, optimize:clear) - Enhance website settings with performance optimization controls - Add validation for IMAP extension availability and helpful error messages
This commit is contained in:
@@ -3,13 +3,16 @@
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\KeyValue;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Inerba\DbConfig\AbstractPageSettings;
|
||||
|
||||
class WebsiteSettings extends AbstractPageSettings
|
||||
@@ -44,6 +47,25 @@ class WebsiteSettings extends AbstractPageSettings
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('filament-optimize')
|
||||
->label('Optimize Application')
|
||||
->color('gray')
|
||||
->icon('heroicon-o-paper-airplane')
|
||||
->action(fn () => $this->appOptimize()),
|
||||
|
||||
Action::make('filament-optimize-clear')
|
||||
->label('Clear Optimized Files')
|
||||
->color('danger')
|
||||
->icon('heroicon-o-trash')
|
||||
->action(fn () => $this->appOptimizeClear()),
|
||||
|
||||
...parent::getHeaderActions(),
|
||||
];
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
@@ -105,4 +127,38 @@ class WebsiteSettings extends AbstractPageSettings
|
||||
])
|
||||
->statePath('data');
|
||||
}
|
||||
|
||||
private function appOptimize(): void
|
||||
{
|
||||
try {
|
||||
\Artisan::queue('optimize');
|
||||
Notification::make()
|
||||
->title('App optimization successful!')
|
||||
->success()
|
||||
->send();
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('App optimization failed', ['exception' => $e->getMessage()]);
|
||||
Notification::make()
|
||||
->title('App optimization failed: '.$e->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
private function appOptimizeClear(): void
|
||||
{
|
||||
try {
|
||||
Artisan::queue('optimize:clear');
|
||||
Notification::make()
|
||||
->title('Cache files clear successful!')
|
||||
->success()
|
||||
->send();
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('App Optimize clear failed', ['exception' => $e->getMessage()]);
|
||||
Notification::make()
|
||||
->title('Failed to clear cache files: '.$e->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user