|
|
|
@ -2,11 +2,18 @@ |
|
|
|
@using ErsatzTV.Application.Playouts |
|
|
|
@using ErsatzTV.Application.Playouts |
|
|
|
@using ErsatzTV.Application.Playouts.Commands |
|
|
|
@using ErsatzTV.Application.Playouts.Commands |
|
|
|
@using ErsatzTV.Application.Playouts.Queries |
|
|
|
@using ErsatzTV.Application.Playouts.Queries |
|
|
|
|
|
|
|
@using ErsatzTV.Application.Configuration.Commands |
|
|
|
|
|
|
|
@using ErsatzTV.Application.Configuration.Queries |
|
|
|
@inject IDialogService _dialog |
|
|
|
@inject IDialogService _dialog |
|
|
|
@inject IMediator _mediator |
|
|
|
@inject IMediator _mediator |
|
|
|
|
|
|
|
|
|
|
|
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="pt-8"> |
|
|
|
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="pt-8"> |
|
|
|
<MudTable Hover="true" Dense="true" Items="_playouts" SelectedItemChanged="@(async (PlayoutNameViewModel x) => await PlayoutSelected(x))"> |
|
|
|
<MudTable Hover="true" |
|
|
|
|
|
|
|
Dense="true" |
|
|
|
|
|
|
|
SelectedItemChanged="@(async (PlayoutNameViewModel x) => await PlayoutSelected(x))" |
|
|
|
|
|
|
|
@bind-RowsPerPage="@_rowsPerPage" |
|
|
|
|
|
|
|
ServerData="@(new Func<TableState, Task<TableData<PlayoutNameViewModel>>>(ServerReload))" |
|
|
|
|
|
|
|
@ref="_table"> |
|
|
|
<ToolBarContent> |
|
|
|
<ToolBarContent> |
|
|
|
<MudText Typo="Typo.h6">Playouts</MudText> |
|
|
|
<MudText Typo="Typo.h6">Playouts</MudText> |
|
|
|
</ToolBarContent> |
|
|
|
</ToolBarContent> |
|
|
|
@ -80,12 +87,16 @@ |
|
|
|
</MudContainer> |
|
|
|
</MudContainer> |
|
|
|
|
|
|
|
|
|
|
|
@code { |
|
|
|
@code { |
|
|
|
private List<PlayoutNameViewModel> _playouts; |
|
|
|
private MudTable<PlayoutNameViewModel> _table; |
|
|
|
|
|
|
|
private int _rowsPerPage; |
|
|
|
private List<PlayoutItemViewModel> _selectedPlayoutItems; |
|
|
|
private List<PlayoutItemViewModel> _selectedPlayoutItems; |
|
|
|
private int? _selectedPlayoutId; |
|
|
|
private int? _selectedPlayoutId; |
|
|
|
|
|
|
|
|
|
|
|
protected override Task OnParametersSetAsync() => |
|
|
|
protected override async Task OnParametersSetAsync() |
|
|
|
LoadAllPlayouts(); |
|
|
|
{ |
|
|
|
|
|
|
|
_rowsPerPage = await _mediator.Send(new GetConfigElementByKey(ConfigElementKey.PlayoutsPageSize)) |
|
|
|
|
|
|
|
.Map(maybeRows => maybeRows.Match(ce => int.TryParse(ce.Value, out int rows) ? rows : 10, () => 10)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async Task PlayoutSelected(PlayoutNameViewModel playout) |
|
|
|
private async Task PlayoutSelected(PlayoutNameViewModel playout) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -103,23 +114,33 @@ |
|
|
|
if (!result.Cancelled) |
|
|
|
if (!result.Cancelled) |
|
|
|
{ |
|
|
|
{ |
|
|
|
await _mediator.Send(new DeletePlayout(playout.PlayoutId)); |
|
|
|
await _mediator.Send(new DeletePlayout(playout.PlayoutId)); |
|
|
|
await LoadAllPlayouts(); |
|
|
|
await _table.ReloadServerData(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async Task RebuildPlayout(PlayoutNameViewModel playout) |
|
|
|
private async Task RebuildPlayout(PlayoutNameViewModel playout) |
|
|
|
{ |
|
|
|
{ |
|
|
|
await _mediator.Send(new BuildPlayout(playout.PlayoutId, true)); |
|
|
|
await _mediator.Send(new BuildPlayout(playout.PlayoutId, true)); |
|
|
|
await LoadAllPlayouts(); |
|
|
|
await _table.ReloadServerData(); |
|
|
|
if (_selectedPlayoutId == playout.PlayoutId) |
|
|
|
if (_selectedPlayoutId == playout.PlayoutId) |
|
|
|
{ |
|
|
|
{ |
|
|
|
await PlayoutSelected(playout); |
|
|
|
await PlayoutSelected(playout); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async Task LoadAllPlayouts() => |
|
|
|
private async Task<TableData<PlayoutNameViewModel>> ServerReload(TableState state) |
|
|
|
_playouts = await _mediator.Send(new GetAllPlayouts()) |
|
|
|
{ |
|
|
|
.Map(list => list.OrderBy(x => decimal.Parse(x.ChannelNumber)).ToList()); |
|
|
|
await _mediator.Send(new SaveConfigElementByKey(ConfigElementKey.PlayoutsPageSize, state.PageSize.ToString())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<PlayoutNameViewModel> playouts = await _mediator.Send(new GetAllPlayouts()); |
|
|
|
|
|
|
|
IOrderedEnumerable<PlayoutNameViewModel> sorted = playouts.OrderBy(p => decimal.Parse(p.ChannelNumber)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: properly page this data |
|
|
|
|
|
|
|
return new TableData<PlayoutNameViewModel> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
TotalItems = playouts.Count, |
|
|
|
|
|
|
|
Items = sorted.Skip(state.Page * state.PageSize).Take(state.PageSize) |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |