diff --git a/app/Contracts/Repository/UserRepositoryInterface.php b/app/Contracts/Repository/UserRepositoryInterface.php index 41649f48b..f5ba47b4b 100644 --- a/app/Contracts/Repository/UserRepositoryInterface.php +++ b/app/Contracts/Repository/UserRepositoryInterface.php @@ -22,4 +22,12 @@ interface UserRepositoryInterface extends RepositoryInterface, SearchableInterfa * @return \Illuminate\Support\Collection */ public function filterUsersByQuery(?string $query): Collection; + + /** + * Returns a user with the given id in a format that can be used for dropdowns. + * + * @param int $id + * @return \Pterodactyl\Models\Model + */ + public function filterById(int $id): \Pterodactyl\Models\Model; } diff --git a/app/Helpers/Utilities.php b/app/Helpers/Utilities.php index 2a0689124..d900425d9 100644 --- a/app/Helpers/Utilities.php +++ b/app/Helpers/Utilities.php @@ -6,6 +6,7 @@ use Exception; use Carbon\Carbon; use Cron\CronExpression; use Illuminate\Support\Facades\Log; +use Illuminate\Support\ViewErrorBag; class Utilities { @@ -50,4 +51,15 @@ class Utilities sprintf('%s %s %s * %s', $minute, $hour, $dayOfMonth, $dayOfWeek) )->getNextRunDate()); } + + public static function checked($name, $default) + { + $errors = session('errors'); + + if (isset($errors) && $errors instanceof ViewErrorBag && $errors->any()) { + return old($name) ? 'checked' : ''; + } + + return ($default) ? 'checked' : ''; + } } diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 14b3b594f..18e7e3b43 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -177,10 +177,15 @@ class UserController extends Controller * Get a JSON response of users on the system. * * @param \Illuminate\Http\Request $request - * @return \Illuminate\Support\Collection + * @return \Illuminate\Support\Collection|\Pterodactyl\Models\Model */ public function json(Request $request) { + // Handle single user requests. + if ($request->query('user_id')) { + return $this->repository->filterById($request->input('user_id')); + } + return $this->repository->filterUsersByQuery($request->input('q')); } } diff --git a/app/Repositories/Eloquent/UserRepository.php b/app/Repositories/Eloquent/UserRepository.php index 1ed6c5b74..b6468b5bb 100644 --- a/app/Repositories/Eloquent/UserRepository.php +++ b/app/Repositories/Eloquent/UserRepository.php @@ -54,4 +54,22 @@ class UserRepository extends EloquentRepository implements UserRepositoryInterfa return $item; }); } + + /** + * Returns a user with the given id in a format that can be used for dropdowns. + * + * @param int $id + * @return \Pterodactyl\Models\Model + */ + public function filterById(int $id): \Pterodactyl\Models\Model + { + $this->setColumns([ + 'id', 'email', 'username', 'name_first', 'name_last', + ]); + + $model = $this->getBuilder()->findOrFail($id, $this->getColumns())->getModel(); + $model->md5 = md5(strtolower($model->email)); + + return $model; + } } diff --git a/public/themes/pterodactyl/js/admin/new-server.js b/public/themes/pterodactyl/js/admin/new-server.js index 3da41da0f..cf8766356 100644 --- a/public/themes/pterodactyl/js/admin/new-server.js +++ b/public/themes/pterodactyl/js/admin/new-server.js @@ -41,47 +41,6 @@ $(document).ready(function() { $('#pAllocationAdditional').select2({ placeholder: 'Select Additional Allocations', }); - - $('#pUserId').select2({ - ajax: { - url: '/admin/users/accounts.json', - dataType: 'json', - delay: 250, - data: function (params) { - return { - q: params.term, // search term - page: params.page, - }; - }, - processResults: function (data, params) { - return { results: data }; - }, - cache: true, - }, - escapeMarkup: function (markup) { return markup; }, - minimumInputLength: 2, - templateResult: function (data) { - if (data.loading) return data.text; - - return '
Character limits: a-z A-Z 0-9 _ - .
and [Space]
(max 200 characters).
A brief description of this server.
The node which this server will be deployed to.
The main allocation that will be assigned to this server.
Additional allocations to assign to this server on creation.
The total number of databases a user is allowed to create for this server. Leave blank to allow unlimited.
The total number of allocations a user is allowed to create for this server. Leave blank to allow unlimited.
If you do not want to limit CPU usage, set the value to 0
. To determine a value, take the number of physical cores and multiply it by 100. For example, on a quad core system (4 * 100 = 400)
there is 400%
available. To limit a server to using half of a single core, you would set the value to 50
. To allow a server to use up to two physical cores, set the value to 200
. BlockIO should be a value between 10
and 1000
. Please see this documentation for more information about it.
+ +
If you do not want to limit CPU usage, set the value to 0
. To determine a value, take the number of physical cores and multiply it by 100. For example, on a quad core system (4 * 100 = 400)
there is 400%
available. To limit a server to using half of a single core, you would set the value to 50
. To allow a server to use up to two physical cores, set the value to 200
. BlockIO should be a value between 10
and 1000
. Please see this documentation for more information about it.
Advanced: Enter the specific CPU cores that this process can run on, or leave blank to allow all cores. This can be a single number, or a comma seperated list. Example: 0
, 0-1,3
, or 0,1,3,4
.
Advanced: The IO performance of this server relative to other running containers on the system. Value should be between 10
and 1000
.
Advanced: The IO performance of this server relative to other running containers on the system. Value should be between 10
and 1000
.
Select the Egg that will define how this server should operate.
Select a data pack to be automatically installed on this server when first created.
If the selected Egg has an install script attached to it, the script will run during install after the pack is installed. If you would like to skip this step, check this box.
The following data substitutes are available for the startup command: @{{SERVER_MEMORY}}
, @{{SERVER_IP}}
, and @{{SERVER_PORT}}
. They will be replaced with the allocated memory, server IP, and server port respectively.