54 lines
1.9 KiB
Text
54 lines
1.9 KiB
Text
@page "/Settings/Beacon"
|
|
@using LANCommander.SDK
|
|
@inject Client Client
|
|
@inject IMessageService MessageService
|
|
@inject ILogger<Beacon> Logger
|
|
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
|
|
|
|
<PageHeader Title="Beacon" />
|
|
|
|
<PageContent>
|
|
<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>
|
|
|
|
<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>
|
|
|
|
<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>
|
|
</PageContent>
|
|
|
|
@code {
|
|
Settings Settings = SettingService.GetSettings();
|
|
|
|
async Task Save()
|
|
{
|
|
try
|
|
{
|
|
SettingService.SaveSettings(Settings);
|
|
MessageService.Success("Settings saved!");
|
|
|
|
if (Settings.Beacon.Enabled)
|
|
await Client.Beacon.StartBeaconAsync(Settings.Beacon.Port, Settings.Beacon.Address, Settings.Beacon.Name);
|
|
else
|
|
await Client.Beacon.StopBeaconAsync();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageService.Error("An unknown error occurred.");
|
|
Logger.LogError(ex, "An unknown error occurred.");
|
|
}
|
|
}
|
|
}
|