diff --git a/Hcs.WebApp/Components/Layout/MainLayout.razor b/Hcs.WebApp/Components/Layout/MainLayout.razor index 9eb8fb4..b71a215 100644 --- a/Hcs.WebApp/Components/Layout/MainLayout.razor +++ b/Hcs.WebApp/Components/Layout/MainLayout.razor @@ -37,6 +37,7 @@ + diff --git a/Hcs.WebApp/Components/Pages/FilesToParse.razor b/Hcs.WebApp/Components/Pages/FilesToParse.razor new file mode 100644 index 0000000..3322a03 --- /dev/null +++ b/Hcs.WebApp/Components/Pages/FilesToParse.razor @@ -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 + +Файлы для парсинга + + + + + + + + + + + + + + + + + + + + + + + + + + + + +@code { + PageState state; + ICollection? 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(); + } +} diff --git a/Hcs.WebApp/Data/Hcs/FileToParse.cs b/Hcs.WebApp/Data/Hcs/FileToParse.cs index 5de8282..f629e13 100644 --- a/Hcs.WebApp/Data/Hcs/FileToParse.cs +++ b/Hcs.WebApp/Data/Hcs/FileToParse.cs @@ -4,7 +4,13 @@ { public int Id { get; set; } - public int Path { get; set; } + public string Path { get; set; } + + public string FileName { get; set; } + + public int UploaderId { get; set; } + + public DateTime? UploadedAt { get; set; } public DateTime? ParsedAt { get; set; } diff --git a/Hcs.WebApp/Program.cs b/Hcs.WebApp/Program.cs index 7025049..912a550 100644 --- a/Hcs.WebApp/Program.cs +++ b/Hcs.WebApp/Program.cs @@ -71,6 +71,7 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); diff --git a/Hcs.WebApp/Services/FileToParseService.cs b/Hcs.WebApp/Services/FileToParseService.cs new file mode 100644 index 0000000..61c4479 --- /dev/null +++ b/Hcs.WebApp/Services/FileToParseService.cs @@ -0,0 +1,14 @@ +using Hcs.WebApp.Data.Hcs; +using Microsoft.EntityFrameworkCore; + +namespace Hcs.WebApp.Services +{ + public class FileToParseService(IDbContextFactory factory) : HcsServiceBase(factory) + { + public async Task> GetAllFilesToParseAsync() + { + using var context = GetNewContext(); + return await context.FilesToParse.ToListAsync(); + } + } +}