refactor history view to use Livewire component for dynamic updates; add navigation links for upload and processing history

main
Artem-Darius Weber 1 month ago
parent 513f8ce671
commit a114325425

@ -0,0 +1,28 @@
<?php
namespace App\Http\Livewire;
use App\Models\ProcessHistories;
use Livewire\Component;
class History extends Component
{
public $histories;
protected $listeners = ['refreshHistory' => '$refresh'];
public function mount()
{
$this->loadHistories();
}
public function loadHistories()
{
$this->histories = ProcessHistories::orderBy('id', 'desc')->get();
}
public function render()
{
return view('livewire.history');
}
}

@ -3,44 +3,5 @@
История обработок
</x-slot>
<div class="p-4" wire:poll.750ms>
<h1 class="text-2xl font-bold mb-4">История обработок</h1>
<table class="min-w-full border-collapse">
<thead>
<tr class="border-b">
<th class="p-2 text-left">ID</th>
<th class="p-2 text-left">Изображения</th>
<th class="p-2 text-left">Step файл</th>
<th class="p-2 text-left">Время начала</th>
<th class="p-2 text-left">Время окончания</th>
<th class="p-2 text-left">Обработано</th>
<th class="p-2 text-left">Затраты времени (сек)</th>
</tr>
</thead>
<tbody>
@foreach($histories as $h)
<tr class="border-b">
<td class="p-2">{{ $h->id }}</td>
<td class="p-2">
@foreach($h->images as $img)
<div>{{ $img['original_name'] }} ({{ $img['path'] }})</div>
@endforeach
</td>
<td class="p-2">{{ $h->step_file_name }}</td>
<td class="p-2">{{ $h->started_at }}</td>
<td class="p-2">{{ $h->finished_at }}</td>
<td class="p-2">{{ $h->processed_count }}/3</td>
<td class="p-2">
@if($h->stages_timing)
Очередь: {{ $h->stages_timing['queue_wait_time'] ?? 'N/A' }}<br>
Загрузка: {{ $h->stages_timing['upload_time'] ?? 'N/A' }}<br>
Обработка: {{ $h->stages_timing['processing_time'] ?? 'N/A' }}<br>
Сохранение: {{ $h->stages_timing['saving_time'] ?? 'N/A' }}<br>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</x-app-layout>
<livewire:history />
</x-app-layout>

@ -0,0 +1,40 @@
<div class="p-4" wire:poll.750ms>
<h1 class="text-2xl font-bold mb-4">История обработок</h1>
<table class="min-w-full border-collapse">
<thead>
<tr class="border-b">
<th class="p-2 text-left">ID</th>
<th class="p-2 text-left">Изображения</th>
<th class="p-2 text-left">Step файл</th>
<th class="p-2 text-left">Время начала</th>
<th class="p-2 text-left">Время окончания</th>
<th class="p-2 text-left">Обработано</th>
<th class="p-2 text-left">Затраты времени (сек)</th>
</tr>
</thead>
<tbody>
@foreach($histories as $h)
<tr class="border-b">
<td class="p-2">{{ $h->id }}</td>
<td class="p-2">
@foreach($h->images as $img)
<div>{{ $img['original_name'] }} ({{ $img['path'] }})</div>
@endforeach
</td>
<td class="p-2">{{ $h->step_file_name }}</td>
<td class="p-2">{{ $h->started_at }}</td>
<td class="p-2">{{ $h->finished_at }}</td>
<td class="p-2">{{ $h->processed_count }}/3</td>
<td class="p-2">
@if($h->stages_timing)
Очередь: {{ $h->stages_timing['queue_wait_time'] ?? 'N/A' }}<br>
Загрузка: {{ $h->stages_timing['upload_time'] ?? 'N/A' }}<br>
Обработка: {{ $h->stages_timing['processing_time'] ?? 'N/A' }}<br>
Сохранение: {{ $h->stages_timing['saving_time'] ?? 'N/A' }}<br>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>

@ -15,7 +15,15 @@
<x-jet-nav-link href="{{ route('dashboard') }}" :active="request()->routeIs('dashboard')">
{{ __('Dashboard') }}
</x-jet-nav-link>
</div>
<x-jet-nav-link href="{{ route('upload') }}" :active="request()->routeIs('upload')">
{{ __('Upload Images') }}
</x-jet-nav-link>
<x-jet-nav-link href="{{ route('history') }}" :active="request()->routeIs('history')">
{{ __('Processing History') }}
</x-jet-nav-link>
</div>
</div>
<div class="hidden sm:flex sm:items-center sm:ml-6">
@ -163,6 +171,14 @@
{{ __('Profile') }}
</x-jet-responsive-nav-link>
<x-jet-responsive-nav-link href="{{ route('upload') }}" :active="request()->routeIs('upload')">
{{ __('Upload Images') }}
</x-jet-responsive-nav-link>
<x-jet-responsive-nav-link href="{{ route('history') }}" :active="request()->routeIs('history')">
{{ __('Processing History') }}
</x-jet-responsive-nav-link>
@if (Laravel\Jetstream\Jetstream::hasApiFeatures())
<x-jet-responsive-nav-link href="{{ route('api-tokens.index') }}" :active="request()->routeIs('api-tokens.index')">
{{ __('API Tokens') }}

Loading…
Cancel
Save