From 243d23d4e219aa5ceff466ac9b26768cce32f314 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 2 Jul 2023 20:40:47 +0200 Subject: [PATCH 1/7] Fixed repatcha config for empty values --- Moonlight/App/Configuration/ConfigV1.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moonlight/App/Configuration/ConfigV1.cs b/Moonlight/App/Configuration/ConfigV1.cs index 7836b7cb..67224fd2 100644 --- a/Moonlight/App/Configuration/ConfigV1.cs +++ b/Moonlight/App/Configuration/ConfigV1.cs @@ -174,7 +174,7 @@ public class ConfigV1 { [JsonProperty("Token")] public string Token { get; set; } = Guid.NewGuid().ToString(); - [JsonProperty("ReCaptcha")] public ReCaptchaData ReCaptcha { get; set; } + [JsonProperty("ReCaptcha")] public ReCaptchaData ReCaptcha { get; set; } = new(); } public class ReCaptchaData From 1aab86a317d666ffbbe1849f57017f4b58b7292d Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 2 Jul 2023 20:41:31 +0200 Subject: [PATCH 2/7] Fixed wrong ssl config for nodes --- Moonlight/Shared/Views/Admin/Nodes/Setup.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moonlight/Shared/Views/Admin/Nodes/Setup.razor b/Moonlight/Shared/Views/Admin/Nodes/Setup.razor index d3ae6c11..1296259e 100644 --- a/Moonlight/Shared/Views/Admin/Nodes/Setup.razor +++ b/Moonlight/Shared/Views/Admin/Nodes/Setup.razor @@ -40,7 +40,7 @@   host: 0.0.0.0
  port: @(Node.HttpPort)
  ssl:
-     enabled: false
+     enabled: @(Node.Ssl ? "true" : "false")
    cert: /etc/letsencrypt/live/@(Node.Fqdn)/fullchain.pem
    key: /etc/letsencrypt/live/@(Node.Fqdn)/privkey.pem
  disable_remote_download: false
From fe21668a2bc034fe99ede2b8cb8064c53bbdaadf Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 2 Jul 2023 20:44:29 +0200 Subject: [PATCH 3/7] Removed wrong logged warn --- Moonlight/App/Services/Statistics/StatisticsCaptureService.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Moonlight/App/Services/Statistics/StatisticsCaptureService.cs b/Moonlight/App/Services/Statistics/StatisticsCaptureService.cs index 39f341e9..28333f48 100644 --- a/Moonlight/App/Services/Statistics/StatisticsCaptureService.cs +++ b/Moonlight/App/Services/Statistics/StatisticsCaptureService.cs @@ -36,8 +36,6 @@ public class StatisticsCaptureService { while (await Timer.WaitForNextTickAsync()) { - Logger.Warn("Creating statistics"); - using var scope = ServiceScopeFactory.CreateScope(); var statisticsRepo = scope.ServiceProvider.GetRequiredService>(); From 016f50fb1c19379a664366278d2eab7304981e80 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 2 Jul 2023 20:48:47 +0200 Subject: [PATCH 4/7] Added ignore for json serialize errors --- Moonlight/App/Helpers/Wings/WingsConsole.cs | 1 + Moonlight/Program.cs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Moonlight/App/Helpers/Wings/WingsConsole.cs b/Moonlight/App/Helpers/Wings/WingsConsole.cs index d1efb9bc..9767e540 100644 --- a/Moonlight/App/Helpers/Wings/WingsConsole.cs +++ b/Moonlight/App/Helpers/Wings/WingsConsole.cs @@ -243,6 +243,7 @@ public class WingsConsole : IDisposable } } catch(JsonReaderException){} + catch(JsonSerializationException){} catch (Exception e) { if (!Disconnecting) diff --git a/Moonlight/Program.cs b/Moonlight/Program.cs index 223e2f26..cc18c698 100644 --- a/Moonlight/Program.cs +++ b/Moonlight/Program.cs @@ -32,7 +32,6 @@ using Moonlight.App.Services.SupportChat; using Sentry; using Serilog; using Serilog.Events; -using Serilog.Sinks.SystemConsole.Themes; namespace Moonlight { From 5e592ccdcb5ac8b68d529025140b7092453d106a Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 2 Jul 2023 20:51:08 +0200 Subject: [PATCH 5/7] Added ignore for unexpected dispose errors --- Moonlight/Shared/Components/Xterm/Terminal.razor | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Moonlight/Shared/Components/Xterm/Terminal.razor b/Moonlight/Shared/Components/Xterm/Terminal.razor index 16ee2bbc..e47426e7 100644 --- a/Moonlight/Shared/Components/Xterm/Terminal.razor +++ b/Moonlight/Shared/Components/Xterm/Terminal.razor @@ -39,7 +39,15 @@ public async void Dispose() { - await Xterm.DisposeAsync(); + try + { + await Xterm.DisposeAsync(); + } + catch (Exception) + { + // ignore dispose errors. They occur when the tab closes unexpectedly + // so we can ignore them + } } private async void OnFirstRender() From 7f2da5a55ded961be39098411169b1253ad28905 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 2 Jul 2023 20:56:10 +0200 Subject: [PATCH 6/7] Updated sweet alert 2 --- Moonlight/Moonlight.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moonlight/Moonlight.csproj b/Moonlight/Moonlight.csproj index 1ffe3145..cc520db6 100644 --- a/Moonlight/Moonlight.csproj +++ b/Moonlight/Moonlight.csproj @@ -18,7 +18,7 @@ - + From d418c91efab4fa44c0d6435f042be643091f0b30 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 2 Jul 2023 21:30:34 +0200 Subject: [PATCH 7/7] Fixed js invoke errors --- .../App/Services/Interop/AlertService.cs | 47 +++++++++++++++---- Moonlight/Program.cs | 1 - Moonlight/Shared/Layouts/MainLayout.razor | 8 ++-- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/Moonlight/App/Services/Interop/AlertService.cs b/Moonlight/App/Services/Interop/AlertService.cs index 24a15fa4..a5cad8f1 100644 --- a/Moonlight/App/Services/Interop/AlertService.cs +++ b/Moonlight/App/Services/Interop/AlertService.cs @@ -1,21 +1,40 @@ using CurrieTechnologies.Razor.SweetAlert2; +using Microsoft.JSInterop; namespace Moonlight.App.Services.Interop; public class AlertService { - private readonly SweetAlertService SweetAlertService; private readonly SmartTranslateService SmartTranslateService; + private readonly IJSRuntime JsRuntime; + private SweetAlertService? SweetAlertService; - public AlertService(SweetAlertService service, SmartTranslateService smartTranslateService) + public AlertService(SmartTranslateService smartTranslateService, IJSRuntime jsRuntime) { - SweetAlertService = service; SmartTranslateService = smartTranslateService; + JsRuntime = jsRuntime; + } + + // We create the swal service here and not using the dependency injection + // because it initializes when instantiated which leads to js invoke errors + private Task EnsureService() + { + if (SweetAlertService == null) + { + SweetAlertService = new(JsRuntime, new() + { + Theme = SweetAlertTheme.Dark + }); + } + + return Task.CompletedTask; } public async Task Info(string title, string desciption) { - await SweetAlertService.FireAsync(new SweetAlertOptions() + await EnsureService(); + + await SweetAlertService!.FireAsync(new SweetAlertOptions() { Title = title, Text = desciption, @@ -30,7 +49,9 @@ public class AlertService public async Task Success(string title, string desciption) { - await SweetAlertService.FireAsync(new SweetAlertOptions() + await EnsureService(); + + await SweetAlertService!.FireAsync(new SweetAlertOptions() { Title = title, Text = desciption, @@ -45,7 +66,9 @@ public class AlertService public async Task Warning(string title, string desciption) { - await SweetAlertService.FireAsync(new SweetAlertOptions() + await EnsureService(); + + await SweetAlertService!.FireAsync(new SweetAlertOptions() { Title = title, Text = desciption, @@ -60,7 +83,9 @@ public class AlertService public async Task Error(string title, string desciption) { - await SweetAlertService.FireAsync(new SweetAlertOptions() + await EnsureService(); + + await SweetAlertService!.FireAsync(new SweetAlertOptions() { Title = title, Text = desciption, @@ -75,7 +100,9 @@ public class AlertService public async Task YesNo(string title, string desciption, string yesText, string noText) { - var result = await SweetAlertService.FireAsync(new SweetAlertOptions() + await EnsureService(); + + var result = await SweetAlertService!.FireAsync(new SweetAlertOptions() { Title = title, Text = desciption, @@ -91,7 +118,9 @@ public class AlertService public async Task Text(string title, string desciption, string setValue) { - var result = await SweetAlertService.FireAsync(new SweetAlertOptions() + await EnsureService(); + + var result = await SweetAlertService!.FireAsync(new SweetAlertOptions() { Title = title, Text = desciption, diff --git a/Moonlight/Program.cs b/Moonlight/Program.cs index cc18c698..d78d7967 100644 --- a/Moonlight/Program.cs +++ b/Moonlight/Program.cs @@ -248,7 +248,6 @@ namespace Moonlight // Third party services builder.Services.AddBlazorTable(); - builder.Services.AddSweetAlert2(options => { options.Theme = SweetAlertTheme.Dark; }); builder.Services.AddBlazorContextMenu(); builder.Services.AddBlazorDownloadFile(); diff --git a/Moonlight/Shared/Layouts/MainLayout.razor b/Moonlight/Shared/Layouts/MainLayout.razor index 040186ad..8eac6b55 100644 --- a/Moonlight/Shared/Layouts/MainLayout.razor +++ b/Moonlight/Shared/Layouts/MainLayout.razor @@ -163,13 +163,11 @@ private bool IsIpBanned = false; - protected override void OnInitialized() - { - AddBodyAttribute("data-kt-app-page-loading", "on"); - } - protected override void OnAfterRender(bool firstRender) { + if(firstRender) + AddBodyAttribute("data-kt-app-page-loading", "on"); + //Initialize classes and attributes for layout with dark sidebar AddBodyAttribute("data-kt-app-reset-transition", "true");