Browse Source

save schedules and playouts table page sizes (#262)

pull/263/head
Jason Dove 4 years ago committed by GitHub
parent
commit
275f82fcc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 2
      ErsatzTV.Core/Domain/ConfigElementKey.cs
  3. 39
      ErsatzTV/Pages/Playouts.razor
  4. 37
      ErsatzTV/Pages/Schedules.razor

1
CHANGELOG.md

@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
- Add watermark opacity setting to allow blending with content
- Add global watermark setting; channel-specific watermarks have precedence over global watermarks
- Save Schedules, Playouts table page sizes
### Changed
- Remove unused API and SDK project; may reintroduce in the future but for now they have fallen out of date

2
ErsatzTV.Core/Domain/ConfigElementKey.cs

@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
public static ConfigElementKey HDHRTunerCount => new("hdhr.tuner_count");
public static ConfigElementKey ChannelsPageSize => new("pages.channels.page_size");
public static ConfigElementKey CollectionsPageSize => new("pages.collections.page_size");
public static ConfigElementKey SchedulesPageSize => new("pages.schedules.page_size");
public static ConfigElementKey PlayoutsPageSize => new("pages.playouts.page_size");
public static ConfigElementKey LibraryRefreshInterval => new("scanner.library_refresh_interval");
}
}

39
ErsatzTV/Pages/Playouts.razor

@ -2,11 +2,18 @@ @@ -2,11 +2,18 @@
@using ErsatzTV.Application.Playouts
@using ErsatzTV.Application.Playouts.Commands
@using ErsatzTV.Application.Playouts.Queries
@using ErsatzTV.Application.Configuration.Commands
@using ErsatzTV.Application.Configuration.Queries
@inject IDialogService _dialog
@inject IMediator _mediator
<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>
<MudText Typo="Typo.h6">Playouts</MudText>
</ToolBarContent>
@ -80,12 +87,16 @@ @@ -80,12 +87,16 @@
</MudContainer>
@code {
private List<PlayoutNameViewModel> _playouts;
private MudTable<PlayoutNameViewModel> _table;
private int _rowsPerPage;
private List<PlayoutItemViewModel> _selectedPlayoutItems;
private int? _selectedPlayoutId;
protected override Task OnParametersSetAsync() =>
LoadAllPlayouts();
protected override async Task OnParametersSetAsync()
{
_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)
{
@ -103,23 +114,33 @@ @@ -103,23 +114,33 @@
if (!result.Cancelled)
{
await _mediator.Send(new DeletePlayout(playout.PlayoutId));
await LoadAllPlayouts();
await _table.ReloadServerData();
}
}
private async Task RebuildPlayout(PlayoutNameViewModel playout)
{
await _mediator.Send(new BuildPlayout(playout.PlayoutId, true));
await LoadAllPlayouts();
await _table.ReloadServerData();
if (_selectedPlayoutId == playout.PlayoutId)
{
await PlayoutSelected(playout);
}
}
private async Task LoadAllPlayouts() =>
_playouts = await _mediator.Send(new GetAllPlayouts())
.Map(list => list.OrderBy(x => decimal.Parse(x.ChannelNumber)).ToList());
private async Task<TableData<PlayoutNameViewModel>> ServerReload(TableState state)
{
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)
};
}
}

37
ErsatzTV/Pages/Schedules.razor

@ -2,11 +2,18 @@ @@ -2,11 +2,18 @@
@using ErsatzTV.Application.ProgramSchedules
@using ErsatzTV.Application.ProgramSchedules.Commands
@using ErsatzTV.Application.ProgramSchedules.Queries
@using ErsatzTV.Application.Configuration.Queries
@using ErsatzTV.Application.Configuration.Commands
@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))">
<MudTable Hover="true"
Dense="true"
SelectedItemChanged="@(async (ProgramScheduleViewModel x) => await ScheduleSelected(x))"
@bind-RowsPerPage="@_rowsPerPage"
ServerData="@(new Func<TableState, Task<TableData<ProgramScheduleViewModel>>>(ServerReload))"
@ref="_table">
<ToolBarContent>
<MudText Typo="Typo.h6">Schedules</MudText>
</ToolBarContent>
@ -80,13 +87,17 @@ @@ -80,13 +87,17 @@
}
</MudContainer>
@code {
private List<ProgramScheduleViewModel> _schedules;
private MudTable<ProgramScheduleViewModel> _table;
private int _rowsPerPage;
private List<ProgramScheduleItemViewModel> _selectedScheduleItems;
private ProgramScheduleViewModel _selectedSchedule;
protected override Task OnParametersSetAsync() => LoadSchedules();
protected override async Task OnParametersSetAsync()
{
_rowsPerPage = await _mediator.Send(new GetConfigElementByKey(ConfigElementKey.SchedulesPageSize))
.Map(maybeRows => maybeRows.Match(ce => int.TryParse(ce.Value, out int rows) ? rows : 10, () => 10));
}
private async Task ScheduleSelected(ProgramScheduleViewModel schedule)
{
@ -105,11 +116,23 @@ @@ -105,11 +116,23 @@
if (!result.Cancelled)
{
await _mediator.Send(new DeleteProgramSchedule(programSchedule.Id));
await LoadSchedules();
await _table.ReloadServerData();
}
}
private async Task LoadSchedules() =>
_schedules = await _mediator.Send(new GetAllProgramSchedules()).Map(list => list.OrderBy(vm => vm.Name).ToList());
private async Task<TableData<ProgramScheduleViewModel>> ServerReload(TableState state)
{
await _mediator.Send(new SaveConfigElementByKey(ConfigElementKey.SchedulesPageSize, state.PageSize.ToString()));
List<ProgramScheduleViewModel> schedules = await _mediator.Send(new GetAllProgramSchedules());
IOrderedEnumerable<ProgramScheduleViewModel> sorted = schedules.OrderBy(s => s.Name);
// TODO: properly page this data
return new TableData<ProgramScheduleViewModel>
{
TotalItems = schedules.Count,
Items = sorted.Skip(state.Page * state.PageSize).Take(state.PageSize)
};
}
}
Loading…
Cancel
Save