Stream custom live channels using your own media
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

66 lines
2.2 KiB

@using ErsatzTV.Application.MediaItems
@using ErsatzTV.Application.MediaItems.Queries
@inject IMediator Mediator
<MudTable @ref="_table" Hover="true" ServerData="@(new Func<TableState, Task<TableData<AggregateMediaItemViewModel>>>(ServerReload))">
<ToolBarContent>
<MudText Typo="Typo.h6">Media Items</MudText>
<MudToolBarSpacer/>
<MudTextField T="string" ValueChanged="@OnSearch" Placeholder="Search" Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0">
</MudTextField>
</ToolBarContent>
<HeaderContent>
<MudTh>Source</MudTh>
<MudTh>Title</MudTh>
<MudTh>Count</MudTh>
<MudTh>Duration</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="Source">@context.Source</MudTd>
<MudTd DataLabel="Title">@context.Title</MudTd>
<MudTd DataLabel="Count">@context.Count</MudTd>
<MudTd DataLabel="Duration">@context.Duration</MudTd>
</RowTemplate>
<PagerContent>
<MudTablePager/>
</PagerContent>
</MudTable>
@code {
[Parameter]
public MediaType MediaType { get; set; }
private IEnumerable<AggregateMediaItemViewModel> _pagedData;
private MudTable<AggregateMediaItemViewModel> _table;
private int _totalItems;
private string _searchString;
private async Task<TableData<AggregateMediaItemViewModel>> ServerReload(TableState state)
{
List<AggregateMediaItemViewModel> aggregateData =
await Mediator.Send(new GetAggregateMediaItems(MediaType, _searchString));
_totalItems = aggregateData.Count;
_pagedData = aggregateData.Skip(state.Page * state.PageSize).Take(state.PageSize);
return new TableData<AggregateMediaItemViewModel> { TotalItems = _totalItems, Items = _pagedData };
}
private void OnSearch(string text)
{
_searchString = text;
_table.ReloadServerData();
}
private class MediaItemAggregate
{
public string Source { get; set; }
public string Title { get; set; }
public int Count { get; set; }
public string Duration { get; set; }
}
}