Fix redistributable editing
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
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
This commit is contained in:
parent
c17d2006a6
commit
71c65059a0
6 changed files with 264 additions and 180 deletions
|
|
@ -0,0 +1,78 @@
|
|||
@using Microsoft.EntityFrameworkCore
|
||||
@inject DatabaseServiceFactory DatabaseServiceFactory
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<Layout Class="panel-layout" Style="padding: 24px 0;">
|
||||
<Sider Width="200">
|
||||
<Menu Mode="@MenuMode.Inline" Style="height: 100%;">
|
||||
<MenuItem RouterLink="@($"/Redistributables/{Redistributable.Id}/General")">General</MenuItem>
|
||||
|
||||
@if (Redistributable?.Id != Guid.Empty)
|
||||
{
|
||||
<MenuItem RouterLink="@($"/Redistributables/{Redistributable.Id}/Archives")">Archives</MenuItem>
|
||||
<MenuItem RouterLink="@($"/Redistributables/{Redistributable.Id}/Scripts")">Scripts</MenuItem>
|
||||
}
|
||||
</Menu>
|
||||
</Sider>
|
||||
|
||||
<Content>
|
||||
<CascadingValue Value="Redistributable">
|
||||
<PageHeader>
|
||||
<PageHeaderTitle>
|
||||
@if (TitleTemplate != null)
|
||||
{
|
||||
@TitleTemplate(Redistributable)
|
||||
}
|
||||
else {
|
||||
<Text>@Title</Text>
|
||||
}
|
||||
</PageHeaderTitle>
|
||||
|
||||
<PageHeaderExtra>
|
||||
@TitleExtraTemplate?.Invoke(Redistributable)
|
||||
</PageHeaderExtra>
|
||||
</PageHeader>
|
||||
</CascadingValue>
|
||||
|
||||
<div class="panel-layout-content">
|
||||
@ChildContent?.Invoke(Redistributable)
|
||||
</div>
|
||||
</Content>
|
||||
</Layout>
|
||||
|
||||
@code {
|
||||
[Parameter] public Guid Id { get; set; }
|
||||
[Parameter] public string Title { get; set; }
|
||||
[Parameter] public RenderFragment<Redistributable>? TitleTemplate { get; set; }
|
||||
[Parameter] public RenderFragment<Redistributable>? TitleExtraTemplate { get; set; }
|
||||
[Parameter] public RenderFragment<Redistributable>? ChildContent { get; set; }
|
||||
|
||||
Redistributable Redistributable { get; set; } = new();
|
||||
Guid _id;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (_id != Id)
|
||||
{
|
||||
_id = Id;
|
||||
|
||||
using (var redistributableService = DatabaseServiceFactory.Create<RedistributableService>())
|
||||
{
|
||||
if (_id != Guid.Empty)
|
||||
Redistributable = await redistributableService
|
||||
.Query(query =>
|
||||
{
|
||||
return query
|
||||
.Include(g => g.CreatedBy)
|
||||
.Include(g => g.UpdatedBy);
|
||||
})
|
||||
.GetAsync(_id);
|
||||
else
|
||||
Redistributable = new();
|
||||
}
|
||||
|
||||
if (Redistributable == null)
|
||||
NavigationManager.NavigateTo("/Redistributables");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,179 +0,0 @@
|
|||
@page "/Redistributables/{id:guid}"
|
||||
@page "/Redistributables/{id:guid}/{panel}"
|
||||
@page "/Redistributables/Add"
|
||||
@using LANCommander.SDK.Enums
|
||||
@using LANCommander.Server.Models
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
|
||||
@inject DatabaseServiceFactory DatabaseServiceFactory
|
||||
@inject IMessageService MessageService
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject ILogger<Edit> Logger
|
||||
|
||||
<Layout Class="panel-layout" Style="padding: 24px 0;">
|
||||
<Sider Width="200">
|
||||
<Menu Mode="@MenuMode.Inline" Style="height: 100%;">
|
||||
<MenuItem RouterLink="@($"/Redistributables/{Redistributable.Id}/General")">General</MenuItem>
|
||||
|
||||
@if (Redistributable?.Id != Guid.Empty)
|
||||
{
|
||||
<MenuItem RouterLink="@($"/Redistributables/{Redistributable.Id}/Scripts")">Scripts</MenuItem>
|
||||
<MenuItem RouterLink="@($"/Redistributables/{Redistributable.Id}/Archives")">Archives</MenuItem>
|
||||
}
|
||||
</Menu>
|
||||
</Sider>
|
||||
|
||||
<Content>
|
||||
<PageHeader>
|
||||
<PageHeaderTitle>
|
||||
@if (Id == Guid.Empty)
|
||||
{
|
||||
<Text>Add New Redistributable</Text>
|
||||
}
|
||||
else
|
||||
{
|
||||
@Panel
|
||||
}
|
||||
</PageHeaderTitle>
|
||||
<PageHeaderExtra>
|
||||
<Flex Gap="FlexGap.Small" Justify="FlexJustify.End">
|
||||
@if (Redistributable != null && Redistributable.Id != Guid.Empty)
|
||||
{
|
||||
<a href="/Redistributables/@(Id)/Export" target="_blank" class="ant-btn ant-btn-default">Export</a>
|
||||
}
|
||||
|
||||
<Button Type="@ButtonType.Primary" OnClick="Save">Save</Button>
|
||||
</Flex>
|
||||
</PageHeaderExtra>
|
||||
</PageHeader>
|
||||
|
||||
|
||||
<div class="panel-layout-content">
|
||||
<div data-panel="General">
|
||||
<Form Model="@Redistributable" Layout="@FormLayout.Vertical">
|
||||
<FormItem Label="Name">
|
||||
<Input @bind-Value="@context.Name" />
|
||||
</FormItem>
|
||||
|
||||
<FormItem Label="Notes">
|
||||
<TextArea @bind-Value="@context.Notes" MaxLength=2000 ShowCount />
|
||||
</FormItem>
|
||||
|
||||
<FormItem Label="Description">
|
||||
<TextArea @bind-Value="@context.Description" MaxLength=500 ShowCount />
|
||||
</FormItem>
|
||||
|
||||
<FormItem Label="Games">
|
||||
<TransferInput LeftTitle="Available" RightTitle="Selected" DataSource="Games" TitleSelector="r => r.Title" @bind-Values="Redistributable.Games" />
|
||||
</FormItem>
|
||||
</Form>
|
||||
</div>
|
||||
|
||||
@if (Redistributable != null && Redistributable.Id != Guid.Empty)
|
||||
{
|
||||
<div data-panel="Scripts">
|
||||
<ScriptEditor RedistributableId="Redistributable.Id" ArchiveId="@LatestArchiveId" AllowedTypes="new ScriptType[] { ScriptType.Install, ScriptType.DetectInstall }" />
|
||||
</div>
|
||||
|
||||
<div data-panel="Archives">
|
||||
<ArchiveEditor RedistributableId="Redistributable.Id" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</Content>
|
||||
</Layout>
|
||||
|
||||
@if (!String.IsNullOrWhiteSpace(Panel))
|
||||
{
|
||||
<style>
|
||||
.panel-layout [data-panel="@Panel"] {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
else
|
||||
{
|
||||
<style>
|
||||
.panel-layout [data-panel="General"] {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public Guid Id { get; set; }
|
||||
[Parameter] public string Panel { get; set; }
|
||||
|
||||
Redistributable Redistributable = new Redistributable();
|
||||
|
||||
ICollection<Game> Games;
|
||||
|
||||
Settings Settings = SettingService.GetSettings();
|
||||
|
||||
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 && Panel == null)
|
||||
NavigationManager.NavigateTo($"/Redistributables/{Id}/General", true);
|
||||
else if (Id != Guid.Empty)
|
||||
Redistributable = await redistributableService
|
||||
.Include(r => r.Games)
|
||||
.GetAsync(Id);
|
||||
}
|
||||
|
||||
using (var gameService = DatabaseServiceFactory.Create<GameService>())
|
||||
{
|
||||
Games = await gameService
|
||||
.SortBy(g => String.IsNullOrWhiteSpace(g.SortTitle) ? g.Title : g.SortTitle)
|
||||
.GetAsync(g => g.Type == GameType.MainGame || g.Type == GameType.StandaloneExpansion || g.Type == GameType.StandaloneMod || g.BaseGame == null);
|
||||
}
|
||||
}
|
||||
|
||||
async Task Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var redistributableService = DatabaseServiceFactory.Create<RedistributableService>())
|
||||
{
|
||||
if (Redistributable.Id != Guid.Empty)
|
||||
{
|
||||
Redistributable = await redistributableService.UpdateAsync(Redistributable);
|
||||
|
||||
await MessageService.Success("Redistributable updated!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Redistributable = await redistributableService.AddAsync(Redistributable);
|
||||
|
||||
NavigationManager.LocationChanged += NotifyRedistributableAdded;
|
||||
|
||||
NavigationManager.NavigateTo($"/Redistributables/{Redistributable.Id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageService.Error("Could not save!");
|
||||
Logger.LogError(ex, "Could not save!");
|
||||
}
|
||||
}
|
||||
|
||||
void NotifyRedistributableAdded(object? sender, LocationChangedEventArgs e)
|
||||
{
|
||||
NavigationManager.LocationChanged -= NotifyRedistributableAdded;
|
||||
|
||||
MessageService.Success("Redistributable added!");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
@page "/Redistributables/{id:guid}/Archives"
|
||||
@using LANCommander.Server.UI.Pages.Redistributables.Components
|
||||
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
|
||||
|
||||
<RedistributableEditView Id="Id" Title="Archives">
|
||||
<ArchiveEditor RedistributableId="Id" />
|
||||
</RedistributableEditView>
|
||||
|
||||
@code {
|
||||
[Parameter] public Guid Id { get; set; }
|
||||
}
|
||||
133
LANCommander.Server/UI/Pages/Redistributables/Edit/General.razor
Normal file
133
LANCommander.Server/UI/Pages/Redistributables/Edit/General.razor
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
@page "/Redistributables/{id:guid}"
|
||||
@page "/Redistributables/{id:guid}/General"
|
||||
@page "/Redistributables/Add"
|
||||
@using LANCommander.SDK.Enums
|
||||
@using LANCommander.Server.UI.Pages.Redistributables.Components
|
||||
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
|
||||
@inject DatabaseServiceFactory DatabaseServiceFactory
|
||||
@inject IMessageService MessageService
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject ILogger<General> Logger
|
||||
|
||||
<RedistributableEditView Id="Id">
|
||||
<TitleTemplate>
|
||||
@if (Id == Guid.Empty)
|
||||
{
|
||||
<Text>Add New Redistributable</Text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Text>General</Text>
|
||||
}
|
||||
</TitleTemplate>
|
||||
<TitleExtraTemplate>
|
||||
<Flex Gap="FlexGap.Small" Justify="FlexJustify.End">
|
||||
@if (context != null && context.Id != Guid.Empty)
|
||||
{
|
||||
<Dropdown Trigger="@(new[] { Trigger.Click })">
|
||||
<Overlay>
|
||||
<Menu>
|
||||
<MenuItem>
|
||||
<a href="/Redistributables/@(context.Id)/Export/Full" target="_blank">Full</a>
|
||||
</MenuItem>
|
||||
<MenuItem>
|
||||
<a href="/Redistributables/@(context.Id)/Export/Metadata" target="_blank">Metadata</a>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</Overlay>
|
||||
<ChildContent>
|
||||
<Button>Export</Button>
|
||||
</ChildContent>
|
||||
</Dropdown>
|
||||
}
|
||||
|
||||
<Button Type="ButtonType.Primary" OnClick="() => Save(context)">Save</Button>
|
||||
</Flex>
|
||||
</TitleExtraTemplate>
|
||||
<ChildContent Context="redistributable">
|
||||
<Form Model="redistributable" Layout="@FormLayout.Vertical">
|
||||
<FormItem Label="Name">
|
||||
<Input @bind-Value="@context.Name" />
|
||||
</FormItem>
|
||||
|
||||
<FormItem Label="Notes">
|
||||
<TextArea @bind-Value="@context.Notes" MaxLength=2000 ShowCount />
|
||||
</FormItem>
|
||||
|
||||
<FormItem Label="Description">
|
||||
<TextArea @bind-Value="@context.Description" MaxLength=500 ShowCount />
|
||||
</FormItem>
|
||||
|
||||
<FormItem Label="Games">
|
||||
<TransferInput LeftTitle="Available" RightTitle="Selected" DataSource="Games" TitleSelector="r => r.Title" @bind-Values="Redistributable.Games" />
|
||||
</FormItem>
|
||||
</Form>
|
||||
</ChildContent>
|
||||
</RedistributableEditView>
|
||||
|
||||
@code {
|
||||
[Parameter] public Guid Id { get; set; }
|
||||
|
||||
Redistributable Redistributable = new();
|
||||
|
||||
ICollection<Game> Games;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (Id != Guid.Empty)
|
||||
{
|
||||
using (var redistributableService = DatabaseServiceFactory.Create<RedistributableService>())
|
||||
{
|
||||
Redistributable = await redistributableService
|
||||
.Include(r => r.Archives)
|
||||
.Include(r => r.Games)
|
||||
.Include(r => r.Scripts)
|
||||
.GetAsync(Id);
|
||||
}
|
||||
}
|
||||
|
||||
using (var gameService = DatabaseServiceFactory.Create<GameService>())
|
||||
{
|
||||
Games = await gameService
|
||||
.Include(g => g.Media)
|
||||
.SortBy(g => String.IsNullOrWhiteSpace(g.SortTitle) ? g.Title : g.SortTitle)
|
||||
.GetAsync(g => g.Type == GameType.MainGame || g.Type == GameType.StandaloneExpansion || g.Type == GameType.StandaloneMod || g.BaseGame == null);
|
||||
}
|
||||
}
|
||||
|
||||
async Task Save(Redistributable redistributable)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var redistributableService = DatabaseServiceFactory.Create<RedistributableService>())
|
||||
{
|
||||
if (Redistributable.Id != Guid.Empty)
|
||||
{
|
||||
Redistributable = await redistributableService.UpdateAsync(redistributable);
|
||||
|
||||
await MessageService.Success("Redistributable updated!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Redistributable = await redistributableService.AddAsync(redistributable);
|
||||
|
||||
NavigationManager.LocationChanged += NotifyRedistributableAdded;
|
||||
|
||||
NavigationManager.NavigateTo($"/Redistributables/{redistributable.Id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageService.Error("Could not save!");
|
||||
Logger.LogError(ex, "Could not save!");
|
||||
}
|
||||
}
|
||||
|
||||
void NotifyRedistributableAdded(object? sender, LocationChangedEventArgs e)
|
||||
{
|
||||
NavigationManager.LocationChanged -= NotifyRedistributableAdded;
|
||||
|
||||
MessageService.Success("Redistributable added!");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
<BoundDataColumn Property="r => r.UpdatedOn" Format="MM/dd/yyyy hh:mm tt" Sortable />
|
||||
<BoundDataColumn Property="r => r.UpdatedBy != null ? r.UpdatedBy.UserName : String.Empty" Title="Updated By" Sortable Include="UpdatedBy" />
|
||||
<DataActions>
|
||||
<a href="@($"/Redistibutables/{context.Id}")" class="ant-btn ant-btn-primary">Edit</a>
|
||||
<a href="@($"/Redistributables/{context.Id}")" class="ant-btn ant-btn-primary">Edit</a>
|
||||
|
||||
<Popconfirm OnConfirm="() => Delete(context)" Title="Are you sure you want to delete this redistributable?">
|
||||
<Button Type="@ButtonType.Text" Icon="@IconType.Outline.Close" Danger/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue