2023-10-30 18:45:11 -05:00
@page "/Settings/Beacon"
2025-04-25 00:59:13 -05:00
@using LANCommander.SDK
@inject Client Client
2023-10-30 18:45:11 -05:00
@inject IMessageService MessageService
2024-07-07 16:33:46 -05:00
@inject ILogger<Beacon> Logger
2024-10-16 02:06:02 -05:00
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
2023-10-30 18:45:11 -05:00
<PageHeader Title="Beacon" />
2025-02-04 19:32:33 -06:00
<PageContent>
2023-10-30 18:45:11 -05:00
<Form Model="Settings" Layout="@FormLayout.Vertical">
<FormItem Label="Enable">
<Text Type="@TextElementType.Secondary">Enabling the beacon will allow clients on the same network to auto-discover the LANCommander address.</Text>
<Switch @bind-Checked="context.Beacon.Enabled" />
</FormItem>
2024-08-26 21:29:25 -05:00
<FormItem Label="Name">
<Text Type="@TextElementType.Secondary">Use this to customize the name that is broadcasted to clients.</Text>
<Input @bind-Value="Settings.Beacon.Name" />
</FormItem>
2023-10-30 18:45:11 -05:00
<FormItem Label="Address">
<Text Type="@TextElementType.Secondary">Use this to customize the address that is broadcasted to clients. Default: http://<Server IP>:@context.Port</Text>
<Input @bind-Value="Settings.Beacon.Address" />
</FormItem>
<FormItem>
<Button OnClick="Save" Type="@ButtonType.Primary">Save</Button>
</FormItem>
</Form>
2025-02-04 19:32:33 -06:00
</PageContent>
2023-10-30 18:45:11 -05:00
@code {
2024-11-22 02:04:04 -06:00
Settings Settings = SettingService.GetSettings();
2023-10-30 18:45:11 -05:00
2025-04-25 00:59:13 -05:00
async Task Save()
2023-10-30 18:45:11 -05:00
{
try
{
SettingService.SaveSettings(Settings);
MessageService.Success("Settings saved!");
2025-04-25 00:59:13 -05:00
if (Settings.Beacon.Enabled)
await Client.Beacon.StartBeaconAsync(Settings.Beacon.Port, Settings.Beacon.Address, Settings.Beacon.Name);
else
await Client.Beacon.StopBeaconAsync();
2023-10-30 18:45:11 -05:00
}
2024-07-07 16:33:46 -05:00
catch (Exception ex)
2023-10-30 18:45:11 -05:00
{
MessageService.Error("An unknown error occurred.");
2024-07-07 16:33:46 -05:00
Logger.LogError(ex, "An unknown error occurred.");
2023-10-30 18:45:11 -05:00
}
}
}