diff options
| author | Jake Mannens <jake@asger.xyz> | 2026-05-25 01:06:59 +1000 |
|---|---|---|
| committer | Jake Mannens <jake@asger.xyz> | 2026-06-22 00:35:40 +1000 |
| commit | c10e6ef1a001fde7c1ab834784d68b003619b408 (patch) | |
| tree | 46069ee87f753ee97de99fcf93a044f7b219b4a4 /Pages/Component/AboutDialog.razor | |
| parent | 703dac9f34a93cf244675a453fe8e49e6a1d7482 (diff) | |
Re-implemented existing features via the APIdev
Diffstat (limited to 'Pages/Component/AboutDialog.razor')
| -rw-r--r-- | Pages/Component/AboutDialog.razor | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/Pages/Component/AboutDialog.razor b/Pages/Component/AboutDialog.razor index fa7b1ca..f696549 100644 --- a/Pages/Component/AboutDialog.razor +++ b/Pages/Component/AboutDialog.razor @@ -1,9 +1,7 @@ -@using System.Reflection -@* - * @using Microsoft.AspNetCore.Hosting - * @inject IDbContextFactory<HBContext> dbFactory - * @inject IHostingEnvironment hostingEnvironment - *@ +@using Microsoft.AspNetCore.Components.WebAssembly.Hosting +@using System.Reflection +@inject IWebAssemblyHostEnvironment hostEnvironment +@inject HBSession hb @implements IDialog <Dialog @ref=dialog> @@ -676,16 +674,19 @@ </div> <a href="https://gitlab.com/plasmicplexus/HyperBooru-Server" target="_blank">Source</a> <div id="progressContainer"> - @if(progress.HasValue) { - var untagged = progress.Value.Untagged.ToString("N0"); - var total = progress.Value.Total.ToString("N0"); - var percent = (progress.Value.Untagged * 100f / progress.Value.Total).ToString("f1"); + @if(ingestStatistics is not null) { + var untagged = ingestStatistics.UntaggedMediaCount.ToString("N0"); + var total = ingestStatistics.TotalMediaCount.ToString("N0"); + var percent = + (ingestStatistics.UntaggedMediaCount * 100f / ingestStatistics.TotalMediaCount).ToString("f1"); <p id="progress">Untagged: @($"{untagged}/{total} ({percent}%)")</p> } <ProgressBar @ref=progressBar /> </div> <ButtonContainer> - <button @onclick=Hide>Close</button> + <Button + BackgroundColor=Color.ButtonPrimary + OnClick=@(async () => Hide())>Close</Button> </ButtonContainer> </Dialog> @@ -694,23 +695,15 @@ private ProgressBar progressBar; - private (long Untagged, long Total)? progress; + private IngestStatistics? ingestStatistics; public bool Visible { get => dialog.Visible; set { dialog.Visible = value; - if(value) { - // using var db = dbFactory.CreateDbContext(); - // progress = ( - // Untagged: db.Media - // .Where(m => m.Tags.Any(t => t.TagDefinition.ObjectId == (int) HBObjectId.IngestTag)) - // .Count(), - // Total: db.Media.Count() - // ); - // progressBar.Progress = (float) progress.Value!.Untagged / (float) progress.Value!.Total; - // InvokeAsync(() => StateHasChanged()); - } + InvokeAsync(() => StateHasChanged()); + if(value) + LoadProgressAsync(); } } @@ -731,8 +724,15 @@ #if DEBUG return "(Development)"; #else - return hostingEnvironment.IsDevelopment() ? "(Development)" : null; + return hostEnvironment.IsDevelopment() ? "(Development)" : null; #endif } } + + private async void LoadProgressAsync() { + ingestStatistics = await hb.Statistics.GetIngestStatisticsAsync(); + progressBar.Progress = + (float) ingestStatistics.UntaggedMediaCount / (float) ingestStatistics.TotalMediaCount; + await InvokeAsync(() => StateHasChanged()); + } } |
