Files
ersatztv/ErsatzTV/Shared/SchedulePlayoutReset.razor
T
Jason DoveandGitHub 5d081ceeff fix editorconfig and run code cleanup (#2324)
* fix formatting rules

* reformat ersatztv

* reformat ersatztv.application

* reformat ersatztv.core

* refactor ersatztv.core.tests

* reformat ersatztv.ffmpeg

* reformat ersatztv.ffmpeg.tests

* reformat ersatztv.infrastructure

* cleanup infra mysql

* cleanup infra sqlite

* cleanup infra tests

* cleanup ersatztv.scanner

* cleanup ersatztv.scanner.tests

* sln cleanup

* update dependencies
2025-08-16 14:44:48 +00:00

85 lines
2.7 KiB
Plaintext

@using ErsatzTV.Application.Playouts
@implements IDisposable
@inject IMediator Mediator
@inject ISnackbar Snackbar
@inject ILogger<SchedulePlayoutReset> Logger
<MudDialog>
<DialogContent>
<EditForm Model="@_dummyModel" OnSubmit="@(_ => Submit())">
<MudContainer Class="mb-6">
<MudText>
@FormatText()
</MudText>
</MudContainer>
<MudSelect Class="mb-6 mx-4" Label="Daily Reset Time" @bind-Value="_resetTime">
<MudSelectItem Value="@(Option<TimeSpan>.None)">Do not automatically reset</MudSelectItem>
@for (var i = 1; i < 48; i++)
{
var time = TimeSpan.FromHours(i * 0.5);
string formatted = DateTime.Today.Add(time).ToShortTimeString();
<MudSelectItem Value="@(Option<TimeSpan>.Some(time))">@formatted</MudSelectItem>
}
</MudSelect>
</EditForm>
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel" ButtonType="ButtonType.Reset">Cancel</MudButton>
<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="Submit">
Save Changes
</MudButton>
</DialogActions>
</MudDialog>
@code {
private readonly CancellationTokenSource _cts = new();
[CascadingParameter]
IMudDialogInstance MudDialog { get; set; }
[Parameter]
public int PlayoutId { get; set; }
[Parameter]
public string ChannelName { get; set; }
[Parameter]
public string ScheduleName { get; set; }
[Parameter]
public Option<TimeSpan> DailyResetTime { get; set; }
private string FormatText() => $"Enter the time that the playout on channel {ChannelName} with schedule {ScheduleName} should reset every day";
private record DummyModel;
private readonly DummyModel _dummyModel = new();
private Option<TimeSpan> _resetTime;
public void Dispose()
{
_cts.Cancel();
_cts.Dispose();
}
protected override void OnParametersSet() => _resetTime = DailyResetTime;
private async Task Submit()
{
Either<BaseError, PlayoutNameViewModel> maybeResult =
await Mediator.Send(new UpdatePlayout(PlayoutId, _resetTime), _cts.Token);
maybeResult.Match(
playout => { MudDialog.Close(DialogResult.Ok(playout)); },
error =>
{
Snackbar.Add(error.Value, Severity.Error);
Logger.LogError("Error updating Playout: {Error}", error.Value);
MudDialog.Close(DialogResult.Cancel());
});
}
private void Cancel(MouseEventArgs e) => MudDialog.Cancel();
}