74 lines
No EOL
2.6 KiB
Text
74 lines
No EOL
2.6 KiB
Text
@page "/Servers/{id:guid}/Autostart"
|
|
@using LANCommander.SDK.Enums
|
|
@using LANCommander.Server.UI.Pages.Servers.Components
|
|
@inject ServerService ServerService
|
|
@inject IMessageService MessageService
|
|
@inject ILogger<General> Logger
|
|
|
|
<ServerEditView Id="Id" Title="Autostart">
|
|
<TitleExtraTemplate>
|
|
@if (context != null && context.Id != Guid.Empty)
|
|
{
|
|
<Flex Align="FlexAlign.Center" Justify="FlexJustify.End" Wrap="FlexWrap.NoWrap" Gap="FlexGap.Small">
|
|
<ServerControl ServerId="context.Id" />
|
|
|
|
<Dropdown Trigger="@(new Trigger[] { Trigger.Click })">
|
|
<Overlay>
|
|
<Menu>
|
|
<MenuItem>
|
|
<a href="/Server/@(context.Id)/Export/Full" target="_blank">Full</a>
|
|
</MenuItem>
|
|
</Menu>
|
|
</Overlay>
|
|
<ChildContent>
|
|
<Button>Export</Button>
|
|
</ChildContent>
|
|
</Dropdown>
|
|
</Flex>
|
|
}
|
|
</TitleExtraTemplate>
|
|
|
|
<ChildContent>
|
|
<Form Model="@context" Layout="@FormLayout.Vertical" Context="formContext">
|
|
<FormItem Label="Enable">
|
|
<Switch @bind-Checked="context.Autostart" />
|
|
</FormItem>
|
|
|
|
<FormItem Label="Method">
|
|
<Select @bind-Value="context.AutostartMethod" TItem="ServerAutostartMethod" TItemValue="ServerAutostartMethod" DataSource="Enum.GetValues<ServerAutostartMethod>()">
|
|
<LabelTemplate Context="Value">@Value.GetDisplayName()</LabelTemplate>
|
|
<ItemTemplate Context="Value">@Value.GetDisplayName()</ItemTemplate>
|
|
</Select>
|
|
</FormItem>
|
|
|
|
<FormItem Label="Delay">
|
|
<AntDesign.Input @bind-Value="context.AutostartDelay" Placeholder="0">
|
|
<Suffix>Seconds</Suffix>
|
|
</AntDesign.Input>
|
|
</FormItem>
|
|
|
|
<FormItem>
|
|
<Button Type="@ButtonType.Primary" OnClick="() => Save(context)" Icon="@IconType.Fill.Save">Save</Button>
|
|
</FormItem>
|
|
</Form>
|
|
</ChildContent>
|
|
</ServerEditView>
|
|
|
|
@code {
|
|
[Parameter] public Guid Id { get; set; }
|
|
|
|
async Task Save(Server server)
|
|
{
|
|
try
|
|
{
|
|
server = await ServerService.UpdateAsync(server);
|
|
|
|
await MessageService.SuccessAsync("Autostart configuration updated!");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageService.Error("Could not save!");
|
|
Logger.LogError(ex, "Could not save!");
|
|
}
|
|
}
|
|
} |