LANCommander/LANCommander.Launcher/UI/Components/DownloadQueue.razor
Pat Hartl 9ba9887eb1 Rename project files, namespaces, artifacts
Client has been renamed to launcher, and thus namespaces and artifact names had to change. The server project has also had some artifacts renamed in order to create a more clear separation of builds. This will break auto-updates before v0.9.0.
2024-08-04 17:53:19 -05:00

96 lines
3.3 KiB
Text

@using LANCommander.Launcher.Models
@inject DownloadService DownloadService
@inject NavigationManager NavigationManager
<Drawer Placement="bottom" Class="download-queue" @bind-Visible="@Visible" OnClose="() => Visible = false">
@if (DownloadService.Queue.Any(qi => qi.State))
{
<h2>In Progress</h2>
@foreach (var queueItem in DownloadService.Queue.Where(qi => qi.State))
{
<div class="queue-item">
<MediaImage Id="@queueItem.CoverId" Class="queue-item-cover" />
<div class="queue-item-info">
<div>
<h3>@queueItem.Title</h3>
</div>
</div>
<div class="queue-item-current-download">
<CurrentDownloadItem />
</div>
</div>
}
}
<h2>Up Next</h2>
@foreach (var queueItem in DownloadService.Queue.Where(qi => !qi.State && qi.Status == Enums.DownloadStatus.Idle))
{
<div class="queue-item">
<MediaImage Id="@queueItem.CoverId" Class="queue-item-cover" />
<div class="queue-item-info">
<div>
<h3>@queueItem.Title</h3>
</div>
</div>
<div class="queue-item-actions">
<Button Icon="@IconType.Outline.Close" Size="@ButtonSize.Large" Danger OnClick="() => Remove(queueItem)" />
</div>
</div>
}
@if (!DownloadService.Queue.Any(qi => qi.Status == Enums.DownloadStatus.Idle))
{
<Empty Simple Description="@("The queue is empty")" />
}
@if (DownloadService.Queue.Any(qi => !qi.State && qi.Status != Enums.DownloadStatus.Idle && qi.Status != Enums.DownloadStatus.Failed && qi.Status != Enums.DownloadStatus.Canceled))
{
<h2>Completed</h2>
@foreach (var queueItem in DownloadService.Queue.Where(qi => !qi.State))
{
<div class="queue-item">
<MediaImage Id="@queueItem.CoverId" Class="queue-item-cover" />
<div class="queue-item-info">
<div>
<h3>@queueItem.Title</h3>
<span>@ByteSizeLib.ByteSize.FromBytes(queueItem.TotalBytes)</span>
</div>
</div>
<div class="queue-item-actions">
<PlayButton LibraryItemId="@queueItem.Id">
<MenuExtra>
<MenuItem OnClick="() => ViewInLibrary(queueItem)">
View in Library
</MenuItem>
</MenuExtra>
</PlayButton>
</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();
};
}
async Task Remove(IDownloadQueueItem queueItem)
{
DownloadService.Remove(queueItem);
}
async Task ViewInLibrary(IDownloadQueueItem queueItem)
{
Visible = false;
NavigationManager.NavigateTo("/" + queueItem.Id);
}
}