2024-07-04 16:34:30 -05:00
|
|
|
@page "/Settings/Servers"
|
2025-03-23 20:19:18 -05:00
|
|
|
@using LANCommander.Server.UI.Pages.Settings.Components
|
2024-07-04 16:34:30 -05:00
|
|
|
@inject IMessageService MessageService
|
2024-07-07 16:33:46 -05:00
|
|
|
@inject ILogger<Servers> Logger
|
2024-10-16 02:06:02 -05:00
|
|
|
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
|
2024-07-04 16:34:30 -05:00
|
|
|
|
2025-03-23 20:19:18 -05:00
|
|
|
<PageHeader Title="Servers">
|
|
|
|
|
<PageHeaderExtra>
|
|
|
|
|
<Button OnClick="Save" Type="@ButtonType.Primary">Save</Button>
|
|
|
|
|
</PageHeaderExtra>
|
|
|
|
|
</PageHeader>
|
2024-07-04 16:34:30 -05:00
|
|
|
|
2025-02-04 19:32:33 -06:00
|
|
|
<PageContent>
|
2024-07-04 16:34:30 -05:00
|
|
|
<Form Model="Settings" Layout="@FormLayout.Vertical">
|
|
|
|
|
<FormItem Label="Storage Path">
|
|
|
|
|
<FilePicker Root="@RootPath" EntrySelectable="x => x is FileManagerDirectory" @bind-Value="@context.Servers.StoragePath" OkText="Select Path" Title="Choose Path" OnSelected="OnPathSelected" />
|
|
|
|
|
</FormItem>
|
|
|
|
|
</Form>
|
2025-03-23 20:19:18 -05:00
|
|
|
|
|
|
|
|
<Divider Text="Docker Hosts" />
|
|
|
|
|
|
2025-03-25 18:07:03 -05:00
|
|
|
<ServerEngineEditor @bind-Values="Settings.Servers.ServerEngines" />
|
2025-02-04 19:32:33 -06:00
|
|
|
</PageContent>
|
2024-07-04 16:34:30 -05:00
|
|
|
|
|
|
|
|
@code {
|
2024-11-22 02:04:04 -06:00
|
|
|
Settings Settings = SettingService.GetSettings();
|
2024-07-04 16:34:30 -05:00
|
|
|
|
|
|
|
|
string RootPath = Path.GetPathRoot(Directory.GetCurrentDirectory());
|
|
|
|
|
|
2024-11-22 02:04:04 -06:00
|
|
|
void Save()
|
2024-07-04 16:34:30 -05:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2025-03-23 20:19:18 -05:00
|
|
|
var settings = SettingService.GetSettings();
|
|
|
|
|
|
|
|
|
|
settings.Servers = Settings.Servers;
|
|
|
|
|
|
|
|
|
|
SettingService.SaveSettings(settings);
|
|
|
|
|
|
2024-07-04 16:34:30 -05:00
|
|
|
MessageService.Success("Settings saved!");
|
|
|
|
|
}
|
2024-07-07 16:33:46 -05:00
|
|
|
catch (Exception ex)
|
2024-07-04 16:34:30 -05:00
|
|
|
{
|
|
|
|
|
MessageService.Error("An unknown error occurred.");
|
2024-07-07 16:33:46 -05:00
|
|
|
Logger.LogError(ex, "An unknown error occurred.");
|
2024-07-04 16:34:30 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-22 02:05:44 -06:00
|
|
|
void OnPathSelected(string path)
|
2024-07-04 16:34:30 -05:00
|
|
|
{
|
|
|
|
|
var appPath = Directory.GetCurrentDirectory();
|
|
|
|
|
|
|
|
|
|
if (path != null && path.StartsWith(appPath))
|
|
|
|
|
path = path.Substring(appPath.Length).TrimStart(Path.DirectorySeparatorChar).TrimEnd(Path.DirectorySeparatorChar);
|
|
|
|
|
|
|
|
|
|
Settings.Servers.StoragePath = path;
|
|
|
|
|
}
|
|
|
|
|
}
|