@page "/Settings/Servers" @using LANCommander.Server.Settings @using LANCommander.Server.UI.Pages.Settings.Components @using Microsoft.Extensions.Options @inject IMessageService MessageService @inject ILogger Logger @inject IOptions Settings @inject SettingsProvider SettingsProvider @attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
@code { string RootPath = Path.GetPathRoot(Directory.GetCurrentDirectory()); void Save() { try { SettingsProvider.Update(s => { s.Server.GameServers = Settings.Value.Server.GameServers; }); 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.Value.Server.GameServers.StoragePath = path; } }