Added User Dashboard Informations
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using MoonCoreUI.Helpers;
|
||||
using Moonlight.Core.Interfaces.UI.User;
|
||||
using Moonlight.Core.Models.Abstractions;
|
||||
using Moonlight.Features.Servers.UI.Components.Cards;
|
||||
|
||||
namespace Moonlight.Features.Servers.Implementations.UI.UserDashboard.Components;
|
||||
|
||||
public class UserDashboardServerCount : IUserDashboardComponent
|
||||
{
|
||||
public Task<UiComponent> Get()
|
||||
{
|
||||
var res = new UiComponent()
|
||||
{
|
||||
Component = ComponentHelper.FromType<Servers.UI.Components.Cards.UserDashboardServerCount>(),
|
||||
Index = int.MinValue + 100
|
||||
};
|
||||
|
||||
return Task.FromResult(res);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using MoonCore.Services;
|
||||
using Moonlight.Core.Configuration;
|
||||
using Moonlight.Core.Interfaces;
|
||||
using Moonlight.Core.Interfaces.Ui.Admin;
|
||||
using Moonlight.Core.Interfaces.UI.User;
|
||||
using Moonlight.Core.Models.Abstractions.Feature;
|
||||
using Moonlight.Core.Services;
|
||||
using Moonlight.Features.Servers.Actions;
|
||||
@@ -14,6 +15,7 @@ using Moonlight.Features.Servers.Implementations.UI.Admin.AdminComponents;
|
||||
using Moonlight.Features.Servers.Models.Enums;
|
||||
using Moonlight.Features.Servers.Services;
|
||||
using Moonlight.Features.Servers.UI.Components.Cards;
|
||||
using UserDashboardServerCount = Moonlight.Features.Servers.Implementations.UI.UserDashboard.Components.UserDashboardServerCount;
|
||||
|
||||
namespace Moonlight.Features.Servers;
|
||||
|
||||
@@ -103,6 +105,8 @@ public class ServersFeature : MoonlightFeature
|
||||
await pluginService.RegisterImplementation<IAdminDashboardColumn>(new ServerCount());
|
||||
|
||||
await pluginService.RegisterImplementation<IAdminDashboardComponent>(new NodeOverview());
|
||||
|
||||
await pluginService.RegisterImplementation<IUserDashboardComponent>(new UserDashboardServerCount());
|
||||
}
|
||||
|
||||
public override Task OnUiInitialized(UiInitContext context)
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using MoonCore.Abstractions
|
||||
@using Moonlight.Core.Services
|
||||
@using Moonlight.Features.Servers.Entities
|
||||
|
||||
@inject Repository<Server> ServerRepository
|
||||
@inject Repository<ServerNetwork> NetworkRepository
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
<div class="row mt-8">
|
||||
<div class="col-12 col-md-6 mb-4">
|
||||
<a href="/servers">
|
||||
<StatCard Icon="bx-server" Description="Servers" Value="@ServerCount.ToString()">
|
||||
</StatCard>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-6">
|
||||
<a href="/servers/network">
|
||||
<StatCard Icon="bx-network-chart" Description="Networks" Value="@NetworksCount.ToString()">
|
||||
</StatCard>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
private int ServerCount = 0;
|
||||
private int NetworksCount = 0;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
||||
ServerCount = await ServerRepository.Get().Where(x => x.Owner == IdentityService.CurrentUser).CountAsync();
|
||||
NetworksCount = await NetworkRepository.Get().Where(x => x.User == IdentityService.CurrentUser).CountAsync();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user