LANCommander/LANCommander.Server/UI/Pages/Redistributables/Edit/Scripts.razor
Pat Hartl 71c65059a0
Some checks failed
Publish SDK NuGet Package / publish (push) Failing after 1m29s
LANCommander Release / prep (push) Has been cancelled
LANCommander Release / build_server_linux-arm64 (push) Has been cancelled
LANCommander Release / build_server_linux-x64 (push) Has been cancelled
LANCommander Release / build_server_osx-arm64 (push) Has been cancelled
LANCommander Release / build_server_osx-x64 (push) Has been cancelled
LANCommander Release / build_server_win-arm64 (push) Has been cancelled
LANCommander Release / build_server_win-x64 (push) Has been cancelled
LANCommander Release / build_launcher_linux-arm64 (push) Has been cancelled
LANCommander Release / build_launcher_linux-x64 (push) Has been cancelled
LANCommander Release / build_launcher_osx-arm64 (push) Has been cancelled
LANCommander Release / build_launcher_osx-x64 (push) Has been cancelled
LANCommander Release / build_launcher_win-arm64 (push) Has been cancelled
LANCommander Release / build_launcher_win-x64 (push) Has been cancelled
LANCommander Release / build_release (push) Has been cancelled
Fix redistributable editing
2025-01-28 17:54:30 -06:00

41 lines
No EOL
1.5 KiB
Text

@page "/Redistributables/{id:guid}/Scripts"
@using LANCommander.SDK.Enums
@using LANCommander.Server.UI.Pages.Redistributables.Components
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
@inject DatabaseServiceFactory DatabaseServiceFactory
@inject NavigationManager NavigationManager
<RedistributableEditView Id="Id">
<ScriptEditor RedistributableId="Id" ArchiveId="@LatestArchiveId" AllowedTypes="new[] { ScriptType.Install, ScriptType.DetectInstall }" />
</RedistributableEditView>
@code {
[Parameter] public Guid Id { get; set; }
[Parameter] public string Panel { get; set; }
Redistributable Redistributable = new();
Guid LatestArchiveId
{
get
{
if (Redistributable != null && Redistributable.Archives != null && Redistributable.Archives.Count > 0)
return Redistributable.Archives.OrderByDescending(a => a.CreatedOn).FirstOrDefault().Id;
else
return Guid.Empty;
}
}
protected override async Task OnInitializedAsync()
{
using (var redistributableService = DatabaseServiceFactory.Create<RedistributableService>())
{
if (Id == Guid.Empty)
NavigationManager.NavigateTo($"/Redistributables", true);
else
Redistributable = await redistributableService
.Include(r => r.Archives)
.GetAsync(Id);
}
}
}