Added connection exception handling to node status and added error detail view in node overview

This commit is contained in:
Masu-Baumgartner
2024-09-11 17:04:00 +02:00
parent 9d9f24a21d
commit 80290564d0
2 changed files with 29 additions and 3 deletions

View File

@@ -59,7 +59,20 @@ public class NodesController : BaseCrudController<Node, DetailNodeResponse, Crea
using var httpClient = node.CreateClient(); using var httpClient = node.CreateClient();
var response = await httpClient.GetJson<SystemInfoResponse>("system/info"); SystemInfoResponse response;
try
{
response = await httpClient.GetJson<SystemInfoResponse>("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<StatusNodeResponse>(response); var result = Mapper.Map<StatusNodeResponse>(response);

View File

@@ -1,6 +1,9 @@
@page "/admin/servers/nodes" @page "/admin/servers/nodes"
@using System.Diagnostics
@using MoonCore.Exceptions
@using Moonlight.Client.App.Models.Crud @using Moonlight.Client.App.Models.Crud
@using Moonlight.Client.App.Services
@using Moonlight.Shared.Http.Resources @using Moonlight.Shared.Http.Resources
@using MoonlightServers.Client.UI.Components.Forms @using MoonlightServers.Client.UI.Components.Forms
@using MoonlightServers.Shared.Http.Requests.Admin.Nodes @using MoonlightServers.Shared.Http.Requests.Admin.Nodes
@@ -8,6 +11,7 @@
@using MoonlightServers.Client.UI.Components.Partials @using MoonlightServers.Client.UI.Components.Partials
@inject HttpApiClient HttpApiClient @inject HttpApiClient HttpApiClient
@inject AlertService AlertService
@attribute [RequirePermission("admin.servers.nodes.get")] @attribute [RequirePermission("admin.servers.nodes.get")]
@@ -77,7 +81,9 @@
<i class="mr-1 align-middle text-lg bi bi-exclamation-triangle-fill text-red-500"></i> <i class="mr-1 align-middle text-lg bi bi-exclamation-triangle-fill text-red-500"></i>
<span class="mr-1">Offline:</span> <span class="mr-1">Offline:</span>
@fetchState.Exception.Message <a href="#" @onclick:preventDefault @onclick="() => ShowDetails(fetchState.Exception)" class="mr-1 text-red-400">
Show details
</a>
</div> </div>
} }
</div> </div>
@@ -85,7 +91,7 @@
</SmartColumn> </SmartColumn>
</View> </View>
<DetailView> <DetailView>
<SmartTabs> <SmartTabs BarStyle="true" BarText="Details">
<SmartTab Name="Overview"> <SmartTab Name="Overview">
<NodeOverview NodeId="@context.Id"/> <NodeOverview NodeId="@context.Id"/>
</SmartTab> </SmartTab>
@@ -156,6 +162,8 @@
options.ShowUpdateAsModal = false; options.ShowUpdateAsModal = false;
options.ShowDetailsAsModal = false; options.ShowDetailsAsModal = false;
options.ShowDetailsBar = false;
options.OnConfigureCreate = option => options.OnConfigureCreate = option =>
{ {
option option
@@ -203,6 +211,11 @@
}; };
} }
private async Task ShowDetails(Exception e)
{
await AlertService.ErrorLog("Node connection error", e.ToStringDemystified());
}
class NodeFetchState class NodeFetchState
{ {
public StatusNodeResponse? Response { get; set; } public StatusNodeResponse? Response { get; set; }