From ce228604e8a6140bc4191e9f785c60a40aa2a3f8 Mon Sep 17 00:00:00 2001 From: Jason Dove Date: Mon, 6 Dec 2021 12:49:48 -0600 Subject: [PATCH] use select controls instead of autocomplete (#532) * use select instead of autocomplete for playout editor * use select instead of autocomplete for filler preset editor * reset selected collection when changing collection type * use select instead of autocomplete for multi collection editor * more select * more select controls --- CHANGELOG.md | 2 + .../Channels/ChannelViewModel.cs | 3 +- ErsatzTV.Application/Channels/Mapper.cs | 3 +- .../Data/Repositories/ChannelRepository.cs | 4 +- ErsatzTV/Pages/FillerPresetEditor.razor | 108 +++++----- ErsatzTV/Pages/MultiCollectionEditor.razor | 57 ++--- ErsatzTV/Pages/PlayoutEditor.razor | 29 ++- ErsatzTV/Pages/ScheduleItemsEditor.razor | 200 +++++++++--------- .../ViewModels/FillerPresetEditViewModel.cs | 20 +- 9 files changed, 239 insertions(+), 187 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3b4e9e01..3e62c24e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed - Use blurhash of ErsatzTV colors instead of solid colors for default song backgrounds +- Use select control instead of autocomplete control in many places + - The autocomplete control is not intuitive to use and has focus bugs ## [0.3.2-alpha] - 2021-12-03 ### Fixed diff --git a/ErsatzTV.Application/Channels/ChannelViewModel.cs b/ErsatzTV.Application/Channels/ChannelViewModel.cs index cd8728743..8bdb3acbb 100644 --- a/ErsatzTV.Application/Channels/ChannelViewModel.cs +++ b/ErsatzTV.Application/Channels/ChannelViewModel.cs @@ -11,5 +11,6 @@ namespace ErsatzTV.Application.Channels string PreferredLanguageCode, StreamingMode StreamingMode, int? WatermarkId, - int? FallbackFillerId); + int? FallbackFillerId, + int PlayoutCount); } diff --git a/ErsatzTV.Application/Channels/Mapper.cs b/ErsatzTV.Application/Channels/Mapper.cs index d54326955..78ec73c12 100644 --- a/ErsatzTV.Application/Channels/Mapper.cs +++ b/ErsatzTV.Application/Channels/Mapper.cs @@ -16,7 +16,8 @@ namespace ErsatzTV.Application.Channels channel.PreferredLanguageCode, channel.StreamingMode, channel.WatermarkId, - channel.FallbackFillerId); + channel.FallbackFillerId, + channel.Playouts?.Count ?? 0); private static string GetLogo(Channel channel) => Optional(channel.Artwork.FirstOrDefault(a => a.ArtworkKind == ArtworkKind.Logo)) diff --git a/ErsatzTV.Infrastructure/Data/Repositories/ChannelRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/ChannelRepository.cs index 5bc728bf0..cd1495918 100644 --- a/ErsatzTV.Infrastructure/Data/Repositories/ChannelRepository.cs +++ b/ErsatzTV.Infrastructure/Data/Repositories/ChannelRepository.cs @@ -7,6 +7,7 @@ using LanguageExt; using Microsoft.EntityFrameworkCore; using static LanguageExt.Prelude; + namespace ErsatzTV.Infrastructure.Data.Repositories { public class ChannelRepository : IChannelRepository @@ -42,10 +43,11 @@ namespace ErsatzTV.Infrastructure.Data.Repositories public async Task> GetAll() { - await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(); return await dbContext.Channels .Include(c => c.FFmpegProfile) .Include(c => c.Artwork) + .Include(c => c.Playouts) .ToListAsync(); } diff --git a/ErsatzTV/Pages/FillerPresetEditor.razor b/ErsatzTV/Pages/FillerPresetEditor.razor index f577598f6..2176a9abc 100644 --- a/ErsatzTV/Pages/FillerPresetEditor.razor +++ b/ErsatzTV/Pages/FillerPresetEditor.razor @@ -52,57 +52,75 @@ @if (_model.CollectionType == ProgramScheduleItemCollectionType.Collection) { - + + @foreach (MediaCollectionViewModel collection in _mediaCollections) + { + @collection.Name + } + } @if (_model.CollectionType == ProgramScheduleItemCollectionType.MultiCollection) { - + + @foreach (MultiCollectionViewModel collection in _multiCollections) + { + @collection.Name + } + } @if (_model.CollectionType == ProgramScheduleItemCollectionType.SmartCollection) { - + + @foreach (SmartCollectionViewModel collection in _smartCollections) + { + @collection.Name + } + } @if (_model.CollectionType == ProgramScheduleItemCollectionType.TelevisionShow) { - + + @foreach (NamedMediaItemViewModel show in _televisionShows) + { + @show.Name + } + } @if (_model.CollectionType == ProgramScheduleItemCollectionType.TelevisionSeason) { - + + @foreach (NamedMediaItemViewModel season in _televisionSeasons) + { + @season.Name + } + } @if (_model.CollectionType == ProgramScheduleItemCollectionType.Artist) { - + + @foreach (NamedMediaItemViewModel artist in _artists) + { + @artist.Name + } + } @@ -206,22 +224,4 @@ () => _navigationManager.NavigateTo("/media/filler/presets")); } } - - private Task> SearchMediaCollections(string value) => - _mediaCollections.Filter(c => c.Name.Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); - - private Task> SearchMultiCollections(string value) => - _multiCollections.Filter(c => c.Name.Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); - - private Task> SearchSmartCollections(string value) => - _smartCollections.Filter(c => c.Name.Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); - - private Task> SearchTelevisionShows(string value) => - _televisionShows.Filter(s => s.Name.Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); - - private Task> SearchTelevisionSeasons(string value) => - _televisionSeasons.Filter(s => s.Name.Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); - - private Task> SearchArtists(string value) => - _artists.Filter(s => s.Name.Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); } \ No newline at end of file diff --git a/ErsatzTV/Pages/MultiCollectionEditor.razor b/ErsatzTV/Pages/MultiCollectionEditor.razor index be3d10ccf..866b0e019 100644 --- a/ErsatzTV/Pages/MultiCollectionEditor.razor +++ b/ErsatzTV/Pages/MultiCollectionEditor.razor @@ -17,23 +17,37 @@ - + + @foreach (MediaCollectionViewModel collection in _collections) + { + + @collection.Name + + } + Add Collection - + + @foreach (SmartCollectionViewModel collection in _smartCollections) + { + + @collection.Name + + } + Add Smart Collection @@ -100,8 +114,8 @@ private List _smartCollections; private MediaCollectionViewModel _selectedCollection; private SmartCollectionViewModel _selectedSmartCollection; - private MudAutocomplete _collectionAutocomplete; - private MudAutocomplete _smartCollectionAutocomplete; + private MudSelect _collectionSelect; + private MudSelect _smartCollectionSelect; protected override async Task OnParametersSetAsync() { @@ -211,7 +225,7 @@ }); _selectedCollection = null; - _collectionAutocomplete.Reset(); + _collectionSelect.Reset(); } } @@ -226,14 +240,7 @@ }); _selectedSmartCollection = null; - _smartCollectionAutocomplete.Reset(); + _smartCollectionSelect.Reset(); } } - - private Task> SearchCollections(string value) => - _collections.Filter(c => _model.Items.All(i => i.Collection != c) && c.Name.Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); - - private Task> SearchSmartCollections(string value) => - _smartCollections.Filter(c => _model.Items.OfType().All(i => i.SmartCollection != c) && c.Name.Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); - } \ No newline at end of file diff --git a/ErsatzTV/Pages/PlayoutEditor.razor b/ErsatzTV/Pages/PlayoutEditor.razor index cc57f0885..d6e0f3a16 100644 --- a/ErsatzTV/Pages/PlayoutEditor.razor +++ b/ErsatzTV/Pages/PlayoutEditor.razor @@ -16,8 +16,26 @@ - - + + @foreach (ChannelViewModel channel in _channels) + { + + @($"{channel.Number} - {channel.Name}") + + } + + + @foreach (ProgramScheduleViewModel schedule in _programSchedules) + { + @schedule.Name + } + @@ -52,13 +70,6 @@ _messageStore = new ValidationMessageStore(_editContext); } - private Task> SearchChannels(string value) => - _channels.Filter(c => $"{c.Number} - {c.Name}".Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); - - private Task> SearchProgramSchedules(string value) => - _programSchedules.Filter(c => c.Name.Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); - - private async Task HandleSubmitAsync() { _messageStore.Clear(); diff --git a/ErsatzTV/Pages/ScheduleItemsEditor.razor b/ErsatzTV/Pages/ScheduleItemsEditor.razor index 467ab81ca..1d1602bc8 100644 --- a/ErsatzTV/Pages/ScheduleItemsEditor.razor +++ b/ErsatzTV/Pages/ScheduleItemsEditor.razor @@ -105,57 +105,75 @@ @if (_selectedItem.CollectionType == ProgramScheduleItemCollectionType.Collection) { - + + @foreach (MediaCollectionViewModel collection in _mediaCollections) + { + @collection.Name + } + } @if (_selectedItem.CollectionType == ProgramScheduleItemCollectionType.MultiCollection) { - + + @foreach (MultiCollectionViewModel collection in _multiCollections) + { + @collection.Name + } + } @if (_selectedItem.CollectionType == ProgramScheduleItemCollectionType.SmartCollection) { - + + @foreach (SmartCollectionViewModel collection in _smartCollections) + { + @collection.Name + } + } @if (_selectedItem.CollectionType == ProgramScheduleItemCollectionType.TelevisionShow) { - + + @foreach (NamedMediaItemViewModel show in _televisionShows) + { + @show.Name + } + } @if (_selectedItem.CollectionType == ProgramScheduleItemCollectionType.TelevisionSeason) { - + + @foreach (NamedMediaItemViewModel season in _televisionSeasons) + { + @season.Name + } + } @if (_selectedItem.CollectionType == ProgramScheduleItemCollectionType.Artist) { - + + @foreach (NamedMediaItemViewModel artist in _artists) + { + @artist.Name + } + } @switch (_selectedItem.CollectionType) @@ -202,47 +220,57 @@
- - - - - - + + @foreach (FillerPresetViewModel filler in _fillerPresets.Where(f => f.FillerKind == FillerKind.PreRoll)) + { + @filler.Name + } + + + @foreach (FillerPresetViewModel filler in _fillerPresets.Where(f => f.FillerKind == FillerKind.MidRoll)) + { + @filler.Name + } + + + @foreach (FillerPresetViewModel filler in _fillerPresets.Where(f => f.FillerKind == FillerKind.PostRoll)) + { + @filler.Name + } + + + @foreach (FillerPresetViewModel filler in _fillerPresets.Where(f => f.FillerKind == FillerKind.Tail)) + { + @filler.Name + } + + + @foreach (FillerPresetViewModel filler in _fillerPresets.Where(f => f.FillerKind == FillerKind.Fallback)) + { + @filler.Name + } + +
@@ -379,24 +407,6 @@ (toSwap.Index, item.Index) = (item.Index, toSwap.Index); } - private Task> SearchMediaCollections(string value) => - _mediaCollections.Filter(c => c.Name.Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); - - private Task> SearchMultiCollections(string value) => - _multiCollections.Filter(c => c.Name.Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); - - private Task> SearchSmartCollections(string value) => - _smartCollections.Filter(c => c.Name.Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); - - private Task> SearchTelevisionShows(string value) => - _televisionShows.Filter(s => s.Name.Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); - - private Task> SearchTelevisionSeasons(string value) => - _televisionSeasons.Filter(s => s.Name.Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); - - private Task> SearchArtists(string value) => - _artists.Filter(s => s.Name.Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); - private Task> SearchFillerPresets(FillerKind fillerKind, string value) => _fillerPresets.Filter(p => p.FillerKind == fillerKind && p.Name.Contains(value ?? string.Empty, StringComparison.OrdinalIgnoreCase)).AsTask(); diff --git a/ErsatzTV/ViewModels/FillerPresetEditViewModel.cs b/ErsatzTV/ViewModels/FillerPresetEditViewModel.cs index acdad1b72..5aaab4db0 100644 --- a/ErsatzTV/ViewModels/FillerPresetEditViewModel.cs +++ b/ErsatzTV/ViewModels/FillerPresetEditViewModel.cs @@ -17,6 +17,7 @@ namespace ErsatzTV.ViewModels private TimeSpan? _duration; private FillerMode _fillerMode; private int? _count; + private ProgramScheduleItemCollectionType _collectionType; public int Id { get; set; } public string Name { get; set; } @@ -53,7 +54,24 @@ namespace ErsatzTV.ViewModels } public int? PadToNearestMinute { get; set; } - public ProgramScheduleItemCollectionType CollectionType { get; set; } + + public ProgramScheduleItemCollectionType CollectionType + { + get => _collectionType; + set + { + if (_collectionType != value) + { + Collection = null; + MediaItem = null; + MultiCollection = null; + SmartCollection = null; + } + + _collectionType = value; + } + } + public MediaCollectionViewModel Collection { get; set; } public NamedMediaItemViewModel MediaItem { get; set; } public MultiCollectionViewModel MultiCollection { get; set; }