Check for resources when upgrading server
This commit is contained in:
parent
30d29cdd62
commit
df0d37bb81
|
@ -241,6 +241,9 @@ class ServerController extends Controller
|
||||||
$serverRelationships = $serverAttributes['relationships'];
|
$serverRelationships = $serverAttributes['relationships'];
|
||||||
$serverLocationAttributes = $serverRelationships['location']['attributes'];
|
$serverLocationAttributes = $serverRelationships['location']['attributes'];
|
||||||
|
|
||||||
|
//Get current product
|
||||||
|
$currentProduct = Product::where('id', $server->product_id)->first();
|
||||||
|
|
||||||
//Set server infos
|
//Set server infos
|
||||||
$server->location = $serverLocationAttributes['long'] ?
|
$server->location = $serverLocationAttributes['long'] ?
|
||||||
$serverLocationAttributes['long'] :
|
$serverLocationAttributes['long'] :
|
||||||
|
@ -249,11 +252,19 @@ class ServerController extends Controller
|
||||||
$server->node = $serverRelationships['node']['attributes']['name'];
|
$server->node = $serverRelationships['node']['attributes']['name'];
|
||||||
$server->name = $serverAttributes['name'];
|
$server->name = $serverAttributes['name'];
|
||||||
$server->egg = $serverRelationships['egg']['attributes']['name'];
|
$server->egg = $serverRelationships['egg']['attributes']['name'];
|
||||||
$products = Product::orderBy("created_at")->get();
|
|
||||||
|
$pteroNode = Pterodactyl::getNode($serverRelationships['node']['attributes']['id']);
|
||||||
|
|
||||||
|
$products = Product::orderBy("created_at")
|
||||||
|
->whereHas('nodes', function (Builder $builder) use ($serverRelationships) { //Only show products for that node
|
||||||
|
$builder->where('id', '=', $serverRelationships['node']['attributes']['id']);
|
||||||
|
})
|
||||||
|
->get();
|
||||||
|
|
||||||
// Set the each product eggs array to just contain the eggs name
|
// Set the each product eggs array to just contain the eggs name
|
||||||
foreach ($products as $product) {
|
foreach ($products as $product) {
|
||||||
$product->eggs = $product->eggs->pluck('name')->toArray();
|
$product->eggs = $product->eggs->pluck('name')->toArray();
|
||||||
|
if($product->memory-$currentProduct->memory>($pteroNode['memory']*($pteroNode['memory_overallocate']+100)/100)-$pteroNode['allocated_resources']['memory']||$product->disk-$currentProduct->disk>($pteroNode['disk']*($pteroNode['disk_overallocate']+100)/100)-$pteroNode['allocated_resources']['disk']) $product->doesNotFit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('servers.settings')->with([
|
return view('servers.settings')->with([
|
||||||
|
|
|
@ -255,8 +255,8 @@
|
||||||
<option value="">{{__("Select the product")}}</option>
|
<option value="">{{__("Select the product")}}</option>
|
||||||
@foreach($products as $product)
|
@foreach($products as $product)
|
||||||
@if(in_array($server->egg, $product->eggs) && $product->id != $server->product->id && $product->disabled == false)
|
@if(in_array($server->egg, $product->eggs) && $product->id != $server->product->id && $product->disabled == false)
|
||||||
<option value="{{ $product->id }}">{{ $product->name }} [ {{ CREDITS_DISPLAY_NAME }} {{ $product->price }} @if($product->minimum_credits!=-1) /
|
<option value="{{ $product->id }}" @if($product->doesNotFit)disabled @endif>{{ $product->name }} [ {{ CREDITS_DISPLAY_NAME }} {{ $product->price }} @if($product->doesNotFit)] {{__('Server can´t fit on this node')}} @else @if($product->minimum_credits!=-1) /
|
||||||
{{__("Required")}}: {{$product->minimum_credits}} {{ CREDITS_DISPLAY_NAME }}@endif ]</option>
|
{{__("Required")}}: {{$product->minimum_credits}} {{ CREDITS_DISPLAY_NAME }}@endif ] @endif</option>
|
||||||
@endif
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
|
|
Loading…
Reference in a new issue