* re-enable plex, temp force secure connections * add plex fanart * synchronize genre from plex * fix plex library sync * improve stream error handling * synchronize plex artwork * use switch instead of button * prioritize local connections for insecure plex sources * sign out of plex * better plex sign in/out * code cleanup * fix plex movie aspect ratio and scan type
135 lines
4.9 KiB
Plaintext
135 lines
4.9 KiB
Plaintext
@page "/media/sources/plex/{Id:int}/paths"
|
|
@using ErsatzTV.Application.Plex
|
|
@using ErsatzTV.Application.Plex.Commands
|
|
@using ErsatzTV.Application.Plex.Queries
|
|
@inject NavigationManager NavigationManager
|
|
@inject ILogger<ScheduleItemsEditor> Logger
|
|
@inject ISnackbar Snackbar
|
|
@inject IMediator Mediator
|
|
|
|
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="pt-8">
|
|
<MudTable Hover="true" Items="_pathReplacements.OrderBy(r => r.Id)" Dense="true" @bind-SelectedItem="_selectedItem">
|
|
<ToolBarContent>
|
|
<MudText Typo="Typo.h6"><b>@_source.Name</b> Path Replacements</MudText>
|
|
</ToolBarContent>
|
|
<ColGroup>
|
|
<col/>
|
|
<col/>
|
|
<col style="width: 60px;"/>
|
|
</ColGroup>
|
|
<HeaderContent>
|
|
<MudTh>Plex Path</MudTh>
|
|
<MudTh>Local Path</MudTh>
|
|
<MudTh/>
|
|
</HeaderContent>
|
|
<RowTemplate>
|
|
<MudTd DataLabel="Plex Path">
|
|
<MudText Typo="@(context == _selectedItem ? Typo.subtitle2 : Typo.body2)">
|
|
@context.PlexPath
|
|
</MudText>
|
|
</MudTd>
|
|
<MudTd DataLabel="Local Path">
|
|
<MudText Typo="@(context == _selectedItem ? Typo.subtitle2 : Typo.body2)">
|
|
@context.LocalPath
|
|
</MudText>
|
|
</MudTd>
|
|
<MudTd>
|
|
<MudTooltip Text="Delete Path Replacement">
|
|
<MudIconButton Icon="@Icons.Material.Filled.Delete"
|
|
OnClick="@(_ => RemovePathReplacement(context))">
|
|
</MudIconButton>
|
|
</MudTooltip>
|
|
</MudTd>
|
|
</RowTemplate>
|
|
</MudTable>
|
|
<MudButton Variant="Variant.Filled" Color="Color.Default" OnClick="@(_ => AddPathReplacement())" Class="mt-4">
|
|
Add Path Replacement
|
|
</MudButton>
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@(_ => SaveChanges())" Class="mt-4 ml-4">
|
|
Save Changes
|
|
</MudButton>
|
|
|
|
@if (_selectedItem is not null)
|
|
{
|
|
<div style="max-width: 400px;">
|
|
<EditForm Model="_selectedItem">
|
|
<FluentValidator/>
|
|
<MudCard Class="mt-6">
|
|
<MudCardContent>
|
|
<MudTextField Label="Plex Path"
|
|
@bind-Value="@_selectedItem.PlexPath"
|
|
For="@(() => _selectedItem.PlexPath)"/>
|
|
<MudTextField Class="mt-3"
|
|
Label="Local Path"
|
|
@bind-Value="@_selectedItem.LocalPath"
|
|
For="@(() => _selectedItem.LocalPath)"/>
|
|
</MudCardContent>
|
|
</MudCard>
|
|
</EditForm>
|
|
</div>
|
|
}
|
|
</MudContainer>
|
|
|
|
@code {
|
|
|
|
[Parameter]
|
|
public int Id { get; set; }
|
|
|
|
private PlexMediaSourceViewModel _source;
|
|
private List<PlexPathReplacementEditViewModel> _pathReplacements;
|
|
|
|
private PlexPathReplacementEditViewModel _selectedItem;
|
|
|
|
protected override Task OnParametersSetAsync() => LoadData();
|
|
|
|
private async Task LoadData()
|
|
{
|
|
Option<PlexMediaSourceViewModel> maybeSource = await Mediator.Send(new GetPlexMediaSourceById(Id));
|
|
await maybeSource.Match(
|
|
async source =>
|
|
{
|
|
_source = source;
|
|
_pathReplacements = await Mediator.Send(new GetPlexPathReplacementsBySourceId(Id))
|
|
.Map(list => list.Map(ProjectToEditViewModel).ToList());
|
|
},
|
|
() =>
|
|
{
|
|
NavigationManager.NavigateTo("404");
|
|
return Task.CompletedTask;
|
|
});
|
|
}
|
|
|
|
private PlexPathReplacementEditViewModel ProjectToEditViewModel(PlexPathReplacementViewModel item) =>
|
|
new() { Id = item.Id, PlexPath = item.PlexPath, LocalPath = item.LocalPath };
|
|
|
|
private void AddPathReplacement()
|
|
{
|
|
var item = new PlexPathReplacementEditViewModel();
|
|
_pathReplacements.Add(item);
|
|
_selectedItem = item;
|
|
}
|
|
|
|
private void RemovePathReplacement(PlexPathReplacementEditViewModel item)
|
|
{
|
|
_selectedItem = null;
|
|
_pathReplacements.Remove(item);
|
|
}
|
|
|
|
private async Task SaveChanges()
|
|
{
|
|
var items = _pathReplacements
|
|
.Map(item => new PlexPathReplacementItem(item.Id, item.PlexPath, item.LocalPath))
|
|
.ToList();
|
|
|
|
Seq<BaseError> errorMessages = await Mediator.Send(new UpdatePlexPathReplacements(Id, items)).Map(e => e.LeftToSeq());
|
|
|
|
errorMessages.HeadOrNone().Match(
|
|
error =>
|
|
{
|
|
Snackbar.Add($"Unexpected error saving path replacements: {error.Value}", Severity.Error);
|
|
Logger.LogError("Unexpected error saving path replacements: {Error}", error.Value);
|
|
},
|
|
() => NavigationManager.NavigateTo("/media/plex"));
|
|
}
|
|
|
|
} |