Added Premium Domains and Gmail Users to dashboard, also added flush cache upon setting update
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Setting;
|
||||
use App\Models\ZEmail;
|
||||
use Artisan;
|
||||
use Ddeboer\Imap\Server;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
@@ -45,6 +46,8 @@ class Settings extends Page implements HasForms
|
||||
$this->applyDefaults($imapSettings, [
|
||||
'protocol' => 'imap',
|
||||
'default_account' => 'default',
|
||||
'premium_protocol' => 'imap',
|
||||
'premium_default_account' => 'default',
|
||||
]);
|
||||
|
||||
$this->applyDefaults($configurationSettings, [
|
||||
@@ -56,6 +59,8 @@ class Settings extends Page implements HasForms
|
||||
$transformMap = [
|
||||
'domains' => 'domain',
|
||||
'gmailUsernames' => 'gmailUsername',
|
||||
'premium_domains' => 'premium_domain',
|
||||
'premium_gmailUsernames' => 'premium_gmailUsername',
|
||||
'forbidden_ids' => 'forbidden_id',
|
||||
'blocked_domains' => 'blocked_domain',
|
||||
];
|
||||
@@ -145,7 +150,7 @@ class Settings extends Page implements HasForms
|
||||
|
||||
]),
|
||||
|
||||
Section::make('Imap')
|
||||
Section::make('Public Mailbox Imap')
|
||||
->description('Enter your imap server')
|
||||
->collapsed()
|
||||
->schema([
|
||||
@@ -164,6 +169,25 @@ class Settings extends Page implements HasForms
|
||||
Checkbox::make('imap_settings.cc_check')->label('Check CC Field')->default(false)->helperText('If enabled, we will check the CC field as well while fetching mails.'),
|
||||
]),
|
||||
|
||||
Section::make('Premium Mailbox Imap')
|
||||
->description('Enter your imap server')
|
||||
->collapsed()
|
||||
->schema([
|
||||
TextInput::make('imap_settings.premium_host')->label('Hostname')->required(),
|
||||
TextInput::make('imap_settings.premium_port')->label('Port')->required(),
|
||||
Select::make('imap_settings.premium_encryption')->options([
|
||||
'none' => 'None',
|
||||
'ssl' => 'SSL',
|
||||
'tls' => 'TLS'
|
||||
]),
|
||||
Checkbox::make('imap_settings.premium_validate_cert')->label('Validate Encryption Certificate')->default(false),
|
||||
TextInput::make('imap_settings.premium_username')->label('Username')->required(),
|
||||
TextInput::make('imap_settings.premium_password')->label('Password')->required(),
|
||||
TextInput::make('imap_settings.premium_default_account')->label('Default Account')->placeholder('default'),
|
||||
TextInput::make('imap_settings.premium_protocol')->label('Protocol')->placeholder('imap'),
|
||||
Checkbox::make('imap_settings.premium_cc_check')->label('Check CC Field')->default(false)->helperText('If enabled, we will check the CC field as well while fetching mails.'),
|
||||
]),
|
||||
|
||||
Section::make('Configuration')
|
||||
->description('Enter your configuration')
|
||||
->collapsed()
|
||||
@@ -230,6 +254,24 @@ class Settings extends Page implements HasForms
|
||||
]),
|
||||
]),
|
||||
|
||||
Section::make('Premium Domains & Gmail Usernames')
|
||||
->collapsed()
|
||||
->columns(2)
|
||||
->schema([
|
||||
Repeater::make('configuration_settings.premium_domains')
|
||||
->statePath('configuration_settings.premium_domains')
|
||||
->columnSpan(1)
|
||||
->schema([
|
||||
TextInput::make('premium_domain')->label('Premium Domain')->required()->maxLength(30),
|
||||
]),
|
||||
Repeater::make('configuration_settings.premium_gmailUsernames')
|
||||
->statePath('configuration_settings.premium_gmailUsernames')
|
||||
->columnSpan(1)
|
||||
->schema([
|
||||
TextInput::make('premium_gmailUsername')->label('Premium Gmail Username')->required()->maxLength(30),
|
||||
]),
|
||||
]),
|
||||
|
||||
Section::make('Mailbox Configuration')
|
||||
->collapsed()
|
||||
->schema([
|
||||
@@ -300,9 +342,31 @@ class Settings extends Page implements HasForms
|
||||
Action::make('save')
|
||||
->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
|
||||
->submit('save'),
|
||||
Action::make('flushCache')
|
||||
->label(__('Flush Cache'))
|
||||
->color('danger')
|
||||
->icon('heroicon-m-no-symbol')
|
||||
->action('flushCache')
|
||||
->requiresConfirmation(),
|
||||
];
|
||||
}
|
||||
|
||||
public function flushCache(): void
|
||||
{
|
||||
try {
|
||||
Artisan::call('cache:clear');
|
||||
Notification::make()
|
||||
->title('Cache flushed successfully')
|
||||
->success()
|
||||
->send();
|
||||
} catch (\Exception $e) {
|
||||
Notification::make()
|
||||
->title('Error : '.$e->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
try {
|
||||
@@ -318,13 +382,17 @@ class Settings extends Page implements HasForms
|
||||
}
|
||||
foreach ([
|
||||
'protocol' => 'imap',
|
||||
'default_account' => 'default'
|
||||
'default_account' => 'default',
|
||||
'premium_protocol' => 'imap',
|
||||
'premium_default_account' => 'default',
|
||||
] as $key => $default) {
|
||||
$data['imap_settings'][$key] ??= $default;
|
||||
}
|
||||
|
||||
$pluckMap = [
|
||||
'domains' => 'domain',
|
||||
'premium_domains' => 'premium_domain',
|
||||
'premium_gmailUsernames' => 'premium_gmailUsername',
|
||||
'gmailUsernames' => 'gmailUsername',
|
||||
'forbidden_ids' => 'forbidden_id',
|
||||
'blocked_domains' => 'blocked_domain'
|
||||
|
||||
Reference in New Issue
Block a user