mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2025-05-07 00:34:03 +02:00
88 lines
3.4 KiB
Plaintext
88 lines
3.4 KiB
Plaintext
@page "/instances"
|
|
@attribute [Authorize(Permission.ViewInstancesPolicy)]
|
|
@using System.Collections.Immutable
|
|
@using Phantom.Common.Data.Web.Instance
|
|
@using Phantom.Common.Data.Web.Users
|
|
@using Phantom.Web.Services.Agents
|
|
@using Phantom.Web.Services.Authorization
|
|
@using Phantom.Web.Services.Instances
|
|
@inherits PhantomComponent
|
|
@inject AgentManager AgentManager
|
|
@inject InstanceManager InstanceManager
|
|
|
|
<h1>Instances</h1>
|
|
|
|
<PermissionView Permission="Permission.CreateInstances">
|
|
<a href="instances/create" class="btn btn-primary" role="button">New Instance</a>
|
|
</PermissionView>
|
|
|
|
<Table TItem="Instance" Items="instances" ItemUrl="@(static instance => "instances/" + instance.InstanceGuid)">
|
|
<HeaderRow>
|
|
<Column Width="40%">Agent</Column>
|
|
<Column Width="40%">Name</Column>
|
|
<Column MinWidth="215px">Status</Column>
|
|
<Column Width="20%">Version</Column>
|
|
<Column Class="text-center" MinWidth="110px">Server Port</Column>
|
|
<Column Class="text-center" MinWidth="110px">Rcon Port</Column>
|
|
<Column Class="text-end" MinWidth="90px">Memory</Column>
|
|
<Column MinWidth="75px">Actions</Column>
|
|
</HeaderRow>
|
|
<ItemRow Context="instance">
|
|
@{ var configuration = instance.Configuration; }
|
|
<Cell>
|
|
<p class="fw-semibold">@(agentNamesByGuid.TryGetValue(configuration.AgentGuid, out var name) ? name : string.Empty)</p>
|
|
<small class="font-monospace text-uppercase">@configuration.AgentGuid.ToString()</small>
|
|
</Cell>
|
|
<Cell>
|
|
<p class="fw-semibold">@configuration.InstanceName</p>
|
|
<small class="font-monospace text-uppercase">@instance.InstanceGuid.ToString()</small>
|
|
</Cell>
|
|
<Cell>
|
|
<InstanceStatusText Status="instance.Status" />
|
|
</Cell>
|
|
<Cell>@configuration.MinecraftServerKind @configuration.MinecraftVersion</Cell>
|
|
<Cell class="text-center">
|
|
<p class="font-monospace">@configuration.ServerPort.ToString()</p>
|
|
</Cell>
|
|
<Cell class="text-center">
|
|
<p class="font-monospace">@configuration.RconPort.ToString()</p>
|
|
</Cell>
|
|
<Cell class="text-end">
|
|
<p class="font-monospace">@configuration.MemoryAllocation.InMegabytes.ToString() MB</p>
|
|
</Cell>
|
|
<Cell>
|
|
<a href="instances/@instance.InstanceGuid.ToString()" class="btn btn-info btn-sm">Detail</a>
|
|
</Cell>
|
|
</ItemRow>
|
|
<NoItemsRow>
|
|
No instances found.
|
|
</NoItemsRow>
|
|
</Table>
|
|
|
|
@code {
|
|
|
|
private ImmutableDictionary<Guid, string> agentNamesByGuid = ImmutableDictionary<Guid, string>.Empty;
|
|
private ImmutableArray<Instance>? instances;
|
|
|
|
protected override void OnInitialized() {
|
|
AgentManager.AgentsChanged.Subscribe(this, agents => {
|
|
this.agentNamesByGuid = agents.ToImmutableDictionary(static agent => agent.AgentGuid, static agent => agent.Configuration.AgentName);
|
|
InvokeAsync(StateHasChanged);
|
|
});
|
|
|
|
InstanceManager.InstancesChanged.Subscribe(this, instances => {
|
|
this.instances = instances.Values
|
|
.OrderBy(instance => agentNamesByGuid.TryGetValue(instance.Configuration.AgentGuid, out var agentName) ? agentName : string.Empty)
|
|
.ThenBy(static instance => instance.Configuration.InstanceName)
|
|
.ToImmutableArray();
|
|
InvokeAsync(StateHasChanged);
|
|
});
|
|
}
|
|
|
|
protected override void OnDisposed() {
|
|
AgentManager.AgentsChanged.Unsubscribe(this);
|
|
InstanceManager.InstancesChanged.Unsubscribe(this);
|
|
}
|
|
|
|
}
|