diff options
Diffstat (limited to 'Pages/Component/AboutDialog.razor')
| -rw-r--r-- | Pages/Component/AboutDialog.razor | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/Pages/Component/AboutDialog.razor b/Pages/Component/AboutDialog.razor index 9ffbad4..1229dc7 100644 --- a/Pages/Component/AboutDialog.razor +++ b/Pages/Component/AboutDialog.razor @@ -1,5 +1,6 @@ @using System.Reflection @using Microsoft.AspNetCore.Hosting +@inject IDbContextFactory<HBContext> dbFactory @inject IHostingEnvironment hostingEnvironment @implements IDialog @@ -672,6 +673,15 @@ <<a href="https://www.gnu.org/licenses/" target="_blank">https://www.gnu.org/licenses/</a>>. </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"); + <p id="progress">Untagged: @($"{untagged}/{total} ({percent}%)")</p> + } + <ProgressBar @ref=progressBar /> + </div> <ButtonContainer> <button @onclick=Hide>Close</button> </ButtonContainer> @@ -680,9 +690,26 @@ @code { private Dialog dialog; + private ProgressBar progressBar; + + private (long Untagged, long Total)? progress; + public bool Visible { get => dialog.Visible; - set => dialog.Visible = value; + 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()); + } + } } public void Show() => Visible = true; |
