142 lines
5.8 KiB
Plaintext
142 lines
5.8 KiB
Plaintext
@page "/ffmpeg"
|
|
@using ErsatzTV.Application.FFmpegProfiles
|
|
@implements IDisposable
|
|
@inject IDialogService Dialog
|
|
@inject ISnackbar Snackbar
|
|
@inject IMediator Mediator
|
|
@inject NavigationManager NavigationManager
|
|
|
|
<MudForm Style="max-height: 100%">
|
|
<MudPaper Square="true" Style="display: flex; height: 64px; min-height: 64px; width: 100%; z-index: 100; align-items: center">
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" Class="ml-6" StartIcon="@Icons.Material.Filled.Add" Href="ffmpeg/add">
|
|
Add Profile
|
|
</MudButton>
|
|
</MudPaper>
|
|
<div class="d-flex flex-column" style="height: 100vh; overflow-x: auto">
|
|
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="pt-8">
|
|
<MudText Typo="Typo.h5" Class="mb-2">FFmpeg Profiles</MudText>
|
|
<MudDivider Class="mb-6"/>
|
|
<MudTable Hover="true" Items="_ffmpegProfiles">
|
|
<ColGroup>
|
|
<MudHidden Breakpoint="Breakpoint.Xs">
|
|
<col/>
|
|
<col/>
|
|
<col/>
|
|
<col/>
|
|
<col style="width: 180px;"/>
|
|
</MudHidden>
|
|
</ColGroup>
|
|
<HeaderContent>
|
|
<MudTh>Name</MudTh>
|
|
<MudTh>Resolution</MudTh>
|
|
<MudTh>Video Format</MudTh>
|
|
<MudTh>Audio Format</MudTh>
|
|
<MudTh/>
|
|
</HeaderContent>
|
|
<RowTemplate>
|
|
<MudTd DataLabel="Name">@context.Name</MudTd>
|
|
<MudTd DataLabel="Resolution">@context.Resolution.Name</MudTd>
|
|
<MudTd DataLabel="Video Format">
|
|
@if (context.HardwareAcceleration != HardwareAccelerationKind.None)
|
|
{
|
|
@($"{context.VideoFormat.ToString().ToLowerInvariant()} / {context.HardwareAcceleration.ToString().ToLowerInvariant()}")
|
|
}
|
|
else
|
|
{
|
|
@context.VideoFormat.ToString().ToLowerInvariant()
|
|
}
|
|
</MudTd>
|
|
<MudTd DataLabel="Audio Format">@context.AudioFormat.ToString().ToLowerInvariant()</MudTd>
|
|
<MudTd>
|
|
<div style="align-items: center; display: flex;">
|
|
<MudTooltip Text="Edit Profile">
|
|
<MudIconButton Icon="@Icons.Material.Filled.Edit"
|
|
Href="@($"ffmpeg/{context.Id}")">
|
|
</MudIconButton>
|
|
</MudTooltip>
|
|
<MudTooltip Text="Copy Profile">
|
|
<MudIconButton Icon="@Icons.Material.Filled.ContentCopy"
|
|
OnClick="@(_ => CopyProfileAsync(context))">
|
|
</MudIconButton>
|
|
</MudTooltip>
|
|
<MudTooltip Text="Delete Profile">
|
|
<MudIconButton Icon="@Icons.Material.Filled.Delete"
|
|
OnClick="@(_ => DeleteProfileAsync(context))">
|
|
</MudIconButton>
|
|
</MudTooltip>
|
|
</div>
|
|
</MudTd>
|
|
</RowTemplate>
|
|
</MudTable>
|
|
</MudContainer>
|
|
</div>
|
|
</MudForm>
|
|
|
|
@code {
|
|
private CancellationTokenSource _cts;
|
|
|
|
private List<FFmpegProfileViewModel> _ffmpegProfiles = [];
|
|
|
|
public void Dispose()
|
|
{
|
|
_cts?.Cancel();
|
|
_cts?.Dispose();
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
_cts?.Cancel();
|
|
_cts?.Dispose();
|
|
_cts = new CancellationTokenSource();
|
|
var token = _cts.Token;
|
|
|
|
try
|
|
{
|
|
await LoadFFmpegProfilesAsync(token);
|
|
}
|
|
catch (OperationCanceledException)
|
|
{
|
|
// do nothing
|
|
}
|
|
}
|
|
|
|
private async Task LoadFFmpegProfilesAsync(CancellationToken cancellationToken) =>
|
|
_ffmpegProfiles = await Mediator.Send(new GetAllFFmpegProfiles(), cancellationToken);
|
|
|
|
private async Task DeleteProfileAsync(FFmpegProfileViewModel ffmpegProfile)
|
|
{
|
|
var parameters = new DialogParameters { { "EntityType", "ffmpeg profile" }, { "EntityName", ffmpegProfile.Name } };
|
|
var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall };
|
|
|
|
IDialogReference dialog = await Dialog.ShowAsync<DeleteDialog>("Delete FFmpeg Profile", parameters, options);
|
|
DialogResult result = await dialog.Result;
|
|
if (result is { Canceled: false })
|
|
{
|
|
Either<BaseError, Unit> deleteResult = await Mediator.Send(new DeleteFFmpegProfile(ffmpegProfile.Id), _cts.Token);
|
|
foreach (BaseError error in deleteResult.LeftToSeq())
|
|
{
|
|
Snackbar.Add(error.Value, Severity.Error);
|
|
}
|
|
|
|
if (deleteResult.IsRight)
|
|
{
|
|
await LoadFFmpegProfilesAsync(_cts.Token);
|
|
}
|
|
}
|
|
}
|
|
|
|
private async Task CopyProfileAsync(FFmpegProfileViewModel ffmpegProfile)
|
|
{
|
|
var parameters = new DialogParameters { { "FFmpegProfileId", ffmpegProfile.Id } };
|
|
var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall };
|
|
|
|
IDialogReference dialog = await Dialog.ShowAsync<CopyFFmpegProfileDialog>("Copy FFmpeg Profile", parameters, options);
|
|
DialogResult dialogResult = await dialog.Result;
|
|
if (dialogResult is { Canceled: false, Data: FFmpegProfileViewModel data })
|
|
{
|
|
NavigationManager.NavigateTo($"ffmpeg/{data.Id}");
|
|
}
|
|
}
|
|
|
|
}
|