164 lines
5.3 KiB
Plaintext
164 lines
5.3 KiB
Plaintext
@page "/admin"
|
|
@using LucideBlazor
|
|
@using Moonlight.Frontend.UI.Admin.Modals
|
|
@using Moonlight.Shared.Http.Responses.Admin
|
|
@using ShadcnBlazor.Buttons
|
|
@using ShadcnBlazor.Cards
|
|
@using ShadcnBlazor.Extras.Dialogs
|
|
@using ShadcnBlazor.Spinners
|
|
|
|
@inject HttpClient HttpClient
|
|
@inject DialogService DialogService
|
|
|
|
<h1 class="text-xl font-semibold">Overview</h1>
|
|
<div class="text-muted-foreground">
|
|
Here you can see a quick overview of your moonlight instance
|
|
</div>
|
|
|
|
<div class="mt-8 grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-5">
|
|
<Card ClassName="col-span-1">
|
|
@if (IsInfoLoading || InfoResponse == null)
|
|
{
|
|
<CardContent ClassName="flex justify-center items-center">
|
|
<Spinner ClassName="size-8"/>
|
|
</CardContent>
|
|
}
|
|
else
|
|
{
|
|
<CardHeader>
|
|
<CardDescription>CPU Usage</CardDescription>
|
|
<CardTitle ClassName="text-lg">@Math.Round(InfoResponse.CpuUsage, 2)%</CardTitle>
|
|
<CardAction>
|
|
<CpuIcon ClassName="size-6 text-muted-foreground" />
|
|
</CardAction>
|
|
</CardHeader>
|
|
}
|
|
</Card>
|
|
|
|
<Card ClassName="col-span-1">
|
|
@if (IsInfoLoading || InfoResponse == null)
|
|
{
|
|
<CardContent ClassName="flex justify-center items-center">
|
|
<Spinner ClassName="size-8"/>
|
|
</CardContent>
|
|
}
|
|
else
|
|
{
|
|
<CardHeader>
|
|
<CardDescription>Memory Usage</CardDescription>
|
|
<CardTitle ClassName="text-lg">@Formatter.FormatSize(InfoResponse.MemoryUsage)</CardTitle>
|
|
<CardAction>
|
|
<MemoryStickIcon ClassName="size-6 text-muted-foreground" />
|
|
</CardAction>
|
|
</CardHeader>
|
|
}
|
|
</Card>
|
|
|
|
<Card ClassName="col-span-1">
|
|
@if (IsInfoLoading || InfoResponse == null)
|
|
{
|
|
<CardContent ClassName="flex justify-center items-center">
|
|
<Spinner ClassName="size-8"/>
|
|
</CardContent>
|
|
}
|
|
else
|
|
{
|
|
<CardHeader>
|
|
<CardDescription>Operating System</CardDescription>
|
|
<CardTitle ClassName="text-lg">@InfoResponse.OperatingSystem</CardTitle>
|
|
<CardAction>
|
|
<ComputerIcon ClassName="size-6 text-muted-foreground" />
|
|
</CardAction>
|
|
</CardHeader>
|
|
}
|
|
</Card>
|
|
|
|
<Card ClassName="col-span-1">
|
|
@if (IsInfoLoading || InfoResponse == null)
|
|
{
|
|
<CardContent ClassName="flex justify-center items-center">
|
|
<Spinner ClassName="size-8"/>
|
|
</CardContent>
|
|
}
|
|
else
|
|
{
|
|
<CardHeader>
|
|
<CardDescription>Uptime</CardDescription>
|
|
<CardTitle ClassName="text-lg">@Formatter.FormatDuration(InfoResponse.Uptime)</CardTitle>
|
|
<CardAction>
|
|
<ClockIcon ClassName="size-6 text-muted-foreground" />
|
|
</CardAction>
|
|
</CardHeader>
|
|
}
|
|
</Card>
|
|
|
|
<Card ClassName="col-span-1">
|
|
@if (IsInfoLoading || InfoResponse == null)
|
|
{
|
|
<CardContent ClassName="flex justify-center items-center">
|
|
<Spinner ClassName="size-8"/>
|
|
</CardContent>
|
|
}
|
|
else
|
|
{
|
|
<CardHeader>
|
|
<CardDescription>Version</CardDescription>
|
|
<CardTitle ClassName="text-lg">@InfoResponse.VersionName</CardTitle>
|
|
<CardAction>
|
|
<RocketIcon ClassName="size-6 text-muted-foreground" />
|
|
</CardAction>
|
|
</CardHeader>
|
|
}
|
|
</Card>
|
|
|
|
<Card ClassName="col-span-1">
|
|
@if (IsInfoLoading || InfoResponse == null)
|
|
{
|
|
<CardContent ClassName="flex justify-center items-center">
|
|
<Spinner ClassName="size-8"/>
|
|
</CardContent>
|
|
}
|
|
else
|
|
{
|
|
<CardHeader>
|
|
<CardDescription>Update Status</CardDescription>
|
|
@if (InfoResponse.IsUpToDate)
|
|
{
|
|
<CardTitle ClassName="text-lg text-green-500">Up-to-date</CardTitle>
|
|
<CardAction>
|
|
<RefreshCwIcon ClassName="size-6 text-muted-foreground" />
|
|
</CardAction>
|
|
}
|
|
else
|
|
{
|
|
<CardTitle ClassName="text-lg text-primary">Update available</CardTitle>
|
|
<CardAction ClassName="self-center">
|
|
<Button>
|
|
<Slot>
|
|
<a href="/admin/system?tab=instance" @attributes="context">Update</a>
|
|
</Slot>
|
|
</Button>
|
|
</CardAction>
|
|
}
|
|
</CardHeader>
|
|
}
|
|
</Card>
|
|
</div>
|
|
|
|
@code
|
|
{
|
|
private bool IsInfoLoading = true;
|
|
private SystemInfoDto? InfoResponse;
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if(!firstRender)
|
|
return;
|
|
|
|
InfoResponse = await HttpClient.GetFromJsonAsync<SystemInfoDto>("api/admin/system/info", Constants.SerializerOptions);
|
|
IsInfoLoading = false;
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
}
|