mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 08:44:46 +02:00
Fix schedules (#949)
* Fix schedules * Only explode when payload isn't a power action * Run only on first day of the month Co-authored-by: Boy132 <Boy132@users.noreply.github.com> --------- Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
This commit is contained in:
parent
3202a59b07
commit
7cde90a39a
@ -264,7 +264,7 @@ class ScheduleResource extends Resource
|
|||||||
->action(function (Set $set, $data) {
|
->action(function (Set $set, $data) {
|
||||||
$set('cron_minute', '0');
|
$set('cron_minute', '0');
|
||||||
$set('cron_hour', '0');
|
$set('cron_hour', '0');
|
||||||
$set('cron_day_of_month', '0');
|
$set('cron_day_of_month', '1');
|
||||||
$set('cron_month', '*/' . $data['x']);
|
$set('cron_month', '*/' . $data['x']);
|
||||||
$set('cron_day_of_week', '*');
|
$set('cron_day_of_week', '*');
|
||||||
}),
|
}),
|
||||||
@ -275,13 +275,13 @@ class ScheduleResource extends Resource
|
|||||||
->label('')
|
->label('')
|
||||||
->prefix('Every')
|
->prefix('Every')
|
||||||
->options([
|
->options([
|
||||||
'0' => 'Sunday',
|
|
||||||
'1' => 'Monday',
|
'1' => 'Monday',
|
||||||
'2' => 'Tuesday',
|
'2' => 'Tuesday',
|
||||||
'3' => 'Wednesday',
|
'3' => 'Wednesday',
|
||||||
'4' => 'Thursday',
|
'4' => 'Thursday',
|
||||||
'5' => 'Friday',
|
'5' => 'Friday',
|
||||||
'6' => 'Saturday',
|
'6' => 'Saturday',
|
||||||
|
'0' => 'Sunday',
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
->action(function (Set $set, $data) {
|
->action(function (Set $set, $data) {
|
||||||
|
@ -40,7 +40,8 @@ class TasksRelationManager extends RelationManager
|
|||||||
->live()
|
->live()
|
||||||
->disableOptionWhen(fn (string $value): bool => $value === Task::ACTION_BACKUP && $schedule->server->backup_limit === 0)
|
->disableOptionWhen(fn (string $value): bool => $value === Task::ACTION_BACKUP && $schedule->server->backup_limit === 0)
|
||||||
->options($this->getActionOptions())
|
->options($this->getActionOptions())
|
||||||
->selectablePlaceholder(false),
|
->selectablePlaceholder(false)
|
||||||
|
->default(Task::ACTION_POWER),
|
||||||
Textarea::make('payload')
|
Textarea::make('payload')
|
||||||
->hidden(fn (Get $get) => $get('action') === Task::ACTION_POWER)
|
->hidden(fn (Get $get) => $get('action') === Task::ACTION_POWER)
|
||||||
->label(fn (Get $get) => $this->getActionOptions(false)[$get('action')] ?? 'Payload'),
|
->label(fn (Get $get) => $this->getActionOptions(false)[$get('action')] ?? 'Payload'),
|
||||||
@ -77,13 +78,9 @@ class TasksRelationManager extends RelationManager
|
|||||||
TextColumn::make('action')
|
TextColumn::make('action')
|
||||||
->state(fn (Task $task) => $this->getActionOptions()[$task->action] ?? $task->action),
|
->state(fn (Task $task) => $this->getActionOptions()[$task->action] ?? $task->action),
|
||||||
TextColumn::make('payload')
|
TextColumn::make('payload')
|
||||||
->state(function (Task $task) {
|
->state(fn (Task $task) => match ($task->payload) {
|
||||||
$payload = match ($task->payload) {
|
'start', 'restart', 'stop', 'kill' => mb_ucfirst($task->payload),
|
||||||
'start', 'restart', 'stop', 'kill' => mb_ucfirst($task->payload),
|
default => explode(PHP_EOL, $task->payload)
|
||||||
default => $task->payload
|
|
||||||
};
|
|
||||||
|
|
||||||
return explode(PHP_EOL, $payload);
|
|
||||||
})
|
})
|
||||||
->badge(),
|
->badge(),
|
||||||
TextColumn::make('time_offset')
|
TextColumn::make('time_offset')
|
||||||
@ -94,7 +91,12 @@ class TasksRelationManager extends RelationManager
|
|||||||
])
|
])
|
||||||
->actions([
|
->actions([
|
||||||
EditAction::make()
|
EditAction::make()
|
||||||
->form($this->getTaskForm($schedule)),
|
->form($this->getTaskForm($schedule))
|
||||||
|
->mutateFormDataUsing(function ($data) {
|
||||||
|
$data['payload'] ??= '';
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}),
|
||||||
DeleteAction::make(),
|
DeleteAction::make(),
|
||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user