Implemented system overview
This commit is contained in:
@@ -58,7 +58,7 @@ public class DefaultSidebarItemProvider : ISidebarItemProvider
|
||||
Path = "/admin/system",
|
||||
Priority = 3,
|
||||
RequiresExactMatch = false,
|
||||
Permission = "admin.system.info"
|
||||
Permission = "admin.system.overview"
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,30 +1,43 @@
|
||||
@page "/admin/system"
|
||||
|
||||
@using MoonCore.Attributes
|
||||
@using MoonCore.Helpers
|
||||
@using Moonlight.Client.UI.Components
|
||||
@using Moonlight.Shared.Http.Responses.Admin.Sys
|
||||
|
||||
@attribute [RequirePermission("admin.system.read")]
|
||||
@attribute [RequirePermission("admin.system.overview")]
|
||||
|
||||
<div class="gap-5 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<StatCard Title="CPU Usage" Text="2%" Icon="bi bi-cpu"/>
|
||||
<StatCard Title="Memory Usage" Text="71 MB" Icon="bi bi-memory"/>
|
||||
<StatCard Title="Host OS" Text="Debian 12" Icon="bi bi-motherboard"/>
|
||||
<StatCard Title="Uptime" Text="1d 5h 12h 3s" Icon="bi bi-clock-history"/>
|
||||
|
||||
<div class="card card-body">
|
||||
<div class="flex justify-center">
|
||||
<WButton OnClick="Restart" CssClasses="btn btn-danger w-full">
|
||||
<i class="bi bi-arrow-repeat text-xl text-white me-2"></i>
|
||||
Restart
|
||||
</WButton>
|
||||
@inject HttpApiClient ApiClient
|
||||
|
||||
<LazyLoader Load="LoadOverview">
|
||||
<div class="gap-5 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<StatCard Title="CPU Usage" Text="@(OverviewData.CpuUsage + "%")" Icon="bi bi-cpu"/>
|
||||
<StatCard Title="Memory Usage" Text="@(Formatter.FormatSize(OverviewData.MemoryUsage))" Icon="bi bi-memory"/>
|
||||
<StatCard Title="Host OS" Text="@(OverviewData.OperatingSystem)" Icon="bi bi-motherboard"/>
|
||||
<StatCard Title="Uptime" Text="@(Formatter.FormatUptime(OverviewData.Uptime))" Icon="bi bi-clock-history"/>
|
||||
|
||||
<div class="card card-body">
|
||||
<div class="flex justify-center">
|
||||
<WButton OnClick="Restart" CssClasses="btn btn-danger w-full">
|
||||
<i class="bi bi-arrow-repeat text-xl text-white me-2"></i>
|
||||
Restart/Shutdown
|
||||
</WButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</LazyLoader>
|
||||
|
||||
@code
|
||||
{
|
||||
private SystemOverviewResponse OverviewData;
|
||||
|
||||
private async Task LoadOverview(LazyLoader arg)
|
||||
{
|
||||
OverviewData = await ApiClient.GetJson<SystemOverviewResponse>("api/admin/system");
|
||||
}
|
||||
|
||||
private async Task Restart(WButton _)
|
||||
{
|
||||
|
||||
await ApiClient.Post("api/admin/system/shutdown");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user