124 lines
5.0 KiB
Plaintext
124 lines
5.0 KiB
Plaintext
@page "/channels"
|
|
@using ErsatzTV.Application.Channels
|
|
@using ErsatzTV.Application.Channels.Commands
|
|
@using ErsatzTV.Application.Channels.Queries
|
|
@using ErsatzTV.Application.FFmpegProfiles
|
|
@using ErsatzTV.Application.FFmpegProfiles.Queries
|
|
@using System.Globalization
|
|
@inject IDialogService _dialog
|
|
@inject IMediator _mediator
|
|
|
|
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="pt-8">
|
|
<MudTable Hover="true" Items="_channels">
|
|
<ToolBarContent>
|
|
<MudText Typo="Typo.h6">Channels</MudText>
|
|
</ToolBarContent>
|
|
<ColGroup>
|
|
<col style="width: 60px;"/>
|
|
<col/>
|
|
<col style="width: 15%"/>
|
|
<col style="width: 15%"/>
|
|
<col style="width: 15%"/>
|
|
<col style="width: 15%"/>
|
|
<col style="width: 120px;"/>
|
|
</ColGroup>
|
|
<HeaderContent>
|
|
<MudTh>
|
|
<MudTableSortLabel InitialDirection="SortDirection.Ascending" SortBy="new Func<ChannelViewModel, object>(x => decimal.Parse(x.Number))">Number</MudTableSortLabel>
|
|
</MudTh>
|
|
<MudTh>Logo</MudTh>
|
|
<MudTh>
|
|
<MudTableSortLabel SortBy="new Func<ChannelViewModel, object>(x => x.Name)">Name</MudTableSortLabel>
|
|
</MudTh>
|
|
<MudTh>Language</MudTh>
|
|
<MudTh>Mode</MudTh>
|
|
<MudTh>FFmpeg Profile</MudTh>
|
|
<MudTh/>
|
|
</HeaderContent>
|
|
<RowTemplate>
|
|
<MudTd DataLabel="Number">@context.Number</MudTd>
|
|
<MudTd DataLabel="Logo">
|
|
@if (!string.IsNullOrWhiteSpace(context.Logo))
|
|
{
|
|
<MudElement HtmlTag="img" src="@($"iptv/logos/{context.Logo}")" Style="max-height: 50px"/>
|
|
}
|
|
</MudTd>
|
|
<MudTd DataLabel="Name">@context.Name</MudTd>
|
|
<MudTd DataLabel="Language">@context.PreferredLanguageCode</MudTd>
|
|
<MudTd DataLabel="Mode">@(context.StreamingMode == StreamingMode.TransportStream ? "TS" : "HLS")</MudTd>
|
|
<MudTd DataLabel="FFmpeg Profile">
|
|
@if (context.StreamingMode == StreamingMode.TransportStream)
|
|
{
|
|
@_ffmpegProfiles.Find(p => p.Id == context.FFmpegProfileId)?.Name
|
|
}
|
|
</MudTd>
|
|
<MudTd>
|
|
<div style="align-items: center; display: flex;">
|
|
<MudTooltip Text="Edit Channel">
|
|
<MudIconButton Icon="@Icons.Material.Filled.Edit"
|
|
Link="@($"/channels/{context.Id}")">
|
|
</MudIconButton>
|
|
</MudTooltip>
|
|
<MudTooltip Text="Delete Channel">
|
|
<MudIconButton Icon="@Icons.Material.Filled.Delete"
|
|
OnClick="@(_ => DeleteChannelAsync(context))">
|
|
</MudIconButton>
|
|
</MudTooltip>
|
|
</div>
|
|
</MudTd>
|
|
</RowTemplate>
|
|
<PagerContent>
|
|
<MudTablePager/>
|
|
</PagerContent>
|
|
</MudTable>
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" Link="/channels/add" Class="mt-4">
|
|
Add Channel
|
|
</MudButton>
|
|
</MudContainer>
|
|
|
|
@code {
|
|
private List<ChannelViewModel> _channels;
|
|
private List<FFmpegProfileViewModel> _ffmpegProfiles;
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
_ffmpegProfiles = await _mediator.Send(new GetAllFFmpegProfiles());
|
|
await LoadChannelsAsync();
|
|
}
|
|
|
|
private async Task DeleteChannelAsync(ChannelViewModel channel)
|
|
{
|
|
var parameters = new DialogParameters { { "EntityType", "channel" }, { "EntityName", channel.Name } };
|
|
var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall };
|
|
|
|
IDialogReference dialog = _dialog.Show<DeleteDialog>("Delete Channel", parameters, options);
|
|
DialogResult result = await dialog.Result;
|
|
if (!result.Cancelled)
|
|
{
|
|
await _mediator.Send(new DeleteChannel(channel.Id));
|
|
await LoadChannelsAsync();
|
|
}
|
|
}
|
|
|
|
private async Task LoadChannelsAsync()
|
|
{
|
|
List<ChannelViewModel> channels = await _mediator.Send(new GetAllChannels());
|
|
IOrderedEnumerable<ChannelViewModel> sorted = channels.OrderBy(c => decimal.Parse(c.Number));
|
|
|
|
CultureInfo[] allCultures = CultureInfo.GetCultures(CultureTypes.NeutralCultures);
|
|
_channels = new List<ChannelViewModel>();
|
|
foreach (ChannelViewModel channel in sorted)
|
|
{
|
|
Option<CultureInfo> maybeCultureInfo = allCultures.Find(
|
|
ci => string.Equals(
|
|
ci.ThreeLetterISOLanguageName,
|
|
channel.PreferredLanguageCode,
|
|
StringComparison.OrdinalIgnoreCase));
|
|
|
|
maybeCultureInfo.Match(
|
|
cultureInfo => _channels.Add(channel with { PreferredLanguageCode = cultureInfo.EnglishName }),
|
|
() => _channels.Add(channel));
|
|
}
|
|
}
|
|
|
|
} |