From ccec79cca7d355493b6054fbc62f8a02d866d27c Mon Sep 17 00:00:00 2001 From: Moritz <101179677+Moritz-Deiaco@users.noreply.github.com> Date: Sun, 19 May 2024 00:04:27 +0200 Subject: [PATCH 1/5] Added node online check on Server create --- .../Features/Servers/Services/ServerService.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Moonlight/Features/Servers/Services/ServerService.cs b/Moonlight/Features/Servers/Services/ServerService.cs index 135f1109..6dc8dabc 100644 --- a/Moonlight/Features/Servers/Services/ServerService.cs +++ b/Moonlight/Features/Servers/Services/ServerService.cs @@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore; using MoonCore.Abstractions; using MoonCore.Attributes; using MoonCore.Exceptions; +using MoonCore.Helpers; using MoonCore.Services; using Moonlight.Core.Configuration; using Moonlight.Core.Database.Entities; @@ -22,6 +23,8 @@ public class ServerService public ServerConsoleService Console => ServiceProvider.GetRequiredService(); public ServerBackupService Backup => ServiceProvider.GetRequiredService(); public ServerScheduleService Schedule => ServiceProvider.GetRequiredService(); + + public NodeService NodeService => ServiceProvider.GetRequiredService(); private readonly IServiceProvider ServiceProvider; @@ -74,6 +77,19 @@ public class ServerService // Load node var node = nodeRepo.Get().First(x => x.Id == form.Node.Id); + // Check if node is available + try + { + await NodeService.GetStatus(node); + } + catch (Exception e) + { + Logger.Warn($"Could not establish to the node with the id {node.Id}"); + Logger.Warn(e); + + throw new DisplayException($"Could not establish connection to the node: {e.Message}"); + } + // Load user var user = userRepo.Get().First(x => x.Id == form.Owner.Id); From 4f5a4913d7005476428eb8b2d16e629065c9c48d Mon Sep 17 00:00:00 2001 From: Masu Baumgartner Date: Mon, 27 May 2024 14:32:16 +0200 Subject: [PATCH 2/5] Upgraded moonlight to dotnet 8 --- Moonlight/Dockerfile | 4 ++-- Moonlight/Moonlight.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Moonlight/Dockerfile b/Moonlight/Dockerfile index b5f1c6b1..b2c6537a 100644 --- a/Moonlight/Dockerfile +++ b/Moonlight/Dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base WORKDIR /app EXPOSE 80 EXPOSE 443 -FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["Moonlight/Moonlight.csproj", "Moonlight/"] diff --git a/Moonlight/Moonlight.csproj b/Moonlight/Moonlight.csproj index 94c9911c..6f369f1d 100644 --- a/Moonlight/Moonlight.csproj +++ b/Moonlight/Moonlight.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 enable enable Linux From 96a906b71759c34f975ced8a9b23ab943b9098ce Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Thu, 30 May 2024 18:15:39 +0200 Subject: [PATCH 3/5] Removed test pages --- Moonlight/Core/UI/Views/Test.razor | 160 ---------------------------- Moonlight/Core/UI/Views/Testy.razor | 110 ------------------- 2 files changed, 270 deletions(-) delete mode 100644 Moonlight/Core/UI/Views/Test.razor delete mode 100644 Moonlight/Core/UI/Views/Testy.razor diff --git a/Moonlight/Core/UI/Views/Test.razor b/Moonlight/Core/UI/Views/Test.razor deleted file mode 100644 index b30dcaf3..00000000 --- a/Moonlight/Core/UI/Views/Test.razor +++ /dev/null @@ -1,160 +0,0 @@ -@page "/test" - -
-
-
-
- - - - -
-
-
-
-
- - - -
- -
-
-
-
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - @for (var i = 1; i <= 10; i++) - { - - - - - - - - - } - - -
-
- -
-
IdEmailUsernameCreated at
-
- -
-
@(i)admin@masuowo.xyz@(i)masuowo@(i)04/19/2024 12:48:35 -
- Edit -
-
-
-
-
- Showing 13 of 100 results -
-
-
- Per page - -
-
-
-
    - -
  • 1
  • -
  • 2
  • -
  • 3
  • - -
-
-
-
-
- -@* -
- -
- -
- -
- -
- Please choose a username. -
-
*@ - - - -@code -{ - private async Task Do() - { - await Task.Delay(5000); - } -} diff --git a/Moonlight/Core/UI/Views/Testy.razor b/Moonlight/Core/UI/Views/Testy.razor deleted file mode 100644 index 5a24759a..00000000 --- a/Moonlight/Core/UI/Views/Testy.razor +++ /dev/null @@ -1,110 +0,0 @@ -@page "/testy" - -
-
- - - Back - - - -
-
- -
-
-
-
- - -
- dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh -
-
- -
- - -
- dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh -
-
- -
- - -
- dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh -
-
- -
- -
- - - -
-
- dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh -
-
-
-
-
- -
-
-
- - Some Section -
-
-
-
-
- - -
- dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh -
-
- -
- - -
- dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh -
-
- -
- -
- - - -
-
- dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh -
-
-
-
-
\ No newline at end of file From b5119b6be15859b759f1767098c5d252ed9aa4f0 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Thu, 30 May 2024 18:27:36 +0200 Subject: [PATCH 4/5] Fixed server creation allocation loading --- .../Servers/UI/Views/Admin/Index.razor | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Moonlight/Features/Servers/UI/Views/Admin/Index.razor b/Moonlight/Features/Servers/UI/Views/Admin/Index.razor index f8dac37c..c8f71e4e 100644 --- a/Moonlight/Features/Servers/UI/Views/Admin/Index.razor +++ b/Moonlight/Features/Servers/UI/Views/Admin/Index.razor @@ -68,14 +68,23 @@ .Include(x => x.Node); } - private IEnumerable LoadFreeAllocations(Repository repository, Server currentServer) + private IEnumerable LoadFreeAllocations(Repository repository, Server? currentServer) { - return currentServer.Allocations.Concat( - repository + if (currentServer == null) + { + return repository .Get() - .FromSqlRaw($"SELECT * FROM `ServerAllocations` WHERE ServerId IS NULL AND ServerNodeId = {currentServer.Node.Id}") - .AsEnumerable() // => executes the sql - ); + .FromSqlRaw("SELECT * FROM `ServerAllocations` WHERE ServerId IS NULL"); + } + else + { + return currentServer.Allocations.Concat( + repository + .Get() + .FromSqlRaw($"SELECT * FROM `ServerAllocations` WHERE ServerId IS NULL AND ServerNodeId = {currentServer.Node.Id}") + .AsEnumerable() // => executes the sql + ); + } } private async Task CustomAdd(Server form) => await ServerService.Create(form); From d62af84dfdbaf36d89b2e8bb9bdaf97c2e30191a Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Thu, 30 May 2024 19:01:44 +0200 Subject: [PATCH 5/5] Upgraded to MoonCoreUI 1.1.9 --- Moonlight/Moonlight.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moonlight/Moonlight.csproj b/Moonlight/Moonlight.csproj index 0c374438..f6281a36 100644 --- a/Moonlight/Moonlight.csproj +++ b/Moonlight/Moonlight.csproj @@ -92,7 +92,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - +