2025-02-04 18:45:24 -06:00
|
|
|
@page "/Settings/Scripts"
|
|
|
|
|
@using LANCommander.SDK.Enums
|
2025-11-16 12:31:25 -06:00
|
|
|
@using LANCommander.Server.Settings
|
|
|
|
|
@using Microsoft.Extensions.Options
|
2025-08-02 00:22:16 -05:00
|
|
|
@inject MessageService MessageService
|
|
|
|
|
@inject ILogger<Scripts> Logger
|
2025-11-16 12:31:25 -06:00
|
|
|
@inject IOptions<Settings> Settings
|
|
|
|
|
@inject SettingsProvider<Settings> SettingsProvider
|
2025-02-04 18:45:24 -06:00
|
|
|
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
|
|
|
|
|
|
|
|
|
|
<PageHeader Title="Scripts" />
|
|
|
|
|
|
2025-02-04 19:32:33 -06:00
|
|
|
<PageContent>
|
2025-11-16 12:31:25 -06:00
|
|
|
<Form Model="Settings.Value" Layout="@FormLayout.Vertical">
|
2025-08-02 00:22:16 -05:00
|
|
|
<FormItem Label="Automatically Repackage">
|
2025-11-16 12:31:25 -06:00
|
|
|
<Switch @bind-Checked="context.Server.Scripts.EnableAutomaticRepackaging" />
|
2025-08-02 00:22:16 -05:00
|
|
|
</FormItem>
|
|
|
|
|
<FormItem Label="Repackage Every">
|
|
|
|
|
<Flex Direction="FlexDirection.Horizontal">
|
2025-11-16 12:31:25 -06:00
|
|
|
<AntDesign.InputNumber @bind-Value="context.Server.Scripts.RepackageEvery" Min="1" DefaultValue="25" />
|
2025-08-02 00:22:16 -05:00
|
|
|
<Text>Hours</Text>
|
|
|
|
|
</Flex>
|
|
|
|
|
</FormItem>
|
|
|
|
|
|
|
|
|
|
<FormItem>
|
|
|
|
|
<Button OnClick="Save" Type="@ButtonType.Primary">Save</Button>
|
|
|
|
|
</FormItem>
|
|
|
|
|
</Form>
|
|
|
|
|
|
|
|
|
|
<ScriptEditor AllowedTypes="new[] { ScriptType.UserLogin, ScriptType.UserRegistration }"/>
|
|
|
|
|
</PageContent>
|
|
|
|
|
|
|
|
|
|
@code {
|
|
|
|
|
void Save()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2025-11-16 12:31:25 -06:00
|
|
|
SettingsProvider.Update(s =>
|
|
|
|
|
{
|
|
|
|
|
s.Server.Scripts = Settings.Value.Server.Scripts;
|
|
|
|
|
});
|
|
|
|
|
|
2025-08-02 00:22:16 -05:00
|
|
|
MessageService.Success("Settings saved!");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageService.Error("An unknown error occurred.");
|
|
|
|
|
Logger.LogError(ex, "An unknown error occurred.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|