Add files to parse page

This commit is contained in:
2025-11-17 17:03:43 +09:00
parent 1be00766ec
commit 60cc921a05
5 changed files with 96 additions and 1 deletions

View File

@ -0,0 +1,73 @@
@page "/files-to-parse"
@using Hcs.WebApp.Services
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize]
@inject AuthenticationStateProvider AuthenticationStateProvider
@inject FileToParseService FileToParseService
@inject NavigationManager NavigationManager
<PageTitle>Файлы для парсинга</PageTitle>
<AuthorizedContent Roles="@($"{AppRole.ADMINISTRATOR_TYPE},{AppRole.OPERATOR_TYPE}")">
<Content>
<RadzenStack>
<RadzenRow AlignItems="AlignItems.Center">
<RadzenColumn Size="12" SizeMD="12">
<RadzenText Text="Файлы для парсинга" TextStyle="TextStyle.H5" class="rz-m-0" />
</RadzenColumn>
</RadzenRow>
<RadzenRow>
<RadzenColumn SizeMD="12">
<RadzenDataGrid TItem="FileToParse" Data="@filesToParse" IsLoading="@(state != PageState.Idle)" AllowFiltering="true" AllowPaging="true" ShowPagingSummary="true" PageSizeOptions=@(new int[] { 5, 10, 20, 30 }) AllowSorting="true" AllowColumnResize="true">
<Columns>
<RadzenDataGridColumn TItem="FileToParse" Property="@nameof(FileToParse.Id)" Title="ID" SortOrder="SortOrder.Descending" Resizable="false" Width="100px" MaxWidth="100px" />
<RadzenDataGridColumn TItem="FileToParse" Property="@nameof(FileToParse.FileName)" Title="Имя файла" />
<RadzenDataGridColumn TItem="FileToParse" Property="@nameof(FileToParse.UploadedAt)" Title="Дата загрузки" Width="150px" />
<RadzenDataGridColumn TItem="FileToParse" Property="@nameof(FileToParse.ParsedAt)" Title="Дата парсинга" Width="150px" />
<RadzenDataGridColumn TItem="FileToParse" Filterable="false" Sortable="false" TextAlign="TextAlign.Center" Width="70px">
<Template Context="fileToParse">
<RadzenButton Click="@(() => NavigationManager.NavigateTo(fileToParse.Path, true))" @onclick:stopPropagation="true" ButtonStyle="ButtonStyle.Primary" Icon="download" Size="ButtonSize.Small" />
</Template>
</RadzenDataGridColumn>
</Columns>
</RadzenDataGrid>
</RadzenColumn>
</RadzenRow>
</RadzenStack>
</Content>
</AuthorizedContent>
@code {
PageState state;
ICollection<FileToParse>? filesToParse;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
if (firstRender)
{
ChangeState(PageState.Loading);
var state = await AuthenticationStateProvider.GetAuthenticationStateAsync();
if (state.User.IsOperatorOrHigher())
{
filesToParse = await FileToParseService.GetAllFilesToParseAsync();
}
ChangeState(PageState.Idle);
}
}
void ChangeState(PageState state)
{
if (this.state == state) return;
this.state = state;
StateHasChanged();
}
}