mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 14:46:53 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			85 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			85 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Filament\Server\Resources\Schedules\Pages;
 | |
| 
 | |
| use App\Facades\Activity;
 | |
| use App\Filament\Components\Actions\ExportScheduleAction;
 | |
| use App\Filament\Server\Resources\Schedules\ScheduleResource;
 | |
| use App\Models\Schedule;
 | |
| use App\Traits\Filament\CanCustomizeHeaderActions;
 | |
| use App\Traits\Filament\CanCustomizeHeaderWidgets;
 | |
| use Filament\Actions\Action;
 | |
| use Filament\Actions\ActionGroup;
 | |
| use Filament\Actions\DeleteAction;
 | |
| use Filament\Resources\Pages\EditRecord;
 | |
| use Filament\Support\Enums\IconSize;
 | |
| 
 | |
| class EditSchedule extends EditRecord
 | |
| {
 | |
|     use CanCustomizeHeaderActions;
 | |
|     use CanCustomizeHeaderWidgets;
 | |
| 
 | |
|     protected static string $resource = ScheduleResource::class;
 | |
| 
 | |
|     protected function afterSave(): void
 | |
|     {
 | |
|         /** @var Schedule $schedule */
 | |
|         $schedule = $this->record;
 | |
| 
 | |
|         Activity::event('server:schedule.update')
 | |
|             ->property('name', $schedule->name)
 | |
|             ->log();
 | |
|     }
 | |
| 
 | |
|     protected function mutateFormDataBeforeSave(array $data): array
 | |
|     {
 | |
|         $data['next_run_at'] = ScheduleResource::getNextRun(
 | |
|             $data['cron_minute'],
 | |
|             $data['cron_hour'],
 | |
|             $data['cron_day_of_month'],
 | |
|             $data['cron_month'],
 | |
|             $data['cron_day_of_week']
 | |
|         );
 | |
| 
 | |
|         return $data;
 | |
|     }
 | |
| 
 | |
|     /** @return array<Action|ActionGroup> */
 | |
|     protected function getDefaultHeaderActions(): array
 | |
|     {
 | |
|         return [
 | |
|             DeleteAction::make()
 | |
|                 ->hiddenLabel()->iconButton()->iconSize(IconSize::ExtraLarge)
 | |
|                 ->icon('tabler-trash')
 | |
|                 ->tooltip(trans('server/schedule.delete'))
 | |
|                 ->after(function ($record) {
 | |
|                     Activity::event('server:schedule.delete')
 | |
|                         ->property('name', $record->name)
 | |
|                         ->log();
 | |
|                 }),
 | |
|             ExportScheduleAction::make()
 | |
|                 ->hiddenLabel()->iconButton()->iconSize(IconSize::ExtraLarge)
 | |
|                 ->icon('tabler-download')
 | |
|                 ->tooltip(trans('server/schedule.export')),
 | |
|             $this->getSaveFormAction()->formId('form')
 | |
|                 ->hiddenLabel()->iconButton()->iconSize(IconSize::ExtraLarge)
 | |
|                 ->icon('tabler-device-floppy')
 | |
|                 ->tooltip(trans('server/schedule.save')),
 | |
|             $this->getCancelFormAction()->formId('form')
 | |
|                 ->hiddenLabel()->iconButton()->iconSize(IconSize::ExtraLarge)
 | |
|                 ->icon('tabler-cancel')
 | |
|                 ->tooltip(trans('server/schedule.cancel')),
 | |
|         ];
 | |
|     }
 | |
| 
 | |
|     public function getBreadcrumbs(): array
 | |
|     {
 | |
|         return [];
 | |
|     }
 | |
| 
 | |
|     protected function getFormActions(): array
 | |
|     {
 | |
|         return [];
 | |
|     }
 | |
| }
 | 
