diff --git a/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php b/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php index 7461a950..77b824c9 100644 --- a/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php +++ b/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php @@ -58,7 +58,7 @@ class ScheduleTaskController extends ClientApiController 'schedule_id' => $schedule->id, 'sequence_id' => ($lastTask->sequence_id ?? 0) + 1, 'action' => $request->input('action'), - 'payload' => $request->input('payload'), + 'payload' => $request->input('payload') ?? '', 'time_offset' => $request->input('time_offset'), ]); @@ -87,7 +87,7 @@ class ScheduleTaskController extends ClientApiController $this->repository->update($task->id, [ 'action' => $request->input('action'), - 'payload' => $request->input('payload'), + 'payload' => $request->input('payload') ?? '', 'time_offset' => $request->input('time_offset'), ]); diff --git a/app/Http/Requests/Api/Client/Servers/Schedules/StoreTaskRequest.php b/app/Http/Requests/Api/Client/Servers/Schedules/StoreTaskRequest.php index 50fc9a2c..cd95bf5e 100644 --- a/app/Http/Requests/Api/Client/Servers/Schedules/StoreTaskRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Schedules/StoreTaskRequest.php @@ -25,7 +25,7 @@ class StoreTaskRequest extends ViewScheduleRequest { return [ 'action' => 'required|in:command,power,backup', - 'payload' => 'required_unless:action,backup|string', + 'payload' => 'required_unless:action,backup|string|nullable', 'time_offset' => 'required|numeric|min:0|max:900', 'sequence_id' => 'sometimes|required|numeric|min:1', ]; diff --git a/app/Models/Task.php b/app/Models/Task.php index f5a26b78..f241b071 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -90,7 +90,7 @@ class Task extends Model 'schedule_id' => 'required|numeric|exists:schedules,id', 'sequence_id' => 'required|numeric|min:1', 'action' => 'required|string', - 'payload' => 'required|string', + 'payload' => 'required_unless:action,backup|string', 'time_offset' => 'required|numeric|between:0,900', 'is_queued' => 'boolean', ]; diff --git a/resources/scripts/components/server/schedules/ScheduleTaskRow.tsx b/resources/scripts/components/server/schedules/ScheduleTaskRow.tsx index 516ffa9a..f73f5da9 100644 --- a/resources/scripts/components/server/schedules/ScheduleTaskRow.tsx +++ b/resources/scripts/components/server/schedules/ScheduleTaskRow.tsx @@ -14,12 +14,26 @@ import Can from '@/components/elements/Can'; import useServer from '@/plugins/useServer'; import useFlash from '@/plugins/useFlash'; import { ServerContext } from '@/state/server'; +import { faFileArchive } from '@fortawesome/free-solid-svg-icons/faFileArchive'; interface Props { schedule: Schedule; task: Task; } +const getActionDetails = (action: string): [ string, any ] => { + switch (action) { + case 'command': + return ['Send Command', faCode]; + case 'power': + return ['Send Power Action', faToggleOn]; + case 'backup': + return ['Create Backup', faFileArchive]; + default: + return ['Unknown Action', faCode]; + } +}; + export default ({ schedule, task }: Props) => { const { uuid } = useServer(); const { clearFlashes, addError } = useFlash(); @@ -43,6 +57,8 @@ export default ({ schedule, task }: Props) => { }); }; + const [ title, icon ] = getActionDetails(task.action); + return (
@@ -56,14 +72,19 @@ export default ({ schedule, task }: Props) => { onDismissed={() => setVisible(false)} onConfirmed={() => onConfirmDeletion()} /> - +
-

- {task.action === 'command' ? 'Send command' : 'Send power action'} +

+ {title}

- - {task.payload} - + {task.payload && +
+ {task.action === 'backup' &&

Ignoring files & folders:

} +
+ {task.payload} +
+
+ }
{task.sequenceId > 1 &&
diff --git a/resources/scripts/components/server/schedules/TaskDetailsModal.tsx b/resources/scripts/components/server/schedules/TaskDetailsModal.tsx index 7c6cdbc7..1aef153d 100644 --- a/resources/scripts/components/server/schedules/TaskDetailsModal.tsx +++ b/resources/scripts/components/server/schedules/TaskDetailsModal.tsx @@ -71,7 +71,10 @@ const TaskDetailsForm = ({ isEditingTask }: { isEditingTask: boolean }) => { :
- +