* add chapter statistics and new filler options * refactor playout builder * more refactor prep for filler * rewrite schedulers * refactor collectionkey * add tail filler kind * migrate tail filler to filler preset * optionally show filler * fix playout detail row count * remove duration tail filler options * implement tail and fallback in flood scheduler * implement tail and fallback in one scheduler * implement tail and fallback in multiple scheduler * implement looping fallback filler * more duration tests * start to add post-roll filler to flood * rework playoutitem filler tagging * rework scheduler logging * calculate whether configured filler will fit * implement pre-roll and post-roll duration and count filler * improve duration filler calculation * add minutes to search index * update channel guide to work with new filler * add mid-roll filler * don't clone enumerators for filler calculations * support pre-roll and post-roll pad filler * implement mid-roll pad filler * allow clearing filler selections in schedule editor * fix tests * filler config validation * use consistent time zone for tests
95 lines
2.9 KiB
C#
95 lines
2.9 KiB
C#
using System;
|
|
using ErsatzTV.Application.Filler.Commands;
|
|
using ErsatzTV.Application.MediaCollections;
|
|
using ErsatzTV.Application.MediaItems;
|
|
using ErsatzTV.Core;
|
|
using ErsatzTV.Core.Domain;
|
|
using ErsatzTV.Core.Domain.Filler;
|
|
using LanguageExt;
|
|
using MediatR;
|
|
using Unit = LanguageExt.Unit;
|
|
|
|
namespace ErsatzTV.ViewModels
|
|
{
|
|
public class FillerPresetEditViewModel
|
|
{
|
|
private FillerKind _fillerKind;
|
|
private TimeSpan? _duration;
|
|
private FillerMode _fillerMode;
|
|
private int? _count;
|
|
|
|
public int Id { get; set; }
|
|
public string Name { get; set; }
|
|
|
|
public FillerKind FillerKind
|
|
{
|
|
get => _fillerKind;
|
|
set
|
|
{
|
|
_fillerKind = value;
|
|
if (_fillerKind is FillerKind.Fallback or FillerKind.Tail)
|
|
{
|
|
FillerMode = FillerMode.None;
|
|
}
|
|
}
|
|
}
|
|
|
|
public FillerMode FillerMode
|
|
{
|
|
get => FillerKind is FillerKind.Fallback or FillerKind.Tail ? FillerMode.None : _fillerMode;
|
|
set => _fillerMode = value;
|
|
}
|
|
|
|
public TimeSpan? Duration
|
|
{
|
|
get => FillerMode == FillerMode.Duration ? _duration : null;
|
|
set => _duration = value;
|
|
}
|
|
|
|
public int? Count
|
|
{
|
|
get => FillerMode == FillerMode.Count ? _count : null;
|
|
set => _count = value;
|
|
}
|
|
|
|
public int? PadToNearestMinute { get; set; }
|
|
public ProgramScheduleItemCollectionType CollectionType { get; set; }
|
|
public MediaCollectionViewModel Collection { get; set; }
|
|
public NamedMediaItemViewModel MediaItem { get; set; }
|
|
public MultiCollectionViewModel MultiCollection { get; set; }
|
|
public SmartCollectionViewModel SmartCollection { get; set; }
|
|
|
|
public IRequest<Either<BaseError, Unit>> ToEdit() =>
|
|
new UpdateFillerPreset(
|
|
Id,
|
|
Name,
|
|
FillerKind,
|
|
FillerMode,
|
|
Duration.Map(FixDuration),
|
|
Count,
|
|
PadToNearestMinute,
|
|
CollectionType,
|
|
Collection?.Id,
|
|
MediaItem?.MediaItemId,
|
|
MultiCollection?.Id,
|
|
SmartCollection?.Id);
|
|
|
|
public IRequest<Either<BaseError, Unit>> ToUpdate() =>
|
|
new CreateFillerPreset(
|
|
Name,
|
|
FillerKind,
|
|
FillerMode,
|
|
Duration.Map(FixDuration),
|
|
Count,
|
|
PadToNearestMinute,
|
|
CollectionType,
|
|
Collection?.Id,
|
|
MediaItem?.MediaItemId,
|
|
MultiCollection?.Id,
|
|
SmartCollection?.Id);
|
|
|
|
private static TimeSpan FixDuration(TimeSpan duration) =>
|
|
duration > TimeSpan.FromDays(1) ? duration.Subtract(TimeSpan.FromDays(1)) : duration;
|
|
}
|
|
}
|