From 80290564d0410d7de52fab227b35de30c5b11805 Mon Sep 17 00:00:00 2001 From: Masu-Baumgartner <68913099+Masu-Baumgartner@users.noreply.github.com> Date: Wed, 11 Sep 2024 17:04:00 +0200 Subject: [PATCH] Added connection exception handling to node status and added error detail view in node overview --- .../Controllers/Admin/Nodes/NodesController.cs | 15 ++++++++++++++- .../UI/Views/Admin/Nodes.razor | 17 +++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/MoonlightServers.ApiServer/Http/Controllers/Admin/Nodes/NodesController.cs b/MoonlightServers.ApiServer/Http/Controllers/Admin/Nodes/NodesController.cs index 96158b7..f47a953 100644 --- a/MoonlightServers.ApiServer/Http/Controllers/Admin/Nodes/NodesController.cs +++ b/MoonlightServers.ApiServer/Http/Controllers/Admin/Nodes/NodesController.cs @@ -59,7 +59,20 @@ public class NodesController : BaseCrudController("system/info"); + SystemInfoResponse response; + + try + { + response = await httpClient.GetJson("system/info"); + } + catch (HttpRequestException e) + { + throw new ApiException( + "The requested node's api server was not reachable", + e.Message, + statusCode: 502 + ); + } var result = Mapper.Map(response); diff --git a/MoonlightServers.Client/UI/Views/Admin/Nodes.razor b/MoonlightServers.Client/UI/Views/Admin/Nodes.razor index 298c6b3..b7f7237 100644 --- a/MoonlightServers.Client/UI/Views/Admin/Nodes.razor +++ b/MoonlightServers.Client/UI/Views/Admin/Nodes.razor @@ -1,6 +1,9 @@ @page "/admin/servers/nodes" +@using System.Diagnostics +@using MoonCore.Exceptions @using Moonlight.Client.App.Models.Crud +@using Moonlight.Client.App.Services @using Moonlight.Shared.Http.Resources @using MoonlightServers.Client.UI.Components.Forms @using MoonlightServers.Shared.Http.Requests.Admin.Nodes @@ -8,6 +11,7 @@ @using MoonlightServers.Client.UI.Components.Partials @inject HttpApiClient HttpApiClient +@inject AlertService AlertService @attribute [RequirePermission("admin.servers.nodes.get")] @@ -77,7 +81,9 @@ Offline: - @fetchState.Exception.Message + + Show details + } @@ -85,7 +91,7 @@ - + @@ -156,6 +162,8 @@ options.ShowUpdateAsModal = false; options.ShowDetailsAsModal = false; + options.ShowDetailsBar = false; + options.OnConfigureCreate = option => { option @@ -203,6 +211,11 @@ }; } + private async Task ShowDetails(Exception e) + { + await AlertService.ErrorLog("Node connection error", e.ToStringDemystified()); + } + class NodeFetchState { public StatusNodeResponse? Response { get; set; }