mirror of
https://github.com/pelican-dev/panel.git
synced 2026-05-04 18:00:48 +03:00
Compare commits
1 Commits
boy132/bac
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bbfb0eef9 |
@@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Events\Server;
|
|
||||||
|
|
||||||
use App\Events\Event;
|
|
||||||
use App\Models\Backup;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
|
|
||||||
class BackupCompleted extends Event
|
|
||||||
{
|
|
||||||
use SerializesModels;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new event instance.
|
|
||||||
*/
|
|
||||||
public function __construct(public Backup $backup) {}
|
|
||||||
}
|
|
||||||
@@ -703,16 +703,6 @@ class Settings extends Page implements HasSchemas
|
|||||||
->formatStateUsing(fn ($state): bool => (bool) $state)
|
->formatStateUsing(fn ($state): bool => (bool) $state)
|
||||||
->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_REINSTALL_NOTIFICATION', (bool) $state))
|
->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_REINSTALL_NOTIFICATION', (bool) $state))
|
||||||
->default(env('PANEL_SEND_REINSTALL_NOTIFICATION', config('panel.email.send_reinstall_notification'))),
|
->default(env('PANEL_SEND_REINSTALL_NOTIFICATION', config('panel.email.send_reinstall_notification'))),
|
||||||
Toggle::make('PANEL_SEND_BACKUP_COMPLETED_NOTIFICATION')
|
|
||||||
->label(trans('admin/setting.misc.mail_notifications.backup_completed'))
|
|
||||||
->onIcon(TablerIcon::Check)
|
|
||||||
->offIcon(TablerIcon::X)
|
|
||||||
->onColor('success')
|
|
||||||
->offColor('danger')
|
|
||||||
->live()
|
|
||||||
->formatStateUsing(fn ($state): bool => (bool) $state)
|
|
||||||
->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_BACKUP_COMPLETED_NOTIFICATION', (bool) $state))
|
|
||||||
->default(env('PANEL_SEND_BACKUP_COMPLETED_NOTIFICATION', config('panel.email.send_backup_completed_notification'))),
|
|
||||||
]),
|
]),
|
||||||
Section::make(trans('admin/setting.misc.connections.title'))
|
Section::make(trans('admin/setting.misc.connections.title'))
|
||||||
->description(trans('admin/setting.misc.connections.helper'))
|
->description(trans('admin/setting.misc.connections.helper'))
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ class TagsFilter extends BaseFilter
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->query(fn (Builder $query, array $data) => $query->when($data['tag'], fn (Builder $query, $tag) => $query->whereJsonContains('tags', $tag)));
|
$this->query(fn (Builder $query, array $data) => $query->when($data['tag'] ?? null, fn (Builder $query, $tag) => $query->whereJsonContains('tags', $tag)));
|
||||||
|
|
||||||
$this->indicateUsing(fn (array $data) => $data['tag'] ? 'Tag: ' . $data['tag'] : null);
|
$this->indicateUsing(fn (array $data) => ($data['tag'] ?? null) ? 'Tag: ' . $data['tag'] : null);
|
||||||
|
|
||||||
$this->resetState(['tag' => null]);
|
$this->resetState(['tag' => null]);
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Api\Remote\Backups;
|
namespace App\Http\Controllers\Api\Remote\Backups;
|
||||||
|
|
||||||
use App\Events\Server\BackupCompleted;
|
|
||||||
use App\Exceptions\DisplayException;
|
use App\Exceptions\DisplayException;
|
||||||
use App\Exceptions\Http\HttpForbiddenException;
|
use App\Exceptions\Http\HttpForbiddenException;
|
||||||
use App\Extensions\Backups\BackupManager;
|
use App\Extensions\Backups\BackupManager;
|
||||||
@@ -80,8 +79,6 @@ class BackupStatusController extends Controller
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
event(new BackupCompleted($model));
|
|
||||||
|
|
||||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Listeners\Server;
|
|
||||||
|
|
||||||
use App\Events\Server\BackupCompleted;
|
|
||||||
use App\Filament\Server\Resources\Backups\Pages\ListBackups;
|
|
||||||
use App\Notifications\BackupCompleted as BackupCompletedNotification;
|
|
||||||
use Filament\Actions\Action;
|
|
||||||
use Filament\Notifications\Notification;
|
|
||||||
|
|
||||||
class BackupCompletedListener
|
|
||||||
{
|
|
||||||
public function handle(BackupCompleted $event): void
|
|
||||||
{
|
|
||||||
$event->backup->loadMissing('server');
|
|
||||||
$event->backup->server->loadMissing('user');
|
|
||||||
|
|
||||||
$locale = $event->backup->server->user->language ?? 'en';
|
|
||||||
|
|
||||||
Notification::make()
|
|
||||||
->status($event->backup->is_successful ? 'success' : 'danger')
|
|
||||||
->title(trans('notifications.backup_' . ($event->backup->is_successful ? 'completed' : 'failed'), locale: $locale))
|
|
||||||
->body(trans('notifications.backup_body', ['name' => $event->backup->name, 'server' => $event->backup->server->name], $locale))
|
|
||||||
->actions([
|
|
||||||
Action::make('exclude_view')
|
|
||||||
->button()
|
|
||||||
->label(trans('notifications.view_backups', locale: $locale))
|
|
||||||
->markAsRead()
|
|
||||||
->url(fn () => ListBackups::getUrl(panel: 'server', tenant: $event->backup->server)),
|
|
||||||
])
|
|
||||||
->sendToDatabase($event->backup->server->user);
|
|
||||||
|
|
||||||
if (config()->get('panel.email.send_backup_completed_notification', true)) {
|
|
||||||
$event->backup->server->user->notify(new BackupCompletedNotification($event->backup));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Notifications;
|
|
||||||
|
|
||||||
use App\Filament\Server\Resources\Backups\Pages\ListBackups;
|
|
||||||
use App\Models\Backup;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
|
||||||
use Illuminate\Notifications\Notification;
|
|
||||||
|
|
||||||
class BackupCompleted extends Notification implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Queueable;
|
|
||||||
|
|
||||||
public function __construct(public Backup $backup) {}
|
|
||||||
|
|
||||||
/** @return string[] */
|
|
||||||
public function via(): array
|
|
||||||
{
|
|
||||||
return ['mail'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toMail(User $notifiable): MailMessage
|
|
||||||
{
|
|
||||||
$locale = $notifiable->language ?? 'en';
|
|
||||||
|
|
||||||
return (new MailMessage())
|
|
||||||
->greeting(trans('mail.greeting', ['name' => $notifiable->username], $locale))
|
|
||||||
->line(trans('mail.backup_completed.body_' . ($this->backup->is_successful ? 'success' : 'failed'), locale: $locale))
|
|
||||||
->line(trans('mail.backup_completed.backup_name', ['name' => $this->backup->name], $locale))
|
|
||||||
->line(trans('mail.backup_completed.server_name', ['name' => $this->backup->server->name], $locale))
|
|
||||||
->action(trans('mail.backup_completed.action', locale: $locale), ListBackups::getUrl(panel: 'server', tenant: $this->backup->server));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -49,8 +49,6 @@ return [
|
|||||||
'send_install_notification' => env('PANEL_SEND_INSTALL_NOTIFICATION', true),
|
'send_install_notification' => env('PANEL_SEND_INSTALL_NOTIFICATION', true),
|
||||||
// Should an email be sent to a server owner whenever their server is reinstalled?
|
// Should an email be sent to a server owner whenever their server is reinstalled?
|
||||||
'send_reinstall_notification' => env('PANEL_SEND_REINSTALL_NOTIFICATION', true),
|
'send_reinstall_notification' => env('PANEL_SEND_REINSTALL_NOTIFICATION', true),
|
||||||
// Should an email be sent to a server owner whenever a backup is completed?
|
|
||||||
'send_backup_completed_notification' => env('PANEL_SEND_BACKUP_COMPLETED_NOTIFICATION', true),
|
|
||||||
],
|
],
|
||||||
|
|
||||||
'filament' => [
|
'filament' => [
|
||||||
|
|||||||
@@ -118,7 +118,6 @@ return [
|
|||||||
'helper' => 'Toggle which mail notifications should be sent to Users.',
|
'helper' => 'Toggle which mail notifications should be sent to Users.',
|
||||||
'server_installed' => 'Server Installed',
|
'server_installed' => 'Server Installed',
|
||||||
'server_reinstalled' => 'Server Reinstalled',
|
'server_reinstalled' => 'Server Reinstalled',
|
||||||
'backup_completed' => 'Backup Completed',
|
|
||||||
],
|
],
|
||||||
'connections' => [
|
'connections' => [
|
||||||
'title' => 'Connections',
|
'title' => 'Connections',
|
||||||
|
|||||||
@@ -28,14 +28,6 @@ return [
|
|||||||
'action' => 'Login and Begin Using',
|
'action' => 'Login and Begin Using',
|
||||||
],
|
],
|
||||||
|
|
||||||
'backup_completed' => [
|
|
||||||
'body_success' => 'The backup was created successfully.',
|
|
||||||
'body_failed' => 'The backup creation failed.',
|
|
||||||
'backup_name' => 'Backup Name: :name',
|
|
||||||
'server_name' => 'Server Name: :name',
|
|
||||||
'action' => 'View Backups',
|
|
||||||
],
|
|
||||||
|
|
||||||
'mail_tested' => [
|
'mail_tested' => [
|
||||||
'subject' => 'Panel Test Message',
|
'subject' => 'Panel Test Message',
|
||||||
'body' => 'This is a test of the Panel mail system. You\'re good to go!',
|
'body' => 'This is a test of the Panel mail system. You\'re good to go!',
|
||||||
|
|||||||
@@ -6,10 +6,6 @@ return [
|
|||||||
'installation_failed' => 'Server Installation Failed',
|
'installation_failed' => 'Server Installation Failed',
|
||||||
'reinstallation_completed' => 'Server Reinstallation Completed',
|
'reinstallation_completed' => 'Server Reinstallation Completed',
|
||||||
'reinstallation_failed' => 'Server Reinstallation Failed',
|
'reinstallation_failed' => 'Server Reinstallation Failed',
|
||||||
'backup_completed' => 'Backup Completed',
|
|
||||||
'backup_failed' => 'Backup Failed',
|
|
||||||
'backup_body' => 'Backup ":name" for server ":server"',
|
|
||||||
'view_backups' => 'View Backups',
|
|
||||||
'failed' => 'Failed',
|
'failed' => 'Failed',
|
||||||
'user_added' => [
|
'user_added' => [
|
||||||
'title' => 'Added to Server',
|
'title' => 'Added to Server',
|
||||||
|
|||||||
Reference in New Issue
Block a user