diff --git a/Moonlight/Features/Servers/Implementations/UI/UserDashboard/Components/UserDashboardServerCount.cs b/Moonlight/Features/Servers/Implementations/UI/UserDashboard/Components/UserDashboardServerCount.cs new file mode 100644 index 00000000..5a10fee5 --- /dev/null +++ b/Moonlight/Features/Servers/Implementations/UI/UserDashboard/Components/UserDashboardServerCount.cs @@ -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 Get() + { + var res = new UiComponent() + { + Component = ComponentHelper.FromType(), + Index = int.MinValue + 100 + }; + + return Task.FromResult(res); + } +} \ No newline at end of file diff --git a/Moonlight/Features/Servers/ServersFeature.cs b/Moonlight/Features/Servers/ServersFeature.cs index 89956ee5..8ebf44f7 100644 --- a/Moonlight/Features/Servers/ServersFeature.cs +++ b/Moonlight/Features/Servers/ServersFeature.cs @@ -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(new ServerCount()); await pluginService.RegisterImplementation(new NodeOverview()); + + await pluginService.RegisterImplementation(new UserDashboardServerCount()); } public override Task OnUiInitialized(UiInitContext context) diff --git a/Moonlight/Features/Servers/UI/Components/Cards/UserDashboardServerCount.razor b/Moonlight/Features/Servers/UI/Components/Cards/UserDashboardServerCount.razor new file mode 100644 index 00000000..952c45ec --- /dev/null +++ b/Moonlight/Features/Servers/UI/Components/Cards/UserDashboardServerCount.razor @@ -0,0 +1,39 @@ +@using Microsoft.EntityFrameworkCore +@using MoonCore.Abstractions +@using Moonlight.Core.Services +@using Moonlight.Features.Servers.Entities + +@inject Repository ServerRepository +@inject Repository NetworkRepository +@inject IdentityService IdentityService + +
+ + + +
+ +@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(); + + } + +} \ No newline at end of file