45 lines
1.3 KiB
Text
45 lines
1.3 KiB
Text
@page "/Games/{id:guid}/SavePaths"
|
|
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
|
|
@inject MessageService MessageService
|
|
@inject ILogger<Multiplayer> Logger
|
|
|
|
<GameEditView Id="Id" Title="Save Paths">
|
|
<TitleExtraTemplate>
|
|
<Flex Gap="FlexGap.Small" Justify="FlexJustify.End">
|
|
<Button Type="ButtonType.Primary" OnClick="Save">Save</Button>
|
|
</Flex>
|
|
</TitleExtraTemplate>
|
|
|
|
<ChildContent>
|
|
<SavePathEditor @ref="SavePathEditor" GameId="@Id" ArchiveId="@GetLatestArchiveId(context)"/>
|
|
</ChildContent>
|
|
</GameEditView>
|
|
|
|
@code {
|
|
[Parameter] public Guid Id { get; set; }
|
|
|
|
SavePathEditor SavePathEditor;
|
|
|
|
Guid GetLatestArchiveId(Game game)
|
|
{
|
|
if (game != null && game.Archives != null && game.Archives.Count > 0)
|
|
return game.Archives.OrderByDescending(a => a.CreatedOn).FirstOrDefault()?.Id ?? Guid.Empty;
|
|
else
|
|
return Guid.Empty;
|
|
}
|
|
|
|
async Task Save()
|
|
{
|
|
try
|
|
{
|
|
await SavePathEditor.Save();
|
|
|
|
await MessageService.Success("Save paths updated!");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageService.Error("Could not update save paths!");
|
|
Logger.LogError(ex, "Could not update save paths!");
|
|
}
|
|
}
|
|
}
|