WIP start of scheduled tasks.

This commit is contained in:
Stuart Rowlands
2024-01-01 10:33:16 -08:00
parent d5b3e88fc4
commit adecf328fc
10 changed files with 440 additions and 0 deletions

View File

@@ -54,6 +54,9 @@
href="#">Resource Limits
</a>
@endif
<a :class="activeTab === 'scheduled-tasks' && 'text-white'"
@click.prevent="activeTab = 'scheduled-tasks'; window.location.hash = 'scheduled-tasks'" href="#">Scheduled Tasks
</a>
<a :class="activeTab === 'danger' && 'text-white'"
@click.prevent="activeTab = 'danger'; window.location.hash = 'danger'" href="#">Danger Zone
</a>
@@ -97,6 +100,9 @@
<div x-cloak x-show="activeTab === 'resource-limits'">
<livewire:project.shared.resource-limits :resource="$application" />
</div>
<div x-cloak x-show="activeTab === 'scheduled-tasks'">
<livewire:project.shared.scheduled-task.all :resource="$application" />
</div>
<div x-cloak x-show="activeTab === 'danger'">
<livewire:project.shared.danger :resource="$application" />
</div>

View File

@@ -0,0 +1,15 @@
<dialog id="newTask" class="modal">
<form method="dialog" class="flex flex-col gap-2 rounded modal-box" wire:submit='submit'>
<h3 class="text-lg font-bold">Add Scheduled Task</h3>
<x-forms.input placeholder="Run cron" id="name" label="Name" required />
<x-forms.input placeholder="php artisan schedule:run" id="command" label="Command" required />
<x-forms.input placeholder="0 0 * * * or daily" id="frequency" label="Frequency" required />
<x-forms.input placeholder="php" id="container" label="Container name" />
<x-forms.button onclick="newTask.close()" type="submit">
Save
</x-forms.button>
</form>
<form method="dialog" class="modal-backdrop">
<button>close</button>
</form>
</dialog>

View File

@@ -0,0 +1,16 @@
<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>
@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>

View File

@@ -0,0 +1,21 @@
<div>
<x-modal yesOrNo modalId="{{ $modalId }}" modalTitle="Delete Scheduled Task">
<x-slot:modalBody>
<p>Are you sure you want to delete this scheduled task <span
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>
</div>
</form>
</div>