95 lines
2.7 KiB
Text
95 lines
2.7 KiB
Text
@using LANCommander.SDK.Models
|
|
@inherits FeedbackComponent<Data.Models.Game>
|
|
@inject SaveService SaveService
|
|
@inject IMessageService MessageService
|
|
|
|
<Table DataSource="Saves" Size="TableSize.Small" PageIndex="@CurrentPage" PageSize="@PageSize" PaginationPosition="none">
|
|
<PropertyColumn Property="s => s.CreatedOn" Title="Created On" />
|
|
<PropertyColumn Property="s => s.Size">
|
|
<ByteSize Value="context.Size" />
|
|
</PropertyColumn>
|
|
<ActionColumn>
|
|
<Flex Justify="FlexJustify.End">
|
|
<Popconfirm Title="Are you sure? This will replace any local save files!" OnConfirm="() => Download(context)">
|
|
<Button Type="@ButtonType.Text" Icon="@IconType.Outline.Download" />
|
|
</Popconfirm>
|
|
|
|
<Popconfirm Title="Are you sure you want to delete this save?" OnConfirm="() => Delete(context)">
|
|
<Button Type="@ButtonType.Text" Icon="@IconType.Outline.Close" Danger />
|
|
</Popconfirm>
|
|
</Flex>
|
|
</ActionColumn>
|
|
</Table>
|
|
|
|
<GridRow Wrap="false" Style="padding: 10px 16px;">
|
|
<GridCol Flex="@("auto")" Style=";display: flex; align-items: center;">
|
|
@if (Saves.Count() > PageSize)
|
|
{
|
|
<Pagination Simple PageSize="@PageSize" OnChange="OnPageChange" Total="Saves.Count()" />
|
|
}
|
|
</GridCol>
|
|
|
|
<GridCol>
|
|
<Space Direction="SpaceDirection.Horizontal">
|
|
<SpaceItem>
|
|
<Button OnClick="() => Upload()">Upload</Button>
|
|
</SpaceItem>
|
|
<SpaceItem>
|
|
<Button Type="ButtonType.Primary" OnClick="() => Close()">Close</Button>
|
|
</SpaceItem>
|
|
</Space>
|
|
</GridCol>
|
|
</GridRow>
|
|
|
|
@code {
|
|
IEnumerable<GameSave> Saves = new List<GameSave>();
|
|
|
|
int PageSize = 10;
|
|
int CurrentPage = 1;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await LoadData();
|
|
}
|
|
|
|
async Task OnPageChange(PaginationEventArgs args)
|
|
{
|
|
CurrentPage = args.Page;
|
|
}
|
|
|
|
async Task Download(GameSave save)
|
|
{
|
|
await SaveService.DownloadAsync(Options.InstallDirectory, Options.Id, save.Id);
|
|
|
|
MessageService.Success("Save downloaded!");
|
|
}
|
|
|
|
async Task Delete(GameSave save)
|
|
{
|
|
await SaveService.DeleteAsync(save.Id);
|
|
|
|
MessageService.Success("Save deleted!");
|
|
|
|
await LoadData();
|
|
}
|
|
|
|
async Task Upload()
|
|
{
|
|
await SaveService.UploadAsync(Options.InstallDirectory, Options.Id);
|
|
|
|
MessageService.Success("Save uploaded!");
|
|
|
|
await LoadData();
|
|
}
|
|
|
|
async Task Close()
|
|
{
|
|
await CloseFeedbackAsync();
|
|
}
|
|
|
|
async Task LoadData()
|
|
{
|
|
Saves = await SaveService.Get(Options.Id);
|
|
Saves = Saves.OrderByDescending(s => s.CreatedOn);
|
|
}
|
|
}
|