Files
ersatztv/ErsatzTV/Pages/LocalLibraryEditor.razor
T
Jason DoveandGitHub e3b91e62ae new movie layout, new dark ui (#55)
* include cache header on artwork responses

* rework movie page to include fan art

* full width app bar

* dark mode

* cleanup

* fix placeholder color
2021-03-10 03:26:51 +00:00

74 lines
2.6 KiB
Plaintext

@page "/media/libraries/local/{Id:int}"
@using ErsatzTV.Application.Libraries
@using ErsatzTV.Application.Libraries.Commands
@using ErsatzTV.Application.Libraries.Queries
@inject IDialogService Dialog
@inject IMediator Mediator
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="pt-8">
<MudTable Hover="true" Items="_libraryPaths" Dense="true">
<ToolBarContent>
<MudText Typo="Typo.h6">Library Paths</MudText>
</ToolBarContent>
<ColGroup>
<col/>
<col style="width: 60px;"/>
</ColGroup>
<HeaderContent>
<MudTh>Path</MudTh>
<MudTh/>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="Path">@context.Path</MudTd>
<MudTd>
<div style="align-items: center; display: flex;">
<MudTooltip Text="Delete Library Path">
<MudIconButton Icon="@Icons.Material.Filled.Delete"
OnClick="@(() => DeleteLibraryPath(context))">
</MudIconButton>
</MudTooltip>
</div>
</MudTd>
</RowTemplate>
</MudTable>
<MudButton Variant="Variant.Filled" Color="Color.Primary" Link="@($"/media/libraries/local/{Id}/add")" Class="mt-4">
Add Library Path
</MudButton>
</MudContainer>
@code {
[Parameter]
public int Id { get; set; }
private IList<LocalLibraryPathViewModel> _libraryPaths;
protected override async Task OnParametersSetAsync() => await LoadLibraryPaths();
private async Task LoadLibraryPaths() =>
_libraryPaths = await Mediator.Send(new GetLocalLibraryPaths(Id));
private async Task DeleteLibraryPath(LocalLibraryPathViewModel libraryPath)
{
int count = await Mediator.Send(new CountMediaItemsByLibraryPath(libraryPath.Id));
var parameters = new DialogParameters
{
{ "EntityType", "library path" },
{ "EntityName", libraryPath.Path },
{ "DetailText", $"This library path contains {count} media items." },
{ "DetailHighlight", count.ToString() }
};
var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall };
IDialogReference dialog = Dialog.Show<DeleteDialog>("Delete Library Path", parameters, options);
DialogResult result = await dialog.Result;
if (!result.Cancelled)
{
await Mediator.Send(new DeleteLocalLibraryPath(libraryPath.Id));
await LoadLibraryPaths();
}
}
}