mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2025-05-31 07:34:03 +02:00
Fix not showing offline Agents when editing an instance
This commit is contained in:
parent
524e27bd29
commit
a6acd7dec9
@ -22,18 +22,32 @@
|
|||||||
@{ var selectedAgent = form.SelectedAgent; }
|
@{ var selectedAgent = form.SelectedAgent; }
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xl-7 mb-3">
|
<div class="col-xl-7 mb-3">
|
||||||
<FormSelectInput Id="instance-agent" Label="Agent" @bind-Value="form.SelectedAgentGuid" disabled="@(EditedInstanceConfiguration != null)">
|
@{
|
||||||
<option value="" selected>Select which agent will run the instance...</option>
|
static RenderFragment GetAgentOption(Agent agent) {
|
||||||
@foreach (var agent in form.AgentsByGuid.Values.OrderBy(static agent => agent.Name)) {
|
return @<option value="@agent.Guid">
|
||||||
<option value="@agent.Guid">
|
@agent.Name
|
||||||
@agent.Name
|
•
|
||||||
•
|
@(agent.Stats?.RunningInstanceCount.ToString() ?? "?")/@(agent.MaxInstances) @(agent.MaxInstances == 1 ? "Instance" : "Instances")
|
||||||
@(agent.Stats?.RunningInstanceCount.ToString() ?? "?")/@(agent.MaxInstances) @(agent.MaxInstances == 1 ? "Instance" : "Instances")
|
•
|
||||||
•
|
@(agent.Stats?.RunningInstanceMemory.InMegabytes.ToString() ?? "?")/@(agent.MaxMemory.InMegabytes) MB RAM
|
||||||
@(agent.Stats?.RunningInstanceMemory.InMegabytes.ToString() ?? "?")/@(agent.MaxMemory.InMegabytes) MB RAM
|
</option>;
|
||||||
</option>
|
|
||||||
}
|
}
|
||||||
</FormSelectInput>
|
}
|
||||||
|
@if (EditedInstanceConfiguration == null) {
|
||||||
|
<FormSelectInput Id="instance-agent" Label="Agent" @bind-Value="form.SelectedAgentGuid">
|
||||||
|
<option value="" selected>Select which agent will run the instance...</option>
|
||||||
|
@foreach (var agent in form.AgentsByGuid.Values.Where(static agent => agent.IsOnline).OrderBy(static agent => agent.Name)) {
|
||||||
|
@GetAgentOption(agent)
|
||||||
|
}
|
||||||
|
</FormSelectInput>
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
<FormSelectInput Id="instance-agent" Label="Agent" @bind-Value="form.SelectedAgentGuid" disabled="true">
|
||||||
|
@if (form.SelectedAgentGuid is {} guid && form.AgentsByGuid.TryGetValue(guid, out var agent)) {
|
||||||
|
@GetAgentOption(agent)
|
||||||
|
}
|
||||||
|
</FormSelectInput>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-xl-5 mb-3">
|
<div class="col-xl-5 mb-3">
|
||||||
@ -163,7 +177,7 @@
|
|||||||
private readonly RamAllocationUnits? editedInstanceRamAllocation;
|
private readonly RamAllocationUnits? editedInstanceRamAllocation;
|
||||||
|
|
||||||
public ConfigureInstanceFormModel(AgentManager agentManager, AgentJavaRuntimesManager agentJavaRuntimesManager, RamAllocationUnits? editedInstanceRamAllocation) {
|
public ConfigureInstanceFormModel(AgentManager agentManager, AgentJavaRuntimesManager agentJavaRuntimesManager, RamAllocationUnits? editedInstanceRamAllocation) {
|
||||||
this.AgentsByGuid = agentManager.GetAgents().Where(static agent => agent.Value.IsOnline).ToImmutableDictionary();
|
this.AgentsByGuid = agentManager.GetAgents().ToImmutableDictionary();
|
||||||
this.javaRuntimesByAgentGuid = agentJavaRuntimesManager.All;
|
this.javaRuntimesByAgentGuid = agentJavaRuntimesManager.All;
|
||||||
this.editedInstanceRamAllocation = editedInstanceRamAllocation;
|
this.editedInstanceRamAllocation = editedInstanceRamAllocation;
|
||||||
}
|
}
|
||||||
@ -187,7 +201,7 @@
|
|||||||
public ImmutableArray<TaggedJavaRuntime> JavaRuntimesForSelectedAgent => TryGet(javaRuntimesByAgentGuid, SelectedAgentGuid, out var javaRuntimes) ? javaRuntimes : ImmutableArray<TaggedJavaRuntime>.Empty;
|
public ImmutableArray<TaggedJavaRuntime> JavaRuntimesForSelectedAgent => TryGet(javaRuntimesByAgentGuid, SelectedAgentGuid, out var javaRuntimes) ? javaRuntimes : ImmutableArray<TaggedJavaRuntime>.Empty;
|
||||||
|
|
||||||
public ushort MaximumMemoryUnits => SelectedAgent?.MaxMemory.RawValue ?? 0;
|
public ushort MaximumMemoryUnits => SelectedAgent?.MaxMemory.RawValue ?? 0;
|
||||||
public ushort AvailableMemoryUnits => Math.Min((SelectedAgent?.AvailableMemory + editedInstanceRamAllocation)?.RawValue ?? 0, MaximumMemoryUnits);
|
public ushort AvailableMemoryUnits => Math.Min((SelectedAgent?.AvailableMemory + editedInstanceRamAllocation)?.RawValue ?? MaximumMemoryUnits, MaximumMemoryUnits);
|
||||||
private ushort selectedMemoryUnits = 4;
|
private ushort selectedMemoryUnits = 4;
|
||||||
|
|
||||||
[Required(ErrorMessage = "You must select an agent.")]
|
[Required(ErrorMessage = "You must select an agent.")]
|
||||||
|
Loading…
Reference in New Issue
Block a user