@page "/Settings/Launcher" @using LANCommander.Server.Jobs.Background @using LANCommander.Server.Settings @using LANCommander.Server.Settings.Enums @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.Launcher = Settings.Value.Server.Launcher; }); 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.Launcher.StoragePath = path; } async Task DownloadLaunchers() { Hangfire.BackgroundJob.Enqueue(x => x.ExecuteAsync()); MessageService.Success("Launchers will be downloaded in the background!"); } }