Merge pull request #1909 from pterodactyl/enhancement/new-server-admin
Enhancements to new server admin
This commit is contained in:
commit
72c144e309
20 changed files with 317 additions and 106 deletions
|
@ -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)) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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' : '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'),
|
||||
]);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue