Merge branch 'development' of https://github.com/SahrulGnwn/controlpanel into development
This commit is contained in:
commit
278ebb4130
7 changed files with 82 additions and 13 deletions
|
@ -87,6 +87,33 @@ class Pterodactyl
|
|||
if ($response->failed()) throw self::getException("Failed to get nodes from pterodactyl - ", $response->status());
|
||||
return $response->json()['data'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
* @description Returns the infos of a single node
|
||||
*/
|
||||
public static function getNode($id) {
|
||||
try {
|
||||
$response = self::client()->get('/application/nodes/' . $id);
|
||||
} catch(Exception $e) {
|
||||
throw self::getException($e->getMessage());
|
||||
}
|
||||
if($response->failed()) throw self::getException("Failed to get node id " . $id . " - " . $response->status());
|
||||
return $response->json()['attributes'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function getServers() {
|
||||
try {
|
||||
$response = self::client()->get('/application/servers');
|
||||
} catch (Exception $e) {
|
||||
throw self::getException($e->getMessage());
|
||||
}
|
||||
if($response->failed()) throw self::getException("Failed to get list of servers - ", $response->status());
|
||||
return $response->json()['data'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
|
|
|
@ -160,6 +160,17 @@ class UserController extends Controller
|
|||
$user->delete();
|
||||
return redirect()->back()->with('success', __('user has been removed!'));
|
||||
}
|
||||
/**
|
||||
* Verifys the users email
|
||||
*
|
||||
* @param User $user
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function verifyEmail(Request $request, User $user)
|
||||
{
|
||||
$user->verifyEmail();
|
||||
return redirect()->back()->with('success', __('Email has been verified!'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
|
@ -285,6 +296,7 @@ class UserController extends Controller
|
|||
$suspendText = $user->isSuspended() ? __("Unsuspend") : __("Suspend");
|
||||
return '
|
||||
<a data-content="' . __("Login as User") . '" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.users.loginas', $user->id) . '" class="btn btn-sm btn-primary mr-1"><i class="fas fa-sign-in-alt"></i></a>
|
||||
<a data-content="' . __("Verify") . '" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.users.verifyEmail', $user->id) . '" class="btn btn-sm btn-primary mr-1"><i class="fas fa-sign-in-alt"></i></a>
|
||||
<a data-content="' . __("Show") . '" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.users.show', $user->id) . '" class="btn btn-sm text-white btn-warning mr-1"><i class="fas fa-eye"></i></a>
|
||||
<a data-content="' . __("Edit") . '" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.users.edit', $user->id) . '" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
|
||||
<form class="d-inline" method="post" action="' . route('admin.users.togglesuspend', $user->id) . '">
|
||||
|
|
|
@ -101,9 +101,31 @@ class ServerController extends Controller
|
|||
return redirect()->route('servers.index')->with('error', __('Server limit reached!'));
|
||||
}
|
||||
|
||||
// minimum credits
|
||||
// minimum credits && Check for Allocation
|
||||
if (FacadesRequest::has("product")) {
|
||||
$product = Product::findOrFail(FacadesRequest::input("product"));
|
||||
// Can we allocate the node? If not then error lol(I don't like overallocation)
|
||||
$node = Pterodactyl::getNode(FacadesRequest::input('node'));
|
||||
$nodeMem = $node['memory'];
|
||||
$nodeDisk = $node['disk'];
|
||||
$nodeName = $node['name'];
|
||||
$currServers = Auth::user()->servers();
|
||||
$currMem = 0;
|
||||
$currDisk = 0;
|
||||
foreach($currServers as $currServer) {
|
||||
$pteroServer = $currServer->getPterodactylServer();
|
||||
$psvAttr = $pteroServer['attributes'];
|
||||
if($psvAttr['node'] != $node['id'])
|
||||
continue;
|
||||
$currMem += $psvAttr['limits']['memory'];
|
||||
$currDisk += $psvAttr['limits']['disk'];
|
||||
}
|
||||
$currMem += $product->memory;
|
||||
$currDisk += $product->disk;
|
||||
if($currMem > $nodeMem || $currDisk > $nodeDisk)
|
||||
return redirect()->route('servers.index')->with('error', "The node '" . $nodeName . "' doesn't have the required memory or disk left to allocate this product.");
|
||||
|
||||
// Min. Credits
|
||||
if (
|
||||
Auth::user()->credits <
|
||||
($product->minimum_credits == -1
|
||||
|
|
|
@ -259,4 +259,11 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||
$status = str_replace(' ', '/', $status);
|
||||
return $status;
|
||||
}
|
||||
|
||||
public function verifyEmail()
|
||||
{
|
||||
$this->forceFill([
|
||||
'email_verified_at' => now(),
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -448,7 +448,7 @@ echo $cardheader;
|
|||
?>
|
||||
<p class="login-box-msg">All done!</p>
|
||||
<p class="login-box-msg">You may navigate to your Dashboard now and log in!</p>
|
||||
<a href="<?php echo "https://" . $_SERVER['SERVER_NAME']; ?>">
|
||||
<a href="<?php echo getEnvironmentValue("APP_URL"); ?>">
|
||||
<button class="btn btn-success">Lets go!</button>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -224,39 +224,39 @@
|
|||
<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>
|
||||
<span>{{ __('Upgrade') }}</span>
|
||||
<span>{{ __('Upgrade / Downgrade') }}</span>
|
||||
</button>
|
||||
<!-- Upgrade Modal -->
|
||||
<div style="width: 100%; margin-block-start: 100px;" class="modal fade" id="UpgradeModal{{ $server->id }}" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header card-header">
|
||||
<h5 class="modal-title">UPGRADE SERVER</h5>
|
||||
<h5 class="modal-title">{{__("Upgrade/Downgrade Server")}}</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body card-body">
|
||||
<strong>FOR DOWNGRADE PLEASE CHOOSE A PLAN BELOW YOUR PLAN</strong>
|
||||
<strong>{{__("FOR DOWNGRADE PLEASE CHOOSE A PLAN BELOW YOUR PLAN")}}</strong>
|
||||
<br>
|
||||
<br>
|
||||
<strong>YOUR PRODUCT : </strong> {{ $server->product->name }}
|
||||
<strong>{{__("YOUR PRODUCT")}} : </strong> {{ $server->product->name }}
|
||||
<br>
|
||||
<br>
|
||||
<form action="{{ route('servers.upgrade', ['server' => $server->id]) }}" method="POST">
|
||||
@csrf
|
||||
<select name="product_upgrade" id="product_upgrade" class="form-input2 form-control">
|
||||
<option value="">Select the product</option>
|
||||
<option value="">{{__("Select the product")}}</option>
|
||||
@foreach($products as $product)
|
||||
@if(in_array($server->egg, $product->eggs) && $product->id != $server->product->id)
|
||||
<option value="{{ $product->id }}">{{ $product->name }} [ {{ CREDITS_DISPLAY_NAME }} {{ $product->price }} ]</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</select>
|
||||
<br> Once the Upgrade button is pressed, we will automatically deduct the amount for the first hour according to the new product from your credits. <br>
|
||||
<br> {{__("Once the Upgrade button is pressed, we will automatically deduct the amount for the first hour according to the new product from your credits")}}. <br>
|
||||
</div>
|
||||
<div class="modal-footer card-body">
|
||||
<button type="submit" class="btn btn-primary" style="width: 100%"><strong>Upgrade</strong></button>
|
||||
<button type="submit" class="btn btn-primary" style="width: 100%"><strong>{{__("Change Product")}}</strong></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -273,20 +273,20 @@
|
|||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="DeleteModalLabel">Delete Server</h5>
|
||||
<h5 class="modal-title" id="DeleteModalLabel">{{__("Delete Server")}}</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
This is an irreversible action, all files of this server will be removed.!!!
|
||||
{{__("This is an irreversible action, all files of this server will be removed!")}}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<form class="d-inline" method="post" action="{{ route('servers.destroy', ['server' => $server->id]) }}">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-danger mr-1">Delete</button>
|
||||
<button data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-danger mr-1">{{__("Delete")}}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -305,4 +305,4 @@
|
|||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
@endsection
|
||||
@endsection
|
||||
|
|
|
@ -115,6 +115,7 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () {
|
|||
#users
|
||||
Route::get("users.json", [UserController::class, "json"])->name('users.json');
|
||||
Route::get('users/loginas/{user}', [UserController::class, 'loginAs'])->name('users.loginas');
|
||||
Route::get('users/verifyEmail/{user}', [UserController::class, 'verifyEmail'])->name('users.verifyEmail');
|
||||
Route::get('users/datatable', [UserController::class, 'datatable'])->name('users.datatable');
|
||||
Route::get('users/notifications', [UserController::class, 'notifications'])->name('users.notifications');
|
||||
Route::post('users/notifications', [UserController::class, 'notify'])->name('users.notifications');
|
||||
|
|
Loading…
Reference in a new issue