Files
ersatztv/ErsatzTV/Pages/EmbyPathReplacementsEditor.razor
T
Jason DoveandGitHub 50529ee6ad add emby media source (#201)
* properly scope jellyfin disconnect

* add emby entities

* add emby media source page

* add emby media source editor

* sync emby libraries

* enable emby library sync toggle

* add emby path replacements editor

* add emby movie synchronization

* fix emby artwork

* sync emby television

* code cleanup

* add jellyfin/emby address placeholder

* tweak jellyfin/emby address form
2021-05-23 03:05:23 -05:00

44 lines
1.7 KiB
Plaintext

@page "/media/sources/emby/{Id:int}/paths"
@using ErsatzTV.Application.MediaSources
@using ErsatzTV.Application.Emby.Queries
@using ErsatzTV.Application.Emby
@using ErsatzTV.Application.Emby.Commands
@using Unit = LanguageExt.Unit
@inject NavigationManager _navigationManager
@inject ILogger<ScheduleItemsEditor> _logger
@inject ISnackbar _snackbar
@inject IMediator _mediator
<RemoteMediaSourcePathReplacementsEditor
Id="@Id"
Name="Emby"
GetMediaSourceById="GetMediaSourceById"
GetUpdatePathReplacementsRequest="GetUpdatePathReplacementsRequest"
GetPathReplacementsBySourceId="GetPathReplacementsBySourceId"/>
@code {
[Parameter]
public int Id { get; set; }
private Task<Option<RemoteMediaSourceViewModel>> GetMediaSourceById(int id) =>
_mediator.Send(new GetEmbyMediaSourceById(Id))
.MapT(vm => new RemoteMediaSourceViewModel(vm.Id, vm.Name, vm.Address));
private Task<List<RemoteMediaSourcePathReplacementEditViewModel>> GetPathReplacementsBySourceId(int mediaSourceId) =>
_mediator.Send(new GetEmbyPathReplacementsBySourceId(Id))
.Map(list => list.Map(ProjectToEditViewModel).ToList());
private RemoteMediaSourcePathReplacementEditViewModel ProjectToEditViewModel(EmbyPathReplacementViewModel item) =>
new() { Id = item.Id, RemotePath = item.EmbyPath, LocalPath = item.LocalPath };
private IRequest<Either<BaseError, Unit>> GetUpdatePathReplacementsRequest(List<RemoteMediaSourcePathReplacementEditViewModel> pathReplacements)
{
var items = pathReplacements
.Map(item => new EmbyPathReplacementItem(item.Id, item.RemotePath, item.LocalPath))
.ToList();
return new UpdateEmbyPathReplacements(Id, items);
}
}