Show warning for a server's allocations if it's currently running

This commit is contained in:
Lance Pioch 2022-11-07 22:12:24 -05:00
parent 87a2fff3b7
commit 6ffb7fd7f6
2 changed files with 15 additions and 0 deletions

View file

@ -61,8 +61,15 @@ class ServerViewController extends Controller
{ {
$allocations = $server->node->allocations->toBase(); $allocations = $server->node->allocations->toBase();
try {
$stats = $server->getStats();
} catch (\Exception) {
// Can't connect to daemon
}
return $this->view->make('admin.servers.view.build', [ return $this->view->make('admin.servers.view.build', [
'server' => $server, 'server' => $server,
'currentState' => $stats['current_state'] ?? null,
'assigned' => $allocations->where('server_id', $server->id)->sortBy('port')->sortBy('ip'), 'assigned' => $allocations->where('server_id', $server->id)->sortBy('port')->sortBy('ip'),
'unassigned' => $allocations->where('server_id', null)->sortBy('port')->sortBy('ip'), 'unassigned' => $allocations->where('server_id', null)->sortBy('port')->sortBy('ip'),
]); ]);

View file

@ -129,6 +129,14 @@
<h3 class="box-title">Allocation Management</h3> <h3 class="box-title">Allocation Management</h3>
</div> </div>
<div class="box-body"> <div class="box-body">
@if ($currentState === 'running')
<div class="alert alert-warning">
Warning, your server is currently running.
If you remove allocations without restarting,
then you can run into issues using them elsewhere.
</div>
@endif
<div class="form-group"> <div class="form-group">
<label for="pAllocation" class="control-label">Game Port</label> <label for="pAllocation" class="control-label">Game Port</label>
<select id="pAllocation" name="allocation_id" class="form-control"> <select id="pAllocation" name="allocation_id" class="form-control">