@page "/Settings/Integrations/Steam" @using LANCommander.Server.Services.Enums @using LANCommander.Server.UI.Pages.Settings.Components @inject SteamCMDService SteamCmdService @inject IMessageService MessageService @inject ILogger Logger @attribute [Authorize(Roles = RoleService.AdministratorRoleName)]

Profiles

@foreach (var profile in _settings.SteamCMD.Profiles) {
@code { Settings _settings = SettingService.GetSettings(); string _rootPath = Path.GetPathRoot(Directory.GetCurrentDirectory()); SteamCmdConnectionStatus _connectionStatus; string _username; string _password; bool _processingLogin; protected override async Task OnInitializedAsync() { if (!_settings.SteamCMD.Profiles.Any()) AddProfile(); } void AddProfile() { _settings.SteamCMD.Profiles.Add(new SteamCmdProfile()); } async Task RemoveProfile(SteamCmdProfile profile) { _settings.SteamCMD.Profiles.Remove(profile); if (!String.IsNullOrWhiteSpace(profile.Username)) { var logoutMessage = new MessageConfig { Content = "Logging out of Steam...", Duration = 0, Key = Guid.NewGuid().ToString() }; MessageService.Loading(logoutMessage); await SteamCmdService.LogoutAsync(profile.Username); logoutMessage.Content = "Successfully logged out from Steam!"; logoutMessage.Duration = 3; MessageService.Success(logoutMessage); } if (!_settings.SteamCMD.Profiles.Any()) AddProfile(); } async Task Save() { try { _settings.SteamCMD.Profiles = _settings.SteamCMD.Profiles.Where(p => !String.IsNullOrWhiteSpace(p.Username)).ToList(); SettingService.SaveSettings(_settings); MessageService.Success("Settings saved!"); } catch (Exception ex) { MessageService.Error("An unknown error occurred."); Logger.LogError(ex, "An unknown error occurred."); } } }