LANCommander/LANCommander.Client/UI/Components/DownloadQueue.razor
2024-06-08 23:38:55 -05:00

58 lines
1.8 KiB
Text

@inject DownloadService DownloadService
<Drawer Placement="bottom" Class="download-queue" @bind-Visible="@Visible">
<h2>In Progress</h2>
@foreach (var queueItem in DownloadService.Queue.Where(qi => qi.State))
{
<div class="queue-item">
<MediaImage Id="@queueItem.CoverId" />
<div class="queue-item-info">
<div>
<h4>@queueItem.Title | @queueItem</h4>
<span>@queueItem.BytesDownloaded / @queueItem.TotalBytes</span>
</div>
</div>
</div>
}
<h2>Up Next</h2>
@foreach (var queueItem in DownloadService.Queue.Where(qi => qi.Status == Enums.DownloadStatus.Idle))
{
<div class="queue-item">
<MediaImage Id="@queueItem.CoverId" />
<div class="queue-item-info">
<div>
<h4>@queueItem.Title | @queueItem</h4>
<span>@queueItem.BytesDownloaded / @queueItem.TotalBytes</span>
</div>
</div>
</div>
}
<h2>Completed</h2>
@foreach (var queueItem in DownloadService.Queue.Where(qi => !qi.State))
{
<div class="queue-item">
<MediaImage Id="@queueItem.CoverId" />
<div class="queue-item-info">
<div>
<h4>@queueItem.Title | @queueItem</h4>
<span>@queueItem.BytesDownloaded / @queueItem.TotalBytes</span>
</div>
</div>
</div>
}
</Drawer>
@code {
[Parameter] public bool Visible { get; set; }
[Parameter] public EventCallback<bool> VisibleChanged { get; set; }
protected override async Task OnInitializedAsync()
{
DownloadService.OnQueueChanged += async () =>
{
StateHasChanged();
};
}
}