Merge pull request #1909 from pterodactyl/enhancement/new-server-admin

Enhancements to new server admin
This commit is contained in:
Dane Everitt 2020-04-12 10:13:03 -07:00 committed by GitHub
commit 72c144e309
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 317 additions and 106 deletions

View file

@ -65,14 +65,14 @@ class EmailSettingsCommand extends Command
public function handle()
{
$this->variables['MAIL_DRIVER'] = $this->option('driver') ?? $this->choice(
trans('command/messages.environment.mail.ask_driver'), [
trans('command/messages.environment.mail.ask_driver'), [
'smtp' => 'SMTP Server',
'mail' => 'PHP\'s Internal Mail Function',
'mailgun' => 'Mailgun Transactional Email',
'mandrill' => 'Mandrill Transactional Email',
'postmark' => 'Postmarkapp Transactional Email',
], $this->config->get('mail.driver', 'smtp')
);
);
$method = 'setup' . studly_case($this->variables['MAIL_DRIVER']) . 'DriverVariables';
if (method_exists($this, $method)) {

View file

@ -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;
}

View file

@ -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' : '';
}
}

View file

@ -165,6 +165,7 @@ class DatabaseController extends Controller
$this->alert->danger(
sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage())
)->flash();
return $redirect->withInput($request->normalize());
} else {
throw $exception;

View file

@ -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'));
}
}

View file

@ -86,7 +86,7 @@ class ScheduleTaskController extends ClientApiController
}
$this->repository->update($task->id, [
'action' => $request->input('action'),
'action' => $request->input('action'),
'payload' => $request->input('payload'),
'time_offset' => $request->input('time_offset'),
]);

View file

@ -3,8 +3,6 @@
namespace Pterodactyl\Http\Controllers\Api\Remote\Servers;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Pterodactyl\Models\Server;
use Illuminate\Http\JsonResponse;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\Eloquent\BackupRepository;

View file

@ -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;
}
}