Browse Source

add disabled and hidden channel indicators (#2649)

pull/2650/head
Jason Dove 2 months ago committed by GitHub
parent
commit
5c51710e2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      CHANGELOG.md
  2. 2
      ErsatzTV.Application/Channels/Queries/GetAllChannels.cs
  3. 3
      ErsatzTV.Application/Channels/Queries/GetAllChannelsHandler.cs
  4. 1
      ErsatzTV.Core/Domain/ConfigElementKey.cs
  5. 55
      ErsatzTV/Pages/Channels.razor
  6. 4
      ErsatzTV/wwwroot/css/site.css

4
CHANGELOG.md

@ -80,9 +80,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -80,9 +80,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- This bug caused some graphics elements to display too early after first joining a channel
- Optimize database calls made for search index rebuilds and updates
- This should improve performance of library scans
- Add toggle to hide/show disabled channels in channel list
- Add disabled text color and `(D)` and `(H)` labels for disabled and hidden channels in channel list
### Changed
- Classic playouts: `Refresh` classic playouts from playout list; do not `Reset` them
- Classic schedules: `Refresh` classic playouts from playout list; do not `Reset` them
- This mode maintains progress; progress can be reset by editing the playout and clicking `Erase Items and History`
- Use smaller batch size for search index updates (100, down from 1000)
- This should help newly scanned items appear in the UI more quickly

2
ErsatzTV.Application/Channels/Queries/GetAllChannels.cs

@ -1,3 +1,3 @@ @@ -1,3 +1,3 @@
namespace ErsatzTV.Application.Channels;
public record GetAllChannels : IRequest<List<ChannelViewModel>>;
public record GetAllChannels(bool ShowDisabled = true) : IRequest<List<ChannelViewModel>>;

3
ErsatzTV.Application/Channels/Queries/GetAllChannelsHandler.cs

@ -9,7 +9,8 @@ public class GetAllChannelsHandler(IChannelRepository channelRepository) @@ -9,7 +9,8 @@ public class GetAllChannelsHandler(IChannelRepository channelRepository)
{
public async Task<List<ChannelViewModel>> Handle(GetAllChannels request, CancellationToken cancellationToken) =>
await channelRepository.GetAll(cancellationToken)
.Map(list => list.Map(c => ProjectToViewModel(c, GetPlayoutsCount(c))).ToList());
.Map(list => list.Where(c => c.IsEnabled || request.ShowDisabled)
.Map(c => ProjectToViewModel(c, GetPlayoutsCount(c))).ToList());
private static int GetPlayoutsCount(Channel channel)
{

1
ErsatzTV.Core/Domain/ConfigElementKey.cs

@ -33,6 +33,7 @@ public class ConfigElementKey @@ -33,6 +33,7 @@ public class ConfigElementKey
public static ConfigElementKey HDHRUUID => new("hdhr.uuid");
public static ConfigElementKey PagesIsDarkMode => new("pages.is_dark_mode");
public static ConfigElementKey ChannelsPageSize => new("pages.channels.page_size");
public static ConfigElementKey ChannelsShowDisabled => new("pages.channels.show_disabled");
public static ConfigElementKey CollectionsPageSize => new("pages.collections.page_size");
public static ConfigElementKey MultiCollectionsPageSize => new("pages.multi_collections.page_size");
public static ConfigElementKey SmartCollectionsPageSize => new("pages.smart_collections.page_size");

55
ErsatzTV/Pages/Channels.razor

@ -27,7 +27,11 @@ @@ -27,7 +27,11 @@
<MudTable Hover="true"
@bind-RowsPerPage="@_rowsPerPage"
ServerData="@(new Func<TableState, CancellationToken, Task<TableData<ChannelViewModel>>>(ServerReload))"
@ref="_table">
@ref="_table"
RowClassFunc="ChannelRowClassFunc">
<ToolBarContent>
<MudSwitch T="bool" Class="ml-6" @bind-Value="@ShowDisabled" Color="Color.Secondary" Label="Show Disabled"/>
</ToolBarContent>
<ColGroup>
<MudHidden Breakpoint="Breakpoint.Xs">
<col style="width: 60px;"/>
@ -53,7 +57,24 @@ @@ -53,7 +57,24 @@
<MudTh/>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="Number">@context.Number</MudTd>
<MudTd DataLabel="Number">
@if (!context.IsEnabled)
{
<MudTooltip Text="Channel is disabled">
@($"(D) {context.Number}")
</MudTooltip>
}
else if (!context.ShowInEpg)
{
<MudTooltip Text="Channel is hidden from EPG">
@($"(H) {context.Number}")
</MudTooltip>
}
else
{
@context.Number
}
</MudTd>
<MudTd DataLabel="Logo">
@if (!string.IsNullOrWhiteSpace(context.Logo?.Path))
{
@ -110,14 +131,14 @@ @@ -110,14 +131,14 @@
}
else
{
<div style="width: 48px"></div>
<div style="width: 48px"></div>
}
<MudTooltip Text="Edit Channel">
<MudIconButton Icon="@Icons.Material.Filled.Edit"
Href="@($"channels/{context.Id}")">
</MudIconButton>
</MudTooltip>
@if (context.PlayoutCount > 0)
@if (context.PlayoutCount > 0 && context.IsEnabled)
{
<MudTooltip Text="Troubleshoot Channel">
<MudIconButton Icon="@Icons.Material.Filled.Troubleshoot"
@ -152,9 +173,22 @@ @@ -152,9 +173,22 @@
private List<FFmpegProfileViewModel> _ffmpegProfiles = [];
private readonly System.Collections.Generic.HashSet<int> _channelsThatCanPreview = [];
private readonly Dictionary<int, bool> _ffmpegProfilesThatCanPreview = [];
private bool _showDisabled;
private int _rowsPerPage = 10;
private bool ShowDisabled
{
get => _showDisabled;
set
{
if (_showDisabled != value)
{
_showDisabled = value;
_table?.ReloadServerData();
}
}
}
protected override void OnInitialized() => SegmenterService.OnWorkersChanged += WorkersChanged;
private void WorkersChanged(object sender, EventArgs e) =>
@ -181,6 +215,8 @@ @@ -181,6 +215,8 @@
token.ThrowIfCancellationRequested();
_rowsPerPage = await Mediator.Send(new GetConfigElementByKey(ConfigElementKey.ChannelsPageSize), token)
.Map(maybeRows => maybeRows.Match(ce => int.TryParse(ce.Value, out int rows) ? rows : 10, () => 10));
_showDisabled = await Mediator.Send(new GetConfigElementByKey(ConfigElementKey.ChannelsShowDisabled), token)
.Map(maybeShow => maybeShow.Match(ce => bool.TryParse(ce.Value, out bool show) && show, () => false));
}
catch (OperationCanceledException)
{
@ -292,9 +328,11 @@ @@ -292,9 +328,11 @@
private async Task<TableData<ChannelViewModel>> ServerReload(TableState state, CancellationToken cancellationToken)
{
await Mediator.Send(new SaveConfigElementByKey(ConfigElementKey.ChannelsPageSize, state.PageSize.ToString()), cancellationToken);
await Mediator.Send(new SaveConfigElementByKey(ConfigElementKey.ChannelsShowDisabled, _showDisabled.ToString()), cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
List<ChannelViewModel> channels = await Mediator.Send(new GetAllChannels(), cancellationToken);
List<ChannelViewModel> channels = await Mediator.Send(new GetAllChannels(_showDisabled), cancellationToken);
// TODO: properly page this data
IOrderedEnumerable<ChannelViewModel> sorted = channels.OrderBy(c => decimal.Parse(c.Number, CultureInfo.InvariantCulture))
.Skip(state.Page * state.PageSize)
@ -348,4 +386,9 @@ @@ -348,4 +386,9 @@
return await JsRuntime.InvokeAsync<bool>("mediaSourceSupports", codecString);
}
private string ChannelRowClassFunc(ChannelViewModel channel, int index)
{
return channel.IsEnabled && channel.ShowInEpg ? string.Empty : "channel-disabled";
}
}

4
ErsatzTV/wwwroot/css/site.css

@ -226,3 +226,7 @@ div.ersatztv-light { @@ -226,3 +226,7 @@ div.ersatztv-light {
.playout-filler-unscheduled {
background-color: #52040d;
}
.channel-disabled .mud-table-cell {
color: var(--mud-palette-text-disabled) !important;
}

Loading…
Cancel
Save