* add paging to playouts * add sorting, paging to schedules * fix channels sorting; add channels paging
115 lines
4.6 KiB
Plaintext
115 lines
4.6 KiB
Plaintext
@page "/schedules"
|
|
@using ErsatzTV.Application.ProgramSchedules
|
|
@using ErsatzTV.Application.ProgramSchedules.Commands
|
|
@using ErsatzTV.Application.ProgramSchedules.Queries
|
|
@inject IDialogService Dialog
|
|
@inject IMediator Mediator
|
|
|
|
<MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="pt-8">
|
|
<MudTable Hover="true" Items="_schedules" Dense="true" SelectedItemChanged="@(async (ProgramScheduleViewModel x) => await ScheduleSelected(x))">
|
|
<ToolBarContent>
|
|
<MudText Typo="Typo.h6">Schedules</MudText>
|
|
</ToolBarContent>
|
|
<ColGroup>
|
|
<col/>
|
|
<col/>
|
|
<col style="width: 180px;"/>
|
|
</ColGroup>
|
|
<HeaderContent>
|
|
<MudTh>
|
|
<MudTableSortLabel SortBy="new Func<ProgramScheduleViewModel, object>(x => x.Name)">
|
|
Name
|
|
</MudTableSortLabel>
|
|
</MudTh>
|
|
<MudTh>Collection Playback Order</MudTh>
|
|
<MudTh/>
|
|
</HeaderContent>
|
|
<RowTemplate>
|
|
<MudTd DataLabel="Name">@context.Name</MudTd>
|
|
<MudTd DataLabel="Name">@context.MediaCollectionPlaybackOrder</MudTd>
|
|
<MudTd>
|
|
<div style="align-items: center; display: flex;">
|
|
<MudTooltip Text="Edit Properties">
|
|
<MudIconButton Icon="@Icons.Material.Filled.Edit"
|
|
Link="@($"/schedules/{context.Id}")">
|
|
</MudIconButton>
|
|
</MudTooltip>
|
|
<MudTooltip Text="Edit Schedule Items">
|
|
<MudIconButton Icon="@Icons.Material.Filled.FormatListNumbered"
|
|
Link="@($"/schedules/{context.Id}/items")">
|
|
</MudIconButton>
|
|
</MudTooltip>
|
|
<MudTooltip Text="Delete Schedule">
|
|
<MudIconButton Icon="@Icons.Material.Filled.Delete"
|
|
OnClick="@(_ => DeleteSchedule(context))">
|
|
</MudIconButton>
|
|
</MudTooltip>
|
|
</div>
|
|
</MudTd>
|
|
</RowTemplate>
|
|
<PagerContent>
|
|
<MudTablePager/>
|
|
</PagerContent>
|
|
</MudTable>
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" Link="/schedules/add" Class="mt-4">
|
|
Add Schedule
|
|
</MudButton>
|
|
|
|
@if (_selectedScheduleItems != null)
|
|
{
|
|
<MudTable Hover="true" Items="_selectedScheduleItems.OrderBy(i => i.Index)" Class="mt-8">
|
|
<ToolBarContent>
|
|
<MudText Typo="Typo.h6">@_selectedSchedule.Name Items</MudText>
|
|
</ToolBarContent>
|
|
<HeaderContent>
|
|
<MudTh>Start Time</MudTh>
|
|
<MudTh>Collection</MudTh>
|
|
<MudTh>Playout Mode</MudTh>
|
|
</HeaderContent>
|
|
<RowTemplate>
|
|
<MudTd DataLabel="Start Time">
|
|
@(context.StartType == StartType.Fixed ? context.StartTime?.ToString(@"hh\:mm") ?? string.Empty : "Dynamic")
|
|
</MudTd>
|
|
<MudTd DataLabel="Collection">@context.Name</MudTd>
|
|
<MudTd DataLabel="Playout Mode">@context.PlayoutMode</MudTd>
|
|
</RowTemplate>
|
|
<PagerContent>
|
|
<MudTablePager/>
|
|
</PagerContent>
|
|
</MudTable>
|
|
}
|
|
</MudContainer>
|
|
|
|
|
|
@code {
|
|
private List<ProgramScheduleViewModel> _schedules;
|
|
private List<ProgramScheduleItemViewModel> _selectedScheduleItems;
|
|
private ProgramScheduleViewModel _selectedSchedule;
|
|
|
|
protected override Task OnParametersSetAsync() => LoadSchedules();
|
|
|
|
private async Task ScheduleSelected(ProgramScheduleViewModel schedule)
|
|
{
|
|
_selectedSchedule = schedule;
|
|
await Mediator.Send(new GetProgramScheduleItems(schedule.Id))
|
|
.IterT(results => _selectedScheduleItems = results.OrderBy(x => x.Name).ToList());
|
|
}
|
|
|
|
private async Task DeleteSchedule(ProgramScheduleViewModel programSchedule)
|
|
{
|
|
var parameters = new DialogParameters { { "EntityType", "schedule" }, { "EntityName", programSchedule.Name } };
|
|
var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall };
|
|
|
|
IDialogReference dialog = Dialog.Show<DeleteDialog>("Delete Schedule", parameters, options);
|
|
DialogResult result = await dialog.Result;
|
|
if (!result.Cancelled)
|
|
{
|
|
await Mediator.Send(new DeleteProgramSchedule(programSchedule.Id));
|
|
await LoadSchedules();
|
|
}
|
|
}
|
|
|
|
private async Task LoadSchedules() =>
|
|
_schedules = await Mediator.Send(new GetAllProgramSchedules()).Map(list => list.OrderBy(vm => vm.Name).ToList());
|
|
|
|
} |