mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
3.6 KiB
98 lines
3.6 KiB
@page "/media/libraries" |
|
@using ErsatzTV.Application.Libraries |
|
@using ErsatzTV.Application.Libraries.Queries |
|
@using ErsatzTV.Application.MediaSources.Commands |
|
@using ErsatzTV.Application.Plex.Commands |
|
@implements IDisposable |
|
@inject IMediator Mediator |
|
@inject IEntityLocker Locker |
|
@inject ChannelWriter<IBackgroundServiceRequest> Channel |
|
|
|
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="pt-8"> |
|
<MudTable Hover="true" Items="_libraries" Dense="true"> |
|
<ToolBarContent> |
|
<MudText Typo="Typo.h6">Libraries</MudText> |
|
</ToolBarContent> |
|
<ColGroup> |
|
<col/> |
|
<col/> |
|
<col/> |
|
<col style="width: 120px;"/> |
|
</ColGroup> |
|
<HeaderContent> |
|
<MudTh>Library Kind</MudTh> |
|
<MudTh>Name</MudTh> |
|
<MudTh>Media Kind</MudTh> |
|
<MudTh/> |
|
</HeaderContent> |
|
<RowTemplate> |
|
<MudTd DataLabel="Library Kind">@context.LibraryKind</MudTd> |
|
<MudTd DataLabel="Name">@context.Name</MudTd> |
|
<MudTd DataLabel="Media Kind">@context.MediaKind</MudTd> |
|
<MudTd> |
|
<div style="align-items: center; display: flex;"> |
|
@if (Locker.IsLibraryLocked(context.Id)) |
|
{ |
|
<div style="align-items: center; display: flex; height: 48px; justify-content: center; width: 48px;"> |
|
<MudProgressCircular Color="Color.Primary" Size="Size.Small" Indeterminate="true"/> |
|
</div> |
|
} |
|
else |
|
{ |
|
<MudTooltip Text="Scan Library"> |
|
<MudIconButton Icon="@Icons.Material.Filled.Refresh" |
|
Disabled="@Locker.IsLibraryLocked(context.Id)" |
|
OnClick="@(_ => ScanLibrary(context))"> |
|
</MudIconButton> |
|
</MudTooltip> |
|
} |
|
@if (context is LocalLibraryViewModel) |
|
{ |
|
<MudTooltip Text="Edit Library"> |
|
<MudIconButton Icon="@Icons.Material.Filled.Edit" |
|
Disabled="@Locker.IsLibraryLocked(context.Id)" |
|
Link="@($"/media/libraries/local/{context.Id}")"> |
|
</MudIconButton> |
|
</MudTooltip> |
|
} |
|
</div> |
|
</MudTd> |
|
</RowTemplate> |
|
</MudTable> |
|
</MudContainer> |
|
|
|
@code { |
|
private IList<LibraryViewModel> _libraries; |
|
|
|
protected override void OnInitialized() => |
|
Locker.OnLibraryChanged += LockChanged; |
|
|
|
protected override async Task OnParametersSetAsync() => await LoadLibraries(); |
|
|
|
private async Task LoadLibraries() => |
|
_libraries = await Mediator.Send(new GetAllLibraries()); |
|
|
|
private async Task ScanLibrary(LibraryViewModel library) |
|
{ |
|
if (Locker.LockLibrary(library.Id)) |
|
{ |
|
switch (library) |
|
{ |
|
case LocalLibraryViewModel: |
|
await Channel.WriteAsync(new ForceScanLocalLibrary(library.Id)); |
|
break; |
|
case PlexLibraryViewModel: |
|
await Channel.WriteAsync(new ForceSynchronizePlexLibraryById(library.Id)); |
|
break; |
|
} |
|
|
|
StateHasChanged(); |
|
} |
|
} |
|
|
|
private void LockChanged(object sender, EventArgs e) => |
|
InvokeAsync(StateHasChanged); |
|
|
|
void IDisposable.Dispose() => Locker.OnLibraryChanged -= LockChanged; |
|
|
|
} |