feat: ✨ Added Enable Upgrade setting
This commit is contained in:
parent
c9df5e6f94
commit
5bf5abfda7
4 changed files with 22 additions and 8 deletions
|
@ -43,6 +43,7 @@ public function checkPteroClientkey(){
|
|||
"pterodactyl-api-key" => "required|string",
|
||||
"pterodactyl-url" => "required|string",
|
||||
"pterodactyl-admin-api-key" => "required|string",
|
||||
"enable-upgrades" => "string",
|
||||
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
|
@ -73,6 +74,7 @@ public function checkPteroClientkey(){
|
|||
"SETTINGS::SYSTEM:PTERODACTYL:TOKEN" => "pterodactyl-api-key",
|
||||
"SETTINGS::SYSTEM:ENABLE_LOGIN_LOGO" => "enable-login-logo",
|
||||
"SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN" => "pterodactyl-admin-api-key",
|
||||
"SETTINGS::SYSTEM:ENABLE_UPGRADE" => "enable-upgrade",
|
||||
];
|
||||
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ class ServerController extends Controller
|
|||
|
||||
public function upgrade(Server $server, Request $request)
|
||||
{
|
||||
if($server->user_id != Auth::user()->id) return redirect()->route('servers.index');
|
||||
if($server->user_id != Auth::user()->id || !config("SETTINGS::SYSTEM:ENABLE_UPGRADE")) return redirect()->route('servers.index');
|
||||
if(!isset($request->product_upgrade))
|
||||
{
|
||||
return redirect()->route('servers.show', ['server' => $server->id])->with('error', __('this product is the only one'));
|
||||
|
@ -268,7 +268,7 @@ class ServerController extends Controller
|
|||
$serverAttributes = Pterodactyl::getServerAttributes($server->pterodactyl_id);
|
||||
$serverRelationships = $serverAttributes['relationships'];
|
||||
|
||||
// Get node resource allocation info
|
||||
// Get node resource allocation info
|
||||
$nodeId = $serverRelationships['node']['attributes']['id'];
|
||||
$node = Node::where('id', $nodeId)->firstOrFail();
|
||||
$nodeName = $node->name;
|
||||
|
|
|
@ -178,6 +178,21 @@
|
|||
<h1>{{ __('Server') }}</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="custom-control mb-1 p-0">
|
||||
<div class="col m-0 p-0 d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<input value="true" id="enable-upgrade" name="enable-upgrade"
|
||||
{{ config('SETTINGS::SYSTEM:ENABLE_UPGRADE') == 'true' ? 'checked' : '' }}
|
||||
type="checkbox">
|
||||
<label for="enable-upgrade">{{ __('Enable upgrade/downgrade of servers') }} </label>
|
||||
</div>
|
||||
<i data-toggle="popover" data-trigger="hover" data-html="true"
|
||||
data-content="{{ __('Allow upgrade/downgrade to a new product for the given server') }}"
|
||||
class="fas fa-info-circle"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="custom-control mb-3 p-0">
|
||||
<div class="col m-0 p-0 d-flex justify-content-between align-items-center">
|
||||
|
@ -191,6 +206,8 @@
|
|||
class="form-control @error('allocation-limit') is-invalid @enderror" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{{-- Design --}}
|
||||
|
|
|
@ -221,12 +221,7 @@
|
|||
<div class="card-footer">
|
||||
<div class="col-md-12 text-center">
|
||||
<!-- Upgrade Button trigger modal -->
|
||||
@if(!config("SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN") and Auth::user()->role=="admin")
|
||||
<i data-toggle="popover" data-trigger="hover"
|
||||
data-content="{{ __('To enable the upgrade/downgrade system, please set your Ptero Admin-User API Key in the Settings!') }}"
|
||||
class="fas fa-info-circle"></i>
|
||||
@endif
|
||||
@if(config("SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN") || Auth::user()->role=="admin")
|
||||
@if(config("SETTINGS::SYSTEM:ENABLE_UPGRADE"))
|
||||
<button type="button" data-toggle="modal" data-target="#UpgradeModal{{ $server->id }}" target="__blank"
|
||||
class="btn btn-info btn-md">
|
||||
<i class="fas fa-upload mr-2"></i>
|
||||
|
|
Loading…
Reference in a new issue