91 lines
3.6 KiB
Plaintext
91 lines
3.6 KiB
Plaintext
@using Microsoft.AspNetCore.Components.Web
|
|
@using PlcVanguard.Web.Components.Shared
|
|
|
|
<div class="rounded-xl border border-gray-200 bg-white p-6 shadow-sm">
|
|
<h2 class="font-semibold text-lg mb-4">Recording Sessions</h2>
|
|
<div class="overflow-x-auto">
|
|
<table class="w-full text-left text-xs">
|
|
<thead class="bg-gray-50">
|
|
<tr class="border-b">
|
|
<th class="p-2">Session ID</th>
|
|
<th class="p-2">Timestamp</th>
|
|
<th class="p-2">Status</th>
|
|
<th class="p-2">Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@if (Sessions.Any())
|
|
{
|
|
@foreach (var s in Sessions)
|
|
{
|
|
<tr class="border-b hover:bg-gray-50 transition">
|
|
<td class="p-2 font-mono font-semibold text-blue-600">@s.Id</td>
|
|
<td class="p-2">@s.Timestamp.ToString("yyyy-MM-dd HH:mm:ss")</td>
|
|
<td class="p-2">
|
|
@if (s.Status == "Success")
|
|
{
|
|
<span class="px-2 py-1 rounded-full text-[10px] font-bold bg-green-100 text-green-700">@s.Status</span>
|
|
}
|
|
else
|
|
{
|
|
<span class="px-2 py-1 rounded-full text-[10px] font-bold bg-gray-100 text-gray-700">@s.Status</span>
|
|
}
|
|
</td>
|
|
<td class="p-2">
|
|
<button class="text-blue-600 hover:underline font-semibold"
|
|
@onclick="() => SelectedSession.InvokeAsync(s.Id)">
|
|
Load
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
}
|
|
}
|
|
else
|
|
{
|
|
<tr>
|
|
<td colspan="4" class="p-4 text-center text-gray-400 italic">No recording sessions found.</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
@if (Sessions.Any())
|
|
{
|
|
<div class="flex justify-between items-center mt-4">
|
|
<button class="px-3 py-1 bg-gray-200 hover:bg-gray-300 rounded text-xs font-semibold transition"
|
|
@onclick="PrevPage"
|
|
disabled="@(Page == 1)">
|
|
Prev
|
|
</button>
|
|
<span class="text-xs text-gray-600">Page @Page of @TotalPages</span>
|
|
<button class="px-3 py-1 bg-gray-200 hover:bg-gray-300 rounded text-xs font-semibold transition"
|
|
@onclick="NextPage"
|
|
disabled="@(Page >= TotalPages)">
|
|
Next
|
|
</button>
|
|
</div>
|
|
}
|
|
</div>
|
|
|
|
@code {
|
|
[Parameter] public List<SessionInfo> Sessions { get; set; } = new();
|
|
[Parameter] public EventCallback<string> SelectedSession { get; set; }
|
|
[Parameter] public int Page { get; set; } = 1;
|
|
[Parameter] public int PageSize { get; set; } = 10;
|
|
|
|
private int TotalPages => (int)Math.Ceiling(Sessions.Count / (double)PageSize);
|
|
|
|
private void PrevPage()
|
|
{
|
|
if (Page > 1)
|
|
SelectedSession.InvokeAsync(Sessions[Math.Max(0, (Page - 2) * PageSize % Sessions.Count)].Id);
|
|
}
|
|
|
|
private void NextPage()
|
|
{
|
|
if (Page < TotalPages)
|
|
SelectedSession.InvokeAsync(Sessions[Math.Min(Sessions.Count - 1, Page * PageSize % Sessions.Count)].Id);
|
|
}
|
|
}
|