Added a cool node status card onto the admin dashboard
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
using MoonCoreUI.Helpers;
|
||||||
|
using Moonlight.Core.Interfaces.Ui.Admin;
|
||||||
|
using Moonlight.Core.Models.Abstractions;
|
||||||
|
using Moonlight.Features.Servers.UI.Components.Cards;
|
||||||
|
|
||||||
|
namespace Moonlight.Features.Servers.Implementations.UI.Admin.AdminComponents;
|
||||||
|
|
||||||
|
public class NodeOverview : IAdminDashboardComponent
|
||||||
|
{
|
||||||
|
public Task<UiComponent> Get()
|
||||||
|
{
|
||||||
|
var res = new UiComponent()
|
||||||
|
{
|
||||||
|
Component = ComponentHelper.FromType<AdminNodesComponent>(),
|
||||||
|
RequiredPermissionLevel = 5001
|
||||||
|
};
|
||||||
|
|
||||||
|
return Task.FromResult(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ using Moonlight.Features.Servers.Configuration;
|
|||||||
using Moonlight.Features.Servers.Http.Middleware;
|
using Moonlight.Features.Servers.Http.Middleware;
|
||||||
using Moonlight.Features.Servers.Implementations.Diagnose;
|
using Moonlight.Features.Servers.Implementations.Diagnose;
|
||||||
using Moonlight.Features.Servers.Implementations.UI.Admin.AdminColumns;
|
using Moonlight.Features.Servers.Implementations.UI.Admin.AdminColumns;
|
||||||
|
using Moonlight.Features.Servers.Implementations.UI.Admin.AdminComponents;
|
||||||
using Moonlight.Features.Servers.Models.Enums;
|
using Moonlight.Features.Servers.Models.Enums;
|
||||||
using Moonlight.Features.Servers.Services;
|
using Moonlight.Features.Servers.Services;
|
||||||
using Moonlight.Features.Servers.UI.Components.Cards;
|
using Moonlight.Features.Servers.UI.Components.Cards;
|
||||||
@@ -100,6 +101,8 @@ public class ServersFeature : MoonlightFeature
|
|||||||
await pluginService.RegisterImplementation<IDiagnoseAction>(new NodesDiagnoseAction());
|
await pluginService.RegisterImplementation<IDiagnoseAction>(new NodesDiagnoseAction());
|
||||||
|
|
||||||
await pluginService.RegisterImplementation<IAdminDashboardColumn>(new ServerCount());
|
await pluginService.RegisterImplementation<IAdminDashboardColumn>(new ServerCount());
|
||||||
|
|
||||||
|
await pluginService.RegisterImplementation<IAdminDashboardComponent>(new NodeOverview());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task OnUiInitialized(UiInitContext context)
|
public override Task OnUiInitialized(UiInitContext context)
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
@using MoonCore.Abstractions
|
||||||
|
@using Moonlight.Features.Servers.Api.Resources
|
||||||
|
@using Moonlight.Features.Servers.Entities
|
||||||
|
@using Moonlight.Features.Servers.Services
|
||||||
|
|
||||||
|
@inject NodeService NodeService
|
||||||
|
@inject Repository<ServerNode> NodeRepository
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h4 class="card-title mb-2">Nodes Overview</h4>
|
||||||
|
<hr class="mb-4"/>
|
||||||
|
<div class="row mx-2">
|
||||||
|
@if (Nodes.Any())
|
||||||
|
{
|
||||||
|
foreach (var node in Nodes)
|
||||||
|
{
|
||||||
|
<div class="col-12 col-md-6 col-3">
|
||||||
|
<div class="row">
|
||||||
|
<span class="col-auto d-flex align-items-center">
|
||||||
|
<span class="badge text-bg-@(node.Item2 == null ? "danger" : "success") text-capitalize">@(node.Item2 == null ? "offline" : "online")</span>
|
||||||
|
</span>
|
||||||
|
<div class="col">
|
||||||
|
<span class="fs-5 fw-bold d-block">@node.Item1.Name</span>
|
||||||
|
<span class="text-muted text-lowercase fs-6 d-block">@node.Item1.Fqdn</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<span class="text-muted fs-4">You dont have any nodes.</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
private List<Tuple<ServerNode, SystemStatus?>> Nodes = new();
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
foreach (var node in NodeRepository.Get().ToList())
|
||||||
|
{
|
||||||
|
SystemStatus? nodeStatus = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
nodeStatus = await NodeService.GetStatus(node);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// Ignored
|
||||||
|
}
|
||||||
|
|
||||||
|
Nodes.Add(new Tuple<ServerNode, SystemStatus?>(node, nodeStatus));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -74,7 +74,6 @@
|
|||||||
<Folder Include="Features\FileManager\Http\Requests\" />
|
<Folder Include="Features\FileManager\Http\Requests\" />
|
||||||
<Folder Include="Features\FileManager\Http\Resources\" />
|
<Folder Include="Features\FileManager\Http\Resources\" />
|
||||||
<Folder Include="Features\Servers\Http\Resources\" />
|
<Folder Include="Features\Servers\Http\Resources\" />
|
||||||
<Folder Include="Features\Servers\Implementations\UI\Admin\" />
|
|
||||||
<Folder Include="storage\" />
|
<Folder Include="storage\" />
|
||||||
<Folder Include="Styles\" />
|
<Folder Include="Styles\" />
|
||||||
<Folder Include="wwwroot\css\" />
|
<Folder Include="wwwroot\css\" />
|
||||||
|
|||||||
Reference in New Issue
Block a user