2022-01-11 16:26:47 +00:00
|
|
|
@using Wabbajack.RateLimiter
|
2022-01-27 07:48:32 +00:00
|
|
|
@using System
|
|
|
|
@using System.Reactive.Linq
|
2022-01-28 11:58:28 +00:00
|
|
|
@implements IDisposable
|
2022-01-20 08:34:38 +00:00
|
|
|
|
|
|
|
@namespace Wabbajack.App.Blazor.Components
|
|
|
|
|
|
|
|
<div id="progress-bar">
|
2022-01-28 11:58:28 +00:00
|
|
|
<progress max="1" value="@CurrentProgress.ToString("F")"></progress>
|
2022-01-20 10:19:10 +00:00
|
|
|
<span class="text">@Text</span>
|
2022-01-20 08:34:38 +00:00
|
|
|
</div>
|
2022-01-11 03:00:54 +00:00
|
|
|
|
|
|
|
@code {
|
2022-01-28 11:58:28 +00:00
|
|
|
[Parameter] public IObservable<Percent>? ProgressObserver { get; set; }
|
2022-01-11 03:00:54 +00:00
|
|
|
|
2022-01-27 07:48:32 +00:00
|
|
|
private double CurrentProgress { get; set; }
|
2022-01-28 11:58:28 +00:00
|
|
|
private string Text { get; set; } = string.Empty;
|
2022-01-17 16:46:54 +00:00
|
|
|
|
2022-01-28 11:58:28 +00:00
|
|
|
private IDisposable? _disposable;
|
|
|
|
|
2022-01-28 05:05:30 +00:00
|
|
|
protected override void OnInitialized()
|
2022-01-27 07:48:32 +00:00
|
|
|
{
|
2022-01-28 11:58:28 +00:00
|
|
|
if (ProgressObserver is null) return;
|
|
|
|
|
|
|
|
_disposable = ProgressObserver
|
2022-01-27 07:48:32 +00:00
|
|
|
.Sample(TimeSpan.FromMilliseconds(250))
|
2022-01-28 05:05:30 +00:00
|
|
|
.DistinctUntilChanged(p => p.Value)
|
2022-01-28 11:58:28 +00:00
|
|
|
.Subscribe(p =>
|
|
|
|
{
|
2022-01-27 07:48:32 +00:00
|
|
|
CurrentProgress = p.Value;
|
2022-01-28 11:58:28 +00:00
|
|
|
Text = p.ToString();
|
2022-01-27 07:48:32 +00:00
|
|
|
InvokeAsync(StateHasChanged);
|
|
|
|
});
|
|
|
|
}
|
2022-01-28 11:58:28 +00:00
|
|
|
|
|
|
|
public void Dispose() => _disposable?.Dispose();
|
|
|
|
|
2022-01-17 16:46:54 +00:00
|
|
|
}
|