@page "/Settings/Servers" @using LANCommander.Server.UI.Pages.Settings.Components @inject IMessageService MessageService @inject ILogger Logger @attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
@code { Settings Settings = SettingService.GetSettings(); string RootPath = Path.GetPathRoot(Directory.GetCurrentDirectory()); void Save() { try { var settings = SettingService.GetSettings(); settings.Servers = Settings.Servers; SettingService.SaveSettings(settings); MessageService.Success("Settings saved!"); } catch (Exception ex) { MessageService.Error("An unknown error occurred."); Logger.LogError(ex, "An unknown error occurred."); } } void OnPathSelected(string path) { 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; } }