mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2024-11-22 08:42:44 +01:00
92 lines
2.8 KiB
Plaintext
92 lines
2.8 KiB
Plaintext
@page "/agents"
|
|
@using Phantom.Server.Services.Agents
|
|
@using Phantom.Utils.Collections
|
|
@implements IDisposable
|
|
@inject AgentManager AgentManager
|
|
|
|
<h1>Agents</h1>
|
|
|
|
<table class="table align-middle">
|
|
<thead>
|
|
<tr>
|
|
<Column Width="200px; 44%">Name</Column>
|
|
<Column Width=" 90px; 19%" Class="text-end">Instances</Column>
|
|
<Column Width="145px; 21%" Class="text-end">Memory</Column>
|
|
<Column Width="180px; 8%">Version</Column>
|
|
<Column Width="320px">Identifier</Column>
|
|
<Column Width="100px; 8%" Class="text-center">Status</Column>
|
|
<Column Width="215px" Class="text-end">Last Ping</Column>
|
|
</tr>
|
|
</thead>
|
|
@if (!agentTable.IsEmpty) {
|
|
<tbody>
|
|
@foreach (var agent in agentTable) {
|
|
var usedInstances = agent.Stats?.RunningInstanceCount;
|
|
var usedMemory = agent.Stats?.RunningInstanceMemory.InMegabytes;
|
|
|
|
<tr>
|
|
<td>@agent.Name</td>
|
|
<td class="text-end">
|
|
<ProgressBar Value="@(usedInstances ?? 0)" Maximum="@agent.MaxInstances">
|
|
@(usedInstances?.ToString() ?? "?") / @agent.MaxInstances
|
|
</ProgressBar>
|
|
</td>
|
|
<td class="text-end">
|
|
<ProgressBar Value="@(usedMemory ?? 0)" Maximum="@agent.MaxMemory.InMegabytes">
|
|
@(usedMemory?.ToString() ?? "?") / @agent.MaxMemory.InMegabytes MB
|
|
</ProgressBar>
|
|
</td>
|
|
<td class="text-condensed">
|
|
Build: <code>@agent.BuildVersion</code>
|
|
<br>
|
|
Protocol: <code>v@(agent.ProtocolVersion)</code>
|
|
</td>
|
|
<td>
|
|
<code class="text-uppercase">@agent.Guid.ToString()</code>
|
|
</td>
|
|
@if (agent.IsOnline) {
|
|
<td class="text-center text-success">Online</td>
|
|
<td class="text-end"></td>
|
|
}
|
|
else {
|
|
<td class="text-center text-danger">Offline</td>
|
|
@if (agent.LastPing is {} lastPing) {
|
|
<td class="text-end">
|
|
<time datetime="@lastPing.ToString("o")" data-time-type="relative">@lastPing.ToString()</time>
|
|
</td>
|
|
}
|
|
else {
|
|
<td class="text-end">-</td>
|
|
}
|
|
}
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
}
|
|
else {
|
|
<tfoot>
|
|
<tr>
|
|
<td colspan="7">No agents registered.</td>
|
|
</tr>
|
|
</tfoot>
|
|
}
|
|
</table>
|
|
|
|
@code {
|
|
|
|
private readonly Table<Agent, Guid> agentTable = new();
|
|
|
|
protected override void OnInitialized() {
|
|
AgentManager.AgentsChanged.Subscribe(this, agents => {
|
|
var sortedAgents = agents.Sort(static (a1, a2) => a1.Name.CompareTo(a2.Name));
|
|
agentTable.UpdateFrom(sortedAgents, static agent => agent.Guid, static agent => agent, static (agent, _) => agent);
|
|
InvokeAsync(StateHasChanged);
|
|
});
|
|
}
|
|
|
|
void IDisposable.Dispose() {
|
|
AgentManager.AgentsChanged.Unsubscribe(this);
|
|
}
|
|
|
|
}
|