diff --git a/Moonlight/Features/Servers/Helpers/ServerConsole.cs b/Moonlight/Features/Servers/Helpers/ServerConsole.cs index c116526..cd10375 100644 --- a/Moonlight/Features/Servers/Helpers/ServerConsole.cs +++ b/Moonlight/Features/Servers/Helpers/ServerConsole.cs @@ -99,9 +99,11 @@ public class ServerConsole : IDisposable } catch (Exception e) { - if (e is not WebSocketException) + if (e is WebSocketException) + Logger.Warn($"Lost connection to daemon server websocket: {e.Message}"); + else { - Logger.Warn("Lost connection to daemon server websocket"); + Logger.Warn("Server console ws disconnected because of application error:"); Logger.Warn(e); } diff --git a/Moonlight/Features/Servers/UI/Layouts/UserLayout.razor b/Moonlight/Features/Servers/UI/Layouts/UserLayout.razor index 014d92a..815e9df 100644 --- a/Moonlight/Features/Servers/UI/Layouts/UserLayout.razor +++ b/Moonlight/Features/Servers/UI/Layouts/UserLayout.razor @@ -113,13 +113,7 @@
- @if (IsInstalling) - { -
- -
- } - else if (IsConsoleDisconnected) + @if (IsConsoleDisconnected) { We lost the connection to the server. Please refresh the page in order to retry. If this error persists please contact the support @@ -137,6 +131,12 @@ The node this server is on is still booting. Please refresh the page in order to retry. If this error persists please contact the support } + else if (IsInstalling) + { +
+ +
+ } else { @@ -217,37 +217,7 @@ Console = new ServerConsole(Server); // Configure - Console.OnStateChange += async state => - { - // General rerender to update the state text in the ui - // NOTE: Obsolete because of the update timer - //await InvokeAsync(StateHasChanged); - - // Change from offline to installing - // This will trigger the initialisation of the install view - if (state == ServerState.Installing && !IsInstalling) - { - IsInstalling = true; - - // After this call, we should have access to the install terminal reference - await InvokeAsync(StateHasChanged); - - Console.OnNewMessage += OnInstallConsoleMessage; - } - // Change from installing to offline - // This will trigger the destruction of the install view - else if (state == ServerState.Offline && IsInstalling) - { - IsInstalling = false; - - Console.OnNewMessage -= OnInstallConsoleMessage; - - // After this call, the install terminal will disappear - await InvokeAsync(StateHasChanged); - - await ToastService.Info("Server installation complete"); - } - }; + Console.OnStateChange += async state => await HandleStateChange(state); Console.OnDisconnected += async () => { @@ -267,7 +237,7 @@ await InvokeAsync(StateHasChanged); return; } - + // We want to check if its an connection error, if yes we want to show the user that its an error with the connection // If not we proceed with the throwing for the soft error handler. @@ -288,6 +258,41 @@ } UpdateTimer = new Timer(async _ => { await InvokeAsync(StateHasChanged); }, null, TimeSpan.Zero, TimeSpan.FromSeconds(1)); + + var state = await ServerService.GetState(Server); + await HandleStateChange(state); + } + + private async Task HandleStateChange(ServerState state) + { + // General rerender to update the state text in the ui + // NOTE: Obsolete because of the update timer + //await InvokeAsync(StateHasChanged); + + // Change from offline to installing + // This will trigger the initialisation of the install view + if (state == ServerState.Installing && !IsInstalling) + { + IsInstalling = true; + + // After this call, we should have access to the install terminal reference + await InvokeAsync(StateHasChanged); + + Console.OnNewMessage += OnInstallConsoleMessage; + } + // Change from installing to offline + // This will trigger the destruction of the install view + else if (state == ServerState.Offline && IsInstalling) + { + IsInstalling = false; + + Console.OnNewMessage -= OnInstallConsoleMessage; + + // After this call, the install terminal will disappear + await InvokeAsync(StateHasChanged); + + await ToastService.Info("Server installation complete"); + } } private async Task OnInstallConsoleMessage(string message) @@ -334,7 +339,7 @@ case "/network": return 2; - + case "/schedules": return 7; diff --git a/Moonlight/Moonlight.csproj b/Moonlight/Moonlight.csproj index e37cfbe..df200a7 100644 --- a/Moonlight/Moonlight.csproj +++ b/Moonlight/Moonlight.csproj @@ -74,8 +74,7 @@ - - + @@ -114,6 +113,7 @@ <_ContentIncludedByDefault Remove="Features\FileManager\UI\Components\FileManager.razor" /> <_ContentIncludedByDefault Remove="Features\FileManager\UI\Components\FileUploader.razor" /> <_ContentIncludedByDefault Remove="Features\FileManager\UI\Components\FileView.razor" /> + <_ContentIncludedByDefault Remove="storage\configs\core.json" />