All checks were successful
Build & Deploy PLDpro.Web Test to 192.168.1.100 / build-and-deploy (push) Successful in 1m15s
94 lines
4.0 KiB
Plaintext
94 lines
4.0 KiB
Plaintext
@page "/dms/list"
|
||
@using MudBlazor
|
||
@using Pldpro.Web.UI.Models
|
||
@inject Pldpro.Web.UI.Services.IDocumentClient Client
|
||
@inject NavigationManager Nav
|
||
|
||
<MudPaper Class="pa-4">
|
||
<MudStack Row="true" Spacing="2" AlignItems=AlignItems.Center>
|
||
<MudSelect T="string" @bind-Value="_bucket" Label="Bucket" Dense="true" Style="min-width:220px" Required="true">
|
||
@foreach (var b in _buckets)
|
||
{
|
||
<MudSelectItem Value="@b">@b</MudSelectItem>
|
||
}
|
||
</MudSelect>
|
||
<MudTextField @bind-Value="_prefix" Placeholder="Pfad-Prefix (optional, z. B. rechnungen/2026)" />
|
||
<MudTextField @bind-Value="_query" Placeholder="Suche (Datei/Ordner)"
|
||
Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Search" Immediate="true" />
|
||
<MudSpacer />
|
||
<MudButton Variant="Variant.Outlined" OnClick="Reload" StartIcon="@Icons.Material.Filled.Search">Suchen</MudButton>
|
||
<MudButton Variant="Variant.Filled" OnClick="@(() => Nav.NavigateTo("/dms/upload"))"
|
||
StartIcon="@Icons.Material.Filled.CloudUpload">Upload</MudButton>
|
||
</MudStack>
|
||
|
||
<!-- WICHTIG: T="DocumentListItem" angeben -->
|
||
<MudTable T="DocumentListItem" Items="_items" Dense="true" Hover="true" Class="mt-3">
|
||
<HeaderContent>
|
||
<MudTh>Datei</MudTh>
|
||
<MudTh>Bucket</MudTh>
|
||
<MudTh>Pfad</MudTh>
|
||
<MudTh>Größe</MudTh>
|
||
<MudTh>Geändert</MudTh>
|
||
<MudTh></MudTh>
|
||
</HeaderContent>
|
||
|
||
<!-- @context ist vom Typ DocumentListItem -->
|
||
<RowTemplate>
|
||
<MudTd DataLabel="Datei">@context.FileName</MudTd>
|
||
<MudTd DataLabel="Bucket">@context.Bucket</MudTd>
|
||
<MudTd DataLabel="Pfad">@context.PathPrefix</MudTd>
|
||
<MudTd DataLabel="Größe">@context.Size?.ToString("N0")</MudTd>
|
||
<MudTd DataLabel="Geändert">@context.LastModified</MudTd>
|
||
<MudTd Align="TableCellAlign.Right">
|
||
<MudButton Variant="Variant.Text"
|
||
OnClick="@(() => Nav.NavigateTo($"/dms/detail/{Uri.EscapeDataString(context.Bucket)}/{EncodeKeyForPath(context.Key)}"))">
|
||
Details
|
||
</MudButton>
|
||
</MudTd>
|
||
</RowTemplate>
|
||
|
||
<PagerContent>
|
||
<MudTablePager PageSizeOptions="new int[] { 10, 25, 50 }" @bind-PageSize="_pageSize" />
|
||
</PagerContent>
|
||
</MudTable>
|
||
|
||
<MudStack Row="true" Spacing="1" AlignItems=AlignItems.Center Justify=Justify.Center Class="mt-2">
|
||
<MudButton Variant="Variant.Outlined" Disabled="@(_page == 0)" OnClick="Prev">Zurück</MudButton>
|
||
<MudText>Seite @(_page + 1)</MudText>
|
||
<MudButton Variant="Variant.Outlined" Disabled="@(((_page + 1) * _pageSize) >= _total)" OnClick="Next">Weiter</MudButton>
|
||
</MudStack>
|
||
</MudPaper>
|
||
|
||
@code {
|
||
private List<string> _buckets = new();
|
||
private string? _bucket;
|
||
private string? _prefix;
|
||
private string? _query;
|
||
|
||
private int _page = 0, _pageSize = 25, _total = 0;
|
||
private List<DocumentListItem> _items = new();
|
||
|
||
protected override async Task OnInitializedAsync()
|
||
{
|
||
_buckets = (await Client.ListBucketsAsync()).ToList();
|
||
_bucket = _buckets.FirstOrDefault();
|
||
if (!string.IsNullOrWhiteSpace(_bucket))
|
||
await Reload();
|
||
}
|
||
|
||
private async Task Reload()
|
||
{
|
||
if (string.IsNullOrWhiteSpace(_bucket)) return;
|
||
var (items, total) = await Client.SearchAsync(_bucket!, _query, _prefix, _page, _pageSize);
|
||
_items = items.ToList(); // <- Items ist List<DocumentListItem>
|
||
_total = total;
|
||
}
|
||
|
||
private async Task Prev() { if (_page > 0) { _page--; await Reload(); } }
|
||
private async Task Next() { if (((_page + 1) * _pageSize) < _total) { _page++; await Reload(); } }
|
||
|
||
private static string EncodeKeyForPath(string key)
|
||
=> string.Join("/", (key ?? string.Empty)
|
||
.Split('/', StringSplitOptions.RemoveEmptyEntries)
|
||
.Select(Uri.EscapeDataString));
|
||
} |