mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2025-05-07 00:34:03 +02:00
86 lines
2.9 KiB
Plaintext
86 lines
2.9 KiB
Plaintext
@page "/agents"
|
|
@using Phantom.Common.Data.Web.Agent
|
|
@using Phantom.Utils.Collections
|
|
@using Phantom.Web.Services.Agents
|
|
@inherits Phantom.Web.Components.PhantomComponent
|
|
@inject AgentManager AgentManager
|
|
|
|
<h1>Agents</h1>
|
|
|
|
<Table Items="agentTable">
|
|
<HeaderRow>
|
|
<Column Width="50%">Name</Column>
|
|
<Column Class="text-end" Width="24%" MinWidth="90px">Instances</Column>
|
|
<Column Class="text-end" Width="26%" MinWidth="145px">Memory</Column>
|
|
<Column>Version</Column>
|
|
<Column Class="text-center">Status</Column>
|
|
<Column Class="text-end" MinWidth="200px">Last Ping</Column>
|
|
</HeaderRow>
|
|
<ItemRow Context="agent">
|
|
@{
|
|
var configuration = agent.Configuration;
|
|
var usedInstances = agent.Stats?.RunningInstanceCount;
|
|
var usedMemory = agent.Stats?.RunningInstanceMemory.InMegabytes;
|
|
}
|
|
<Cell>
|
|
<p class="fw-semibold">@configuration.AgentName</p>
|
|
<small class="font-monospace text-uppercase">@agent.AgentGuid.ToString()</small>
|
|
</Cell>
|
|
<Cell class="text-end">
|
|
<ProgressBar Value="@(usedInstances ?? 0)" Maximum="@configuration.MaxInstances">
|
|
@(usedInstances?.ToString() ?? "?") / @configuration.MaxInstances.ToString()
|
|
</ProgressBar>
|
|
</Cell>
|
|
<Cell class="text-end">
|
|
<ProgressBar Value="@(usedMemory ?? 0)" Maximum="@configuration.MaxMemory.InMegabytes">
|
|
@(usedMemory?.ToString() ?? "?") / @configuration.MaxMemory.InMegabytes.ToString() MB
|
|
</ProgressBar>
|
|
</Cell>
|
|
<Cell class="text-condensed">
|
|
Build: <span class="font-monospace">@configuration.BuildVersion</span>
|
|
<br>
|
|
Protocol: <span class="font-monospace">v@(configuration.ProtocolVersion.ToString())</span>
|
|
</Cell>
|
|
@switch (agent.ConnectionStatus) {
|
|
case AgentIsOnline:
|
|
<Cell class="fw-semibold text-center text-success">Online</Cell>
|
|
<Cell class="text-end">-</Cell>
|
|
break;
|
|
case AgentIsOffline:
|
|
<Cell class="fw-semibold text-center">Offline</Cell>
|
|
<Cell class="text-end">N/A</Cell>
|
|
break;
|
|
case AgentIsDisconnected status:
|
|
<Cell class="fw-semibold text-center">Offline</Cell>
|
|
<Cell class="text-end">
|
|
<TimeWithOffset Time="status.LastPingTime" />
|
|
</Cell>
|
|
break;
|
|
default:
|
|
<Cell class="fw-semibold text-center">N/A</Cell>
|
|
break;
|
|
}
|
|
</ItemRow>
|
|
<NoItemsRow>
|
|
No agents registered.
|
|
</NoItemsRow>
|
|
</Table>
|
|
|
|
@code {
|
|
|
|
private readonly TableData<Agent, Guid> agentTable = new();
|
|
|
|
protected override void OnInitialized() {
|
|
AgentManager.AgentsChanged.Subscribe(this, agents => {
|
|
var sortedAgents = agents.Sort(static (a1, a2) => a1.Configuration.AgentName.CompareTo(a2.Configuration.AgentName));
|
|
agentTable.UpdateFrom(sortedAgents, static agent => agent.AgentGuid, static agent => agent, static (agent, _) => agent);
|
|
InvokeAsync(StateHasChanged);
|
|
});
|
|
}
|
|
|
|
protected override void OnDisposed() {
|
|
AgentManager.AgentsChanged.Unsubscribe(this);
|
|
}
|
|
|
|
}
|