LANCommander/LANCommander.Server/UI/Pages/Settings/IPXRelay.razor

62 lines
1.8 KiB
Text
Raw Permalink Normal View History

2023-09-08 22:26:28 -05:00
@page "/Settings/IPXRelay"
@using LANCommander.Server.Settings
@using Microsoft.Extensions.Options
2023-09-08 22:26:28 -05:00
@inject IPXRelayService IPXRelayService
@inject IMessageService MessageService
2024-07-07 16:33:46 -05:00
@inject ILogger<IPXRelay> Logger
@inject IOptions<Settings> Settings
@inject SettingsProvider<Settings> SettingsProvider
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
2023-09-08 22:26:28 -05:00
<PageHeader Title="IPX Relay" />
2025-02-04 19:32:33 -06:00
<PageContent>
<Form Model="Settings.Value" Layout="@FormLayout.Vertical">
2023-09-08 22:26:28 -05:00
<FormItem Label="Enable">
<Switch @bind-Checked="context.Server.IPXRelay.Enabled" />
2023-09-08 22:26:28 -05:00
</FormItem>
2024-01-02 21:33:39 -06:00
<FormItem Label="Host">
<Text Type="@TextElementType.Secondary">Use this to customize the host that is broadcasted to clients.</Text>
<Input @bind-Value="context.Server.IPXRelay.Host" />
2024-01-02 21:33:39 -06:00
</FormItem>
2023-09-08 22:26:28 -05:00
<FormItem Label="Port">
<AntDesign.InputNumber @bind-Value="context.Server.IPXRelay.Port" Max="65535" />
2023-09-08 22:26:28 -05:00
</FormItem>
<FormItem Label="Logging">
<Switch @bind-Checked="context.Server.IPXRelay.Logging" />
2023-09-08 22:26:28 -05:00
</FormItem>
<FormItem>
<Button OnClick="Save" Type="@ButtonType.Primary">Save</Button>
</FormItem>
</Form>
2025-02-04 19:32:33 -06:00
</PageContent>
2023-09-08 22:26:28 -05:00
@code {
2025-03-09 01:51:17 -06:00
async Task Save()
2023-09-08 22:26:28 -05:00
{
try
{
SettingsProvider.Update(s =>
{
s.Server.IPXRelay = Settings.Value.Server.IPXRelay;
});
2023-09-08 22:26:28 -05:00
MessageService.Success("Settings saved!");
2025-03-09 01:51:17 -06:00
await IPXRelayService.StopAsync();
IPXRelayService.Init(Logger);
2023-09-08 22:26:28 -05:00
}
2024-07-07 16:33:46 -05:00
catch (Exception ex)
2023-09-08 22:26:28 -05:00
{
MessageService.Error("An unknown error occurred.");
2024-07-07 16:33:46 -05:00
Logger.LogError(ex, "An unknown error occurred.");
2023-09-08 22:26:28 -05:00
}
}
}