Complete add/edit/delete for scheduled tasks.

Refactor views.
This commit is contained in:
Stuart Rowlands
2024-01-01 18:23:29 -08:00
parent adecf328fc
commit 7913a639b5
8 changed files with 129 additions and 194 deletions

View File

@@ -1,16 +1,31 @@
<div class="flex flex-col gap-2">
<div>
<div class="flex items-center gap-2">
<h2>Scheduled Tasks</h2>
<x-forms.button class="btn" onclick="newTask.showModal()">+ Add</x-forms.button>
<livewire:project.shared.scheduled-task.add />
</div>
<div>Scheduled Tasks for this resource.</div>
<div>
<div class="flex gap-2">
<h2 class="pb-4">Scheduled Tasks</h2>
<x-forms.button class="btn" onclick="newTask.showModal()">+ Add</x-forms.button>
<livewire:project.shared.scheduled-task.add />
</div>
@forelse ($resource->scheduled_tasks as $task)
<livewire:project.shared.scheduled-task.show wire:key="scheduled-task-{{ $task->id }}"
:task="$task" :type="$resource->type()" />
@empty
<div class="text-neutral-500">No scheduled tasks found.</div>
@endforelse
<div class="flex flex-wrap gap-2">
@forelse($resource->scheduled_tasks as $task)
<a class="flex flex-col box"
href="{{ route('project.application.scheduled-tasks', [...$parameters, 'task_uuid' => $task->uuid]) }}">
<div><span class="font-bold text-warning">{{ $task->name }}<span></div>
<div>Frequency: {{ $task->frequency }}</div>
<div>Last run: {{ data_get($task->latest_log, 'status', 'No runs yet') }}</div>
<div>Next run: @todo</div>
</a>
@empty
<div>No scheduled tasks configured.</div>
@endforelse
</div>
{{-- @if ($type === 'service-database' && $selectedBackup)
<div class="pt-10">
<livewire:project.database.backup-edit key="{{ $selectedBackup->id }}" :backup="$selectedBackup" :s3s="$s3s"
:status="data_get($database, 'status')" />
<h3 class="py-4">Executions</h3>
<livewire:project.database.backup-executions key="{{ $selectedBackup->id }}" :backup="$selectedBackup"
:executions="$selectedBackup->executions" />
</div>
@endif --}}
</div>

View File

@@ -5,17 +5,32 @@
class="font-bold text-warning">({{ $task->name }})</span>?</p>
</x-slot:modalBody>
</x-modal>
<form wire:submit='submit'
class="flex flex-col gap-2 p-4 m-2 border lg:items-center border-coolgray-300 lg:m-0 lg:p-0 lg:border-0 lg:flex-row">
<x-forms.input id="task.name" />
<x-forms.input id="task.command" />
<div class="flex gap-2">
<x-forms.button type="submit">
Update
</x-forms.button>
<x-forms.button isError isModal modalId="{{ $modalId }}">
Delete
</x-forms.button>
<h1>Scheduled Backup</h1>
<livewire:project.application.heading :application="$resource" />
<form wire:submit="submit">
<div class="flex flex-col gap-2 pb-10">
<div class="flex items-end gap-2 pt-4">
<h2>Scheduled Task</h2>
<x-forms.button type="submit">
Save
</x-forms.button>
{{-- @if (Str::of($status)->startsWith('running'))
<livewire:project.database.backup-now :backup="$backup" />
@endif --}}
<x-forms.button isError isModal modalId="{{ $modalId }}">
Delete
</x-forms.button>
</div>
</div>
<x-forms.input placeholder="Run cron" id="task.name" label="Name" required />
<x-forms.input placeholder="php artisan schedule:run" id="task.command" label="Command" required />
<x-forms.input placeholder="0 0 * * * or daily" id="task.frequency" label="Frequency" required />
<x-forms.input placeholder="php" id="task.container" label="Container name" />
</form>
</div>