Files
Servers/MoonlightServers.Frontend/Admin/Templates/StartupCommandEditor.razor

78 lines
2.5 KiB
Plaintext

@using LucideBlazor
@using MoonlightServers.Shared.Admin.Templates
@using ShadcnBlazor.Buttons
@using ShadcnBlazor.Inputs
@using ShadcnBlazor.Tabels
@inherits Editor<List<MoonlightServers.Shared.Admin.Templates.UpdateStartupCommandDto>>
<div class="rounded-md bg-card shadow-sm border">
<Table>
<TableHeader>
<TableRow>
<TableHead>
Display Name
</TableHead>
<TableHead>
Command
</TableHead>
<TableHead ClassName="w-10"/>
</TableRow>
</TableHeader>
<TableBody>
@foreach (var command in Value)
{
<TableRow
@key="command">
<TableCell>
<TextInputField @bind-Value="command.DisplayName"
placeholder="Default Command"/>
</TableCell>
<TableCell>
<TextInputField @bind-Value="command.Command"
placeholder="java -Xmx{{SERVER_MEMORY}} server.jar"/>
</TableCell>
<TableCell ClassName="text-right pr-4">
<Button @onclick="() => DeleteAsync(command)"
Size="ButtonSize.Icon"
Variant="ButtonVariant.Destructive">
<Trash2Icon/>
</Button>
</TableCell>
</TableRow>
}
<TableRow>
<TableCell colspan="999999">
<div class="flex justify-end">
<Button
@onclick="AddAsync"
Variant="ButtonVariant.Outline"
Size="ButtonSize.Sm">
<PlusIcon/>
Add Startup Command
</Button>
</div>
</TableCell>
</TableRow>
</TableBody>
</Table>
</div>
@code
{
private async Task DeleteAsync(UpdateStartupCommandDto commandDto)
{
Value.Remove(commandDto);
await ValueChanged.InvokeAsync(Value);
}
private async Task AddAsync()
{
Value.Add(new UpdateStartupCommandDto()
{
Command = "Change me",
DisplayName = "Change me"
});
await ValueChanged.InvokeAsync(Value);
}
}