Functional scheduled executions.

Display last executions.
Support for Services.
This commit is contained in:
Stuart Rowlands
2024-01-05 15:06:36 +10:00
parent 9bbe9567c7
commit e2e6813632
10 changed files with 144 additions and 36 deletions

View File

@@ -26,6 +26,10 @@
@click.prevent="activeTab = 'environment-variables'; window.location.hash = 'environment-variables'"
href="#">Environment
Variables</a>
<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'"
@@ -161,6 +165,9 @@
<livewire:project.shared.environment-variable.all :resource="$service" />
</div>
</div>
<div x-cloak x-show="activeTab === 'scheduled-tasks'">
<livewire:project.shared.scheduled-task.all :resource="$service" />
</div>
<div x-cloak x-show="activeTab === 'danger'">
<livewire:project.shared.danger :resource="$service" />
</div>

View File

@@ -8,24 +8,18 @@
<div class="flex flex-wrap gap-2">
@forelse($resource->scheduled_tasks as $task)
<a class="flex flex-col box"
@if ($resource->type() == 'application')
href="{{ route('project.application.scheduled-tasks', [...$parameters, 'task_uuid' => $task->uuid]) }}">
@elseif ($resource->type() == 'service')
href="{{ route('project.service.scheduled-tasks', [...$parameters, 'task_uuid' => $task->uuid]) }}">
@endif
<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

@@ -0,0 +1,27 @@
<div class="flex flex-col-reverse gap-2">
@forelse($executions as $execution)
<a class="flex flex-col box" wire:click="selectTask({{ data_get($execution, 'id') }})"
@class([
'border-green-500' => data_get($execution, 'status') === 'success',
'border-red-500' => data_get($execution, 'status') === 'failed',
])>
@if (data_get($execution, 'status') === 'running')
<div class="absolute top-2 right-2">
<x-loading />
</div>
@endif
<div>Status: {{ data_get($execution, 'status') }}</div>
<div>Started At: {{ data_get($execution, 'created_at') }}</div>
@if (data_get($execution, 'id') == $selectedKey)
@if (data_get($execution, 'message'))
<div>Output: <pre>{{ data_get($execution, 'message') }}</pre></div>
@else
<div>No output was recorded for this execution.</div>
@endif
@endif
</a>
</a>
@empty
<div>No executions found.</div>
@endforelse
</div>

View File

@@ -7,7 +7,11 @@
</x-modal>
<h1>Scheduled Backup</h1>
@if ($type === 'application')
<livewire:project.application.heading :application="$resource" />
@elseif ($type === 'service')
<livewire:project.service.navbar :service="$resource" :parameters="$parameters" />
@endif
<form wire:submit="submit">
<div class="flex flex-col gap-2 pb-10">
@@ -17,10 +21,6 @@
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>
@@ -33,4 +33,10 @@
<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 class="pt-10">
<h3 class="py-4">Recent executions</h3>
<livewire:project.shared.scheduled-task.executions key="{{ $task->id }}" selectedKey=""
:executions="$task->executions->take(-20)" />
</div>
</div>