82 lines
No EOL
3 KiB
Text
82 lines
No EOL
3 KiB
Text
@using LANCommander.Server.Settings.Enums
|
|
@using LANCommander.Server.Settings.Models
|
|
|
|
<Flex Direction="FlexDirection.Vertical" Gap="FlexGap.Large">
|
|
@if (!ServerEngines.Any())
|
|
{
|
|
<Empty Description="@("No Docker hosts have been configured")" />
|
|
}
|
|
|
|
<Collapse>
|
|
@foreach (var serverEngine in ServerEngines)
|
|
{
|
|
@if (serverEngine.Type == ServerEngine.Local)
|
|
{
|
|
<Panel Header="@serverEngine.Name">
|
|
<ExtraTemplate>
|
|
<Button Type="ButtonType.Text" Icon="@IconType.Outline.Close" Size="ButtonSize.Small" Danger OnClick="() => Remove(serverEngine)"/>
|
|
</ExtraTemplate>
|
|
<ChildContent>
|
|
<Form Model="serverEngine" Layout="FormLayout.Vertical">
|
|
<FormItem Label="Name">
|
|
<Input @bind-Value="context.Name" BindOnInput />
|
|
</FormItem>
|
|
</Form>
|
|
</ChildContent>
|
|
</Panel>
|
|
}
|
|
|
|
@if (serverEngine.Type == ServerEngine.Docker)
|
|
{
|
|
<Panel Header="@serverEngine.Name">
|
|
<ExtraTemplate>
|
|
<Button Type="ButtonType.Text" Icon="@IconType.Outline.Close" Size="ButtonSize.Small" Danger OnClick="() => Remove(serverEngine)"/>
|
|
</ExtraTemplate>
|
|
<ChildContent>
|
|
<Form Model="serverEngine" Layout="FormLayout.Vertical">
|
|
<FormItem Label="Name">
|
|
<Input @bind-Value="context.Name" BindOnInput />
|
|
</FormItem>
|
|
|
|
<FormItem Label="Address">
|
|
<Input @bind-Value="context.Address" />
|
|
</FormItem>
|
|
</Form>
|
|
</ChildContent>
|
|
</Panel>
|
|
}
|
|
}
|
|
</Collapse>
|
|
|
|
<Flex Justify="FlexJustify.Center">
|
|
<Button OnClick="Add" Type="ButtonType.Primary">Add Engine</Button>
|
|
</Flex>
|
|
</Flex>
|
|
|
|
@code {
|
|
[Parameter] public IEnumerable<ServerEngineConfiguration> Values { get; set; }
|
|
[Parameter] public EventCallback<IEnumerable<ServerEngineConfiguration>> ValuesChanged { get; set; }
|
|
|
|
List<ServerEngineConfiguration> ServerEngines = new();
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
ServerEngines = Values.OrderBy(e => e.Type).ThenBy(e => e.Name).ToList();
|
|
}
|
|
|
|
async Task Add()
|
|
{
|
|
ServerEngines.Add(new ServerEngineConfiguration());
|
|
|
|
if (ValuesChanged.HasDelegate)
|
|
await ValuesChanged.InvokeAsync(ServerEngines);
|
|
}
|
|
|
|
async Task Remove(ServerEngineConfiguration serverEngine)
|
|
{
|
|
ServerEngines.Remove(serverEngine);
|
|
|
|
if (ValuesChanged.HasDelegate)
|
|
await ValuesChanged.InvokeAsync(ServerEngines);
|
|
}
|
|
} |