69 lines
2.2 KiB
Text
69 lines
2.2 KiB
Text
@page "/Settings/Tools/ActiveSessions"
|
|
@inject PlaySessionService PlaySessionService
|
|
@inject IMessageService MessageService
|
|
@inject ILogger<ActiveSessions> Logger
|
|
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
|
|
|
|
<PageHeader Title="Active Sessions" />
|
|
|
|
<PageContent>
|
|
<p>
|
|
These play sessions are considered active because they never ended. This may cause servers set to autostart with "Player Activity" to not stop when a player has quit a game.
|
|
</p>
|
|
</PageContent>
|
|
|
|
<Table TItem="PlaySession" DataSource="@PlaySessions" Loading="@Loading" Responsive>
|
|
<PropertyColumn Property="ps => ps.Game.Title" Title="Game" />
|
|
<PropertyColumn Property="ps => ps.Start" />
|
|
<PropertyColumn Property="ps => ps.End" />
|
|
<PropertyColumn Property="ps => ps.CreatedOn" Format="MM/dd/yyyy hh:mm tt" Sortable DefaultSortOrder="@SortDirection.Descending" />
|
|
<PropertyColumn Property="ps => ps.CreatedBy" Sortable>
|
|
@context.CreatedBy?.UserName
|
|
</PropertyColumn>
|
|
<ActionColumn Title="" Style="text-align: right">
|
|
<Space Direction="SpaceDirection.Horizontal">
|
|
<SpaceItem>
|
|
<Popconfirm OnConfirm="() => Delete(context)" Title="Are you sure you want to delete this session?">
|
|
<Button Icon="@IconType.Outline.Close" Type="@ButtonType.Text" Danger />
|
|
</Popconfirm>
|
|
</SpaceItem>
|
|
</Space>
|
|
</ActionColumn>
|
|
</Table>
|
|
|
|
|
|
@code {
|
|
ICollection<PlaySession> PlaySessions;
|
|
bool Loading = true;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await LoadData();
|
|
}
|
|
|
|
async Task LoadData()
|
|
{
|
|
Loading = true;
|
|
|
|
PlaySessions = await PlaySessionService.GetAsync(ps => !ps.End.HasValue);
|
|
|
|
Loading = false;
|
|
}
|
|
|
|
async Task Delete(PlaySession playSession)
|
|
{
|
|
try
|
|
{
|
|
await PlaySessionService.DeleteAsync(playSession);
|
|
|
|
await LoadData();
|
|
|
|
MessageService.Success("Session deleted!");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageService.Error("Session could not be deleted.");
|
|
Logger.LogError(ex, "Session could not be deleted.");
|
|
}
|
|
}
|
|
}
|