Merge pull request #206 from Moonlight-Panel/SmallFixes

Small fixes
This commit is contained in:
Marcel Baumgartner
2023-07-02 21:33:12 +02:00
committed by GitHub
9 changed files with 54 additions and 22 deletions

View File

@@ -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

View File

@@ -243,6 +243,7 @@ public class WingsConsole : IDisposable
}
}
catch(JsonReaderException){}
catch(JsonSerializationException){}
catch (Exception e)
{
if (!Disconnecting)

View File

@@ -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<bool> 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<string?> 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,

View File

@@ -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<Repository<StatisticsData>>();

View File

@@ -18,7 +18,7 @@
<PackageReference Include="BlazorMonaco" Version="2.1.0" />
<PackageReference Include="BlazorTable" Version="1.17.0" />
<PackageReference Include="CloudFlare.Client" Version="6.1.4" />
<PackageReference Include="CurrieTechnologies.Razor.SweetAlert2" Version="5.4.0" />
<PackageReference Include="CurrieTechnologies.Razor.SweetAlert2" Version="5.5.0" />
<PackageReference Include="Discord.Net" Version="3.10.0" />
<PackageReference Include="Discord.Net.Webhook" Version="3.10.0" />
<PackageReference Include="DnsClient" Version="1.7.0" />

View File

@@ -32,7 +32,6 @@ using Moonlight.App.Services.SupportChat;
using Sentry;
using Serilog;
using Serilog.Events;
using Serilog.Sinks.SystemConsole.Themes;
namespace Moonlight
{
@@ -249,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();

View File

@@ -38,9 +38,17 @@
}
public async void Dispose()
{
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()
{

View File

@@ -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");

View File

@@ -40,7 +40,7 @@
&nbsp;&nbsp;host: 0.0.0.0<br/>
&nbsp;&nbsp;port: @(Node.HttpPort)<br/>
&nbsp;&nbsp;ssl:<br/>
&nbsp;&nbsp;&nbsp;&nbsp;enabled: false<br/>
&nbsp;&nbsp;&nbsp;&nbsp;enabled: @(Node.Ssl ? "true" : "false")<br/>
&nbsp;&nbsp;&nbsp;&nbsp;cert: /etc/letsencrypt/live/@(Node.Fqdn)/fullchain.pem<br/>
&nbsp;&nbsp;&nbsp;&nbsp;key: /etc/letsencrypt/live/@(Node.Fqdn)/privkey.pem<br/>
&nbsp;&nbsp;disable_remote_download: false<br/>