add scheduled playout rebuild (#376)
* configure scheduled playout rebuild * implement scheduled playout rebuild * remove variable
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
@using System.Globalization
|
||||
@using ErsatzTV.Application.Playouts
|
||||
@using ErsatzTV.Application.Playouts.Commands
|
||||
@inject IMediator _mediator
|
||||
@inject ISnackbar _snackbar
|
||||
@inject ILogger<SchedulePlayoutRebuild> _logger
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<EditForm Model="@_dummyModel" OnSubmit="@(_ => Submit())">
|
||||
<MudContainer Class="mb-6">
|
||||
<MudText>
|
||||
@FormatText()
|
||||
</MudText>
|
||||
</MudContainer>
|
||||
<MudSelect Class="mb-6 mx-4" Label="Daily Rebuild Time" @bind-Value="_rebuildTime">
|
||||
<MudSelectItem Value="@(Option<TimeSpan>.None)">Do not automatically rebuild</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 {
|
||||
|
||||
[CascadingParameter]
|
||||
MudDialogInstance 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> DailyRebuildTime { get; set; }
|
||||
|
||||
private string FormatText() => $"Enter the time that the playout on channel {ChannelName} with schedule {ScheduleName} should rebuild every day";
|
||||
|
||||
private record DummyModel;
|
||||
|
||||
private readonly DummyModel _dummyModel = new();
|
||||
|
||||
private Option<TimeSpan> _rebuildTime;
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
_rebuildTime = DailyRebuildTime;
|
||||
}
|
||||
|
||||
private async Task Submit()
|
||||
{
|
||||
Either<BaseError, PlayoutNameViewModel> maybeResult =
|
||||
await _mediator.Send(new UpdatePlayout(PlayoutId, _rebuildTime));
|
||||
|
||||
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();
|
||||
}
|
||||
Reference in New Issue
Block a user