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

65 lines
1.9 KiB
Text
Raw Permalink Normal View History

@page "/Settings"
2023-03-03 17:41:15 -06:00
@page "/Settings/General"
@using LANCommander.Server.Settings
@using LANCommander.Server.Settings.Enums
@using Microsoft.Extensions.Options
@inject IOptions<Settings> Settings
@inject SettingsProvider<Settings> SettingsProvider
@inject IMessageService MessageService
2024-07-07 16:33:46 -05:00
@inject ILogger<General> Logger
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
<PageHeader Title="General" />
2025-02-04 19:32:33 -06:00
<PageContent>
<Form Model="Settings.Value" Layout="@FormLayout.Vertical">
2025-01-25 02:40:36 -06:00
<FormItem Label="Port">
<AntDesign.InputNumber @bind-Value="context.Server.Http.Port" />
2023-09-05 19:41:11 -05:00
</FormItem>
2025-01-25 01:57:17 -06:00
<Divider Text="SSL" />
2025-02-04 19:32:33 -06:00
2025-01-25 01:57:17 -06:00
<FormItem Label="Use SSL">
<Switch @bind-Checked="context.Server.Http.UseSSL" />
2025-01-25 01:57:17 -06:00
</FormItem>
2025-02-04 19:32:33 -06:00
2025-01-25 02:40:36 -06:00
<FormItem Label="SSL Port">
<AntDesign.InputNumber @bind-Value="context.Server.Http.SSLPort" Disabled="!context.Server.Http.UseSSL" />
2025-01-25 02:40:36 -06:00
</FormItem>
2025-02-04 19:32:33 -06:00
2025-01-25 01:57:17 -06:00
<FormItem Label="Certificate Path">
<FilePicker Root="@RootPath" @bind-Value="context.Server.Http.CertificatePath" Disabled="!context.Server.Http.UseSSL" />
2025-01-25 01:57:17 -06:00
</FormItem>
2025-02-04 19:32:33 -06:00
2025-01-25 01:57:17 -06:00
<FormItem Label="Certificate Password">
<InputPassword @bind-Value="context.Server.Http.CertificatePassword" Disabled="!context.Server.Http.UseSSL" />
2025-01-25 01:57:17 -06:00
</FormItem>
<FormItem>
<Button OnClick="Save" Type="@ButtonType.Primary">Save</Button>
</FormItem>
</Form>
2025-02-04 19:32:33 -06:00
</PageContent>
2023-02-17 18:02:01 -06:00
@code {
2025-01-25 01:57:17 -06:00
string RootPath = Path.GetPathRoot(Directory.GetCurrentDirectory());
2023-02-17 18:02:01 -06:00
void Save()
2023-02-17 18:02:01 -06:00
{
try
{
SettingsProvider.Update(s =>
{
s.Server.Http = Settings.Value.Server.Http;
});
MessageService.Success("Settings saved!");
2023-02-17 18:02:01 -06:00
}
2024-07-07 16:33:46 -05:00
catch (Exception ex)
2023-02-17 18:02:01 -06:00
{
MessageService.Error("An unknown error occurred.");
2024-07-07 16:33:46 -05:00
Logger.LogError(ex, "An unknown error occurred.");
2023-02-17 18:02:01 -06:00
}
}
}