Add ability to change server name, closes #563
This commit is contained in:
parent
e55d3c1a9a
commit
f8e98e9c9e
8 changed files with 156 additions and 3 deletions
|
@ -13,6 +13,9 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
|
|||
* Fix data integrity exception thrown when attempting to store updated server egg variables.
|
||||
* Added missing permissions check on 'SFTP Configuration' page to ensure user has permission to access a server's SFTP server before showing a user credentials.
|
||||
|
||||
### Added
|
||||
* Added ability for end users to change the name of their server through the UI. This option is only open to the server owner or an admin.
|
||||
|
||||
### Changed
|
||||
* Panel now throws proper 504: Gateway Timeout errors on server listing when daemon is offline.
|
||||
* Sessions handled through redis now use a seperate database (default `1`) to store session database to avoid logging users out when flushing the cache.
|
||||
|
|
59
app/Http/Controllers/Server/Settings/NameController.php
Normal file
59
app/Http/Controllers/Server/Settings/NameController.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Server\Settings;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Traits\Controllers\JavascriptInjection;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Pterodactyl\Http\Requests\Server\Settings\ChangeServerNameRequest;
|
||||
|
||||
class NameController extends Controller
|
||||
{
|
||||
use JavascriptInjection;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* NameController constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository
|
||||
*/
|
||||
public function __construct(ServerRepositoryInterface $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->authorize('view-name', $request->attributes->get('server'));
|
||||
$this->setRequest($request)->injectJavascript();
|
||||
|
||||
return view('server.settings.name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the stored name for a specific server.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Server\Settings\ChangeServerNameRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function update(ChangeServerNameRequest $request): RedirectResponse
|
||||
{
|
||||
$this->repository->update($request->getServer()->id, $request->validated());
|
||||
|
||||
return redirect()->route('server.settings.name', $request->getServer()->uuidShort);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Server\Settings;
|
||||
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Http\Requests\Server\ServerFormRequest;
|
||||
|
||||
class ChangeServerNameRequest extends ServerFormRequest
|
||||
{
|
||||
/**
|
||||
* Permission to use when checking if a user can access this resource.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function permission(): string
|
||||
{
|
||||
return 'edit-name';
|
||||
}
|
||||
|
||||
/**
|
||||
* Rules to use when validating the submitted data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => Server::getCreateRules()['name'],
|
||||
];
|
||||
}
|
||||
}
|
|
@ -27,5 +27,6 @@ return [
|
|||
'edit_file' => 'Edit File',
|
||||
'admin_header' => 'ADMINISTRATIVE',
|
||||
'admin' => 'Server Configuration',
|
||||
'server_name' => 'Server Name',
|
||||
],
|
||||
];
|
||||
|
|
|
@ -289,6 +289,11 @@ return [
|
|||
],
|
||||
],
|
||||
'config' => [
|
||||
'name' => [
|
||||
'header' => 'Server Name',
|
||||
'header_sub' => 'Change this server\'s name.',
|
||||
'details' => 'The server name is only a reference to this server on the panel, and will not affect any server specific configurations that may display to users in games.',
|
||||
],
|
||||
'startup' => [
|
||||
'header' => 'Start Configuration',
|
||||
'header_sub' => 'Control server startup arguments.',
|
||||
|
|
|
@ -184,6 +184,9 @@
|
|||
</span>
|
||||
</a>
|
||||
<ul class="treeview-menu">
|
||||
@can('view-name', $server)
|
||||
<li class="{{ Route::currentRouteName() !== 'server.settings.name' ?: 'active' }}"><a href="{{ route('server.settings.name', $server->uuidShort) }}"><i class="fa fa-angle-right"></i> @lang('navigation.server.server_name')</a></li>
|
||||
@endcan
|
||||
@can('view-allocations', $server)
|
||||
<li class="{{ Route::currentRouteName() !== 'server.settings.allocation' ?: 'active' }}"><a href="{{ route('server.settings.allocation', $server->uuidShort) }}"><i class="fa fa-angle-right"></i> @lang('navigation.server.port_allocations')</a></li>
|
||||
@endcan
|
||||
|
|
50
resources/themes/pterodactyl/server/settings/name.blade.php
Normal file
50
resources/themes/pterodactyl/server/settings/name.blade.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
{{-- Pterodactyl - Panel --}}
|
||||
{{-- Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com> --}}
|
||||
|
||||
{{-- This software is licensed under the terms of the MIT license. --}}
|
||||
{{-- https://opensource.org/licenses/MIT --}}
|
||||
@extends('layouts.master')
|
||||
|
||||
@section('title')
|
||||
@lang('server.config.name.header')
|
||||
@endsection
|
||||
|
||||
@section('content-header')
|
||||
<h1>@lang('server.config.name.header')<small>@lang('server.config.name.header_sub')</small></h1>
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="{{ route('index') }}">@lang('strings.home')</a></li>
|
||||
<li><a href="{{ route('server.index', $server->uuidShort) }}">{{ $server->name }}</a></li>
|
||||
<li>@lang('navigation.server.configuration')</li>
|
||||
<li class="active">@lang('navigation.server.server_name')</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<form action="{{ route('server.settings.name', $server->uuidShort) }}" method="POST">
|
||||
<div class="box">
|
||||
<div class="box-body">
|
||||
<div class="form-group no-margin-bottom">
|
||||
<label class="control-label" for="pServerName">@lang('server.config.name.header')</label>
|
||||
<div>
|
||||
<input type="text" name="name" id="pServerName" class="form-control" value="{{ $server->name }}" />
|
||||
<p class="small text-muted no-margin-bottom">@lang('server.config.name.details')</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
{{ method_field('PATCH') }}
|
||||
{{ csrf_field() }}
|
||||
<input type="submit" class="btn btn-sm btn-primary pull-right" value="@lang('strings.submit')" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('footer-scripts')
|
||||
@parent
|
||||
{!! Theme::js('js/frontend/server.socket.js') !!}
|
||||
@endsection
|
|
@ -19,11 +19,12 @@ Route::get('/console', 'ConsoleController@console')->name('server.console');
|
|||
*/
|
||||
Route::group(['prefix' => 'settings'], function () {
|
||||
Route::get('/allocation', 'Settings\AllocationController@index')->name('server.settings.allocation');
|
||||
Route::patch('/allocation', 'Settings\AllocationController@update');
|
||||
|
||||
Route::get('/name', 'Settings\NameController@index')->name('server.settings.name');
|
||||
Route::get('/sftp', 'Settings\SftpController@index')->name('server.settings.sftp');
|
||||
|
||||
Route::get('/startup', 'Settings\StartupController@index')->name('server.settings.startup');
|
||||
|
||||
Route::patch('/allocation', 'Settings\AllocationController@update');
|
||||
Route::patch('/name', 'Settings\NameController@update');
|
||||
Route::patch('/startup', 'Settings\StartupController@update');
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue